#!/bin/sh
TORRENTS_DIR="/home/zver/torrents"
RUN_FILE="${TORRENTS_DIR}/running.txt"
LOG_FILE="${TORRENTS_DIR}/ctorrent.log"
DOWNLOADED_DIR="${TORRENTS_DIR}/downloaded"
SAVE_DIR="/home/user"
CTORRENT="/usr/local/bin/ctorrent"
if [ ! -x "${CTORRENT}" ]; then
echo "ctorrent binary not found"
exit 1
fi
if [ ! -d "${DOWNLOADED_DIR}" ]; then
mkdir -p "$DOWNLOADED_DIR"
fi
for trfile in `ls "${TORRENTS_DIR}" | grep -E '\.torrent$'`; do
if [ -f "${RUN_FILE}" ]; then
if [ ! -z "`cat "${RUN_FILE}" | grep -F "${trfile}"`" ]; then
ctorrent_run=`ps -ax | grep ctorrent`
if [ -z "${ctorrent_run}" ]; then
rm -f "$RUN_FILE" "$LOG_FILE"
mv "${TORRENTS_DIR}/${trfile}" "${DOWNLOADED_DIR}"
continue
else
break
fi
else
continue
fi
else
${CTORRENT} -a -e 0 -C 32 -U 32 "${TORRENTS_DIR}/${trfile}" > ${LOG_FILE} 2>&1 &
echo "${trfile}" > "${RUN_FILE}"
break
fi
done
exit 0
Последние комментарии
Может кто…