Created
February 4, 2014 04:34
-
-
Save yig/8798208 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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