Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yig/8798208 to your computer and use it in GitHub Desktop.
Save yig/8798208 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Startup script for btsync
# Copy to /usr/local/etc/rc.d/S99btsync.sh and chown to root:root
#
# Stop myself if running
btsyncdir="/var/services/homes/yotam/btsync/"
btsync="${btsyncdir}/btsync"
pidfile="${btsyncdir}/.sync/sync.pid"
#
case $1 in
start)
if [ -e "${pidfile}" ] ; then
echo "btsync already running. PID=`cat \"${pidfile}\"`" >&2
exit
fi
echo "Starting btsync..."
case `whoami` in
yotam)
"${btsync}"
;;
root)
su yotam -c "${btsync}"
;;
*)
echo "Must be run as root or yotam" >&2
exit 1
;;
esac
;;
stop)
if [ -e "${pidfile}" ] ; then
echo "Stopping btsync..."
kill `cat $pidfile`
rm "${pidfile}"
else
echo "btsync is not running. No PID file." >&2
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 start|stop|restart" >&2
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment