From 1dc46a67a782798821cb880c22d6687d59855ce8 Mon Sep 17 00:00:00 2001 From: tuna Date: Sat, 21 Mar 2020 11:32:55 +0800 Subject: [PATCH] move debian scripts here --- debian.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 debian.sh diff --git a/debian.sh b/debian.sh new file mode 100755 index 0000000..8ae6b9a --- /dev/null +++ b/debian.sh @@ -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