2015-02-14 18:14:34 +01:00
|
|
|
#!/bin/bash
|
2015-02-13 18:10:02 +01:00
|
|
|
# /etc/init.d/sync
|
|
|
|
# version 0.1 2013-03-12 (YYYY-MM-DD)
|
|
|
|
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: sync
|
|
|
|
# Required-Start: $local_fs $remote_fs
|
|
|
|
# Required-Stop: $local_fs $remote_fs
|
|
|
|
# Should-Start: $network
|
|
|
|
# Should-Stop: $network
|
|
|
|
# Default-Start: 2 3 4 5
|
|
|
|
# Default-Stop: 0 1 6
|
|
|
|
# Short-Description: Mozilla Sync server
|
|
|
|
# Description: Starts the mozilla sync server
|
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
# Source function library.
|
|
|
|
#. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
prog=sync
|
|
|
|
SYNC_USER=ffsync
|
|
|
|
SYNC_HOME=/opt/yunohost/ffsync
|
|
|
|
CPU_COUNT=2
|
|
|
|
pidfile=/tmp/sync.pid
|
2015-02-14 18:15:11 +01:00
|
|
|
lockfile=/var/run/sync.lock
|
2015-02-13 18:10:02 +01:00
|
|
|
conffile=${SYNC_HOME}/syncserver.ini
|
2015-02-14 18:16:45 +01:00
|
|
|
GUNICORN=${SYNC_HOME}/local/bin/gunicorn
|
2015-02-14 18:18:59 +01:00
|
|
|
GUNICORN_ARGS="--paste $conffile --access-logfile /var/log/ffsync.log --daemon -p $pidfile"
|
2015-02-13 18:10:02 +01:00
|
|
|
|
|
|
|
start () {
|
|
|
|
echo -n "Starting $prog"
|
2015-02-14 19:27:08 +01:00
|
|
|
start-stop-daemon --start -c ${SYNC_USER} --exec $GUNICORN -- $GUNICORN_ARGS
|
2015-02-13 18:10:02 +01:00
|
|
|
RETVAL=$?
|
|
|
|
echo
|
|
|
|
[ $RETVAL = 0 ] && touch ${lockfile}
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
echo "Stopping $prog"
|
|
|
|
start-stop-daemon --stop --quiet --oknodo --pidfile ${pidfile}
|
|
|
|
#log_end_msg $?
|
|
|
|
rm -f ${pidfile}
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo $"Usage: $prog {start|stop|restart|help}"
|
|
|
|
RETVAL=2
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit $RETVAL
|