#!/bin/bash SELF=$(readlink -f $0) DIR=$(dirname $SELF) RSYNC_USER="aloudata" RSYNC_PASSWORD="VPwSrFw2lVfFokJ" PORT=20002 LOG_FILE=${DIR}/log/rsyncd.log PASSWORD_FILE=${DIR}/conf/passwordfile start() { echo "${RSYNC_USER}:${RSYNC_PASSWORD}" > ${PASSWORD_FILE} chmod 600 ${PASSWORD_FILE} sed -i "s#^auth users =.*#auth users = ${RSYNC_USER}#g" ${DIR}/conf/rsync.conf sed -i "s#^secrets file =.*#secrets file = ${PASSWORD_FILE}#g" ${DIR}/conf/rsync.conf eval "${DIR}/bin/rsync --daemon --port=${PORT} --config=${DIR}/conf/rsync.conf --log-file=${LOG_FILE}" return $? } stop() { local PID=$(pgrep -f "${DIR}/bin/rsync --daemon .*") kill -9 ${PID} >/dev/null 2>&1 } restart() { stop sleep 1 start return $? } status() { local PID=$(pgrep -f "${DIR}/bin/rsync --daemon .*") if [ -z "$PID" ]; then echo "Rsyncd is not running." return 1 fi eval "ps -ef |grep '${DIR}/bin/rsync '|grep -v grep" echo "Rsyncd is running." return 0 } eval "$@" exit $?