#!/bin/sh # # mldonkey_submit_dllink | # # submits a local torrent file, or an ed2k link to a running mldonkey. . /etc/conf.d/mldonkey if [ "${TERM}" = "dumb" ] then PRINT="xmessage -buttons ok -default ok" else PRINT="echo" fi if [ -n "`echo ${1} | grep "\.torrent$"`" ] then #DIRNAME=`dirname "${1}" 2>/dev/null` BASENAME=`basename "${1}" 2>/dev/null` if [ ! -f "${1}" ] then exec ${PRINT} Torrent file does not exist: ${1} exit 1 fi DLLINK=/tmp/`echo ${BASENAME} | sed s/[^[:alpha:][:digit:]]/_/g`.torrent cp "${1}" "${DLLINK}" chmod 664 ${DLLINK} elif [ -n "`echo ${1} | grep "^ed2k:\/\/|file|"`" ] then DLLINK=`perl -MURI::Escape -e "print uri_escape('${1}')"` else exec ${PRINT} Invalid dllink: ${1} exit 2 fi BASE="http://" if [ -n ${USERNAME} -a -n ${PASSWORD} ] then BASE=${BASE}${USERNAME}:${PASSWORD}@ fi BASE=${BASE}${SERVER}:${PORT} wget --spider ${BASE}/submit?q=dllink+${DLLINK} -q if [ "$?" -eq "0" ] then exec ${PRINT} Submitted ${1} else exec ${PRINT} Error submitting ${1} fi