Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh -e
- ### BEGIN INIT INFO
- # Provides: btsync
- # 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: Multi-user daemonized version of btsync.
- # Description: Starts the btsync daemon for all registered users.
- ### END INIT INFO
- # Replace with linux users you want to run BTSync clients for
- BTSYNC_USERS="root"
- DAEMON=/opt/btsync
- start() {
- for btsuser in $BTSYNC_USERS; do
- HOMEDIR=`getent passwd $btsuser | cut -d: -f6`
- config=$HOMEDIR/.sync/config.json
- if [ -f $config ]; then
- echo "Starting BTSync for $btsuser"
- start-stop-daemon -b -o -c $btsuser -S -u $btsuser -x $DAEMON -- --config $config
- else
- echo "Couldn't start BTSync for $btsuser (no $config found)"
- fi
- done
- }
- stop() {
- for btsuser in $BTSYNC_USERS; do
- # dbpid=`pgrep -fu $btsuser $DAEMON`
- # if [ ! -z "$dbpid" ]; then
- # echo "Stopping btsync for $btsuser"
- start-stop-daemon -o -c $btsuser -K -u $btsuser -x $DAEMON
- # fi
- done
- }
- status() {
- for btsuser in $BTSYNC_USERS; do
- dbpid=`pgrep -fu $btsuser $DAEMON`
- if [ -z "$dbpid" ]; then
- echo "btsync for USER $btsuser: not running."
- else
- echo "btsync for USER $btsuser: running (pid $dbpid)"
- fi
- done
- }
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart|reload|force-reload)
- stop
- start
- ;;
- status)
- status
- ;;
- *)
- echo "Usage: /etc/init.d/btsync {start|stop|reload|force-reload|restart|status}"
- exit 1
- esac
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement