move debian scripts here

This commit is contained in:
tuna 2020-03-21 11:32:55 +08:00
parent 964e22659a
commit 1dc46a67a7

30
debian.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
set -e
set -o pipefail
set -u
export LOGNAME=tunasync
FTPSYNC="${FTPSYNC:-"ftpsync"}"
FTPSYNC_LOG_DIR="${FTPSYNC_LOG_DIR:-"/var/log/ftpsync"}"
trap 'kill $(jobs -p)' EXIT
if [[ $1 == sync:archive:* ]]; then
${FTPSYNC} $1 &
PID=$!
jobname=${1##sync:archive:}
jobname=${jobname//\/}
jobname=${jobname//.}
sleep 2
if [[ ! -f ${FTPSYNC_LOG_DIR}/ftpsync-${jobname}.log ]]; then
echo "Failed to start ftpsync, please check configuration file."
exit 1
fi
tail --retry -f "${FTPSYNC_LOG_DIR}/ftpsync-${jobname}.log" &
tail --retry -f "${FTPSYNC_LOG_DIR}/rsync-ftpsync-${jobname}.log" &
tail --retry -f "${FTPSYNC_LOG_DIR}/rsync-ftpsync-${jobname}.error" &
wait $PID
else
echo "Invalid command line"
exit 1
fi