Skip to content

Instantly share code, notes, and snippets.

@thisismitch

thisismitch/dropbox

Forked from migrs/dropbox
Last active Mar 26, 2018
Embed
What would you like to do?
/etc/init.d/dropbox
#!/bin/sh
### BEGIN INIT INFO
# Provides: dropbox
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: dropbox service
### END INIT INFO
[ -f /etc/default/dropbox ] && . /etc/default/dropbox
mkdir -p /var/run/dropbox
DAEMON=/opt/dropbox/dropboxd
start() {
echo "Starting dropbox..."
for dbuser in $DROPBOX_USERS; do
HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
if [ -x $DAEMON ]; then
echo "Starting dropbox for $dbuser"
HOME="$HOMEDIR" start-stop-daemon -b -o -c $dbuser -S -u $dbuser -x $DAEMON -p $HOMEDIR/.dropbox/dropbox.pid
fi
done
}
stop() {
echo "Stopping dropbox..."
for dbuser in $DROPBOX_USERS; do
HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
if [ -x $DAEMON ]; then
echo "Stopping dropbox for $dbuser"
start-stop-daemon -o -c $dbuser -K -u $dbuser -p $HOMEDIR/.dropbox/dropbox.pid
fi
done
}
status() {
for dbuser in $DROPBOX_USERS; do
dbpid=`pgrep -u $dbuser dropbox`
if [ -z $dbpid ] ; then
echo "dropboxd for USER $dbuser: not running."
else
echo "dropboxd for USER $dbuser: 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/dropbox {start|stop|reload|force-reload|restart|status}"
exit 1
esac
exit 0
DROPBOX_USERS="sammy"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment