Skip to content

Instantly share code, notes, and snippets.

@benhedrington
Created April 10, 2012 01:06
Show Gist options
  • Save benhedrington/2347727 to your computer and use it in GitHub Desktop.
Save benhedrington/2347727 to your computer and use it in GitHub Desktop.
Dropbox init.d
#!/bin/sh
# dropbox service
# Replace with linux users you want to run Dropbox clients for
DROPBOX_USERS="user1 user2"
DAEMON=.dropbox-dist/dropbox
start() {
echo "Starting dropbox..."
for dbuser in $DROPBOX_USERS; do
HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
if [ -x $HOMEDIR/$DAEMON ]; then
HOME="$HOMEDIR" start-stop-daemon -b -o -c $dbuser -S -u $dbuser -x $HOMEDIR/$DAEMON
fi
done
}
stop() {
echo "Stopping dropbox..."
for dbuser in $DROPBOX_USERS; do
HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
if [ -x $HOMEDIR/$DAEMON ]; then
start-stop-daemon -o -c $dbuser -K -u $dbuser -x $HOMEDIR/$DAEMON
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
Copy link

ghost commented Jan 23, 2015

There's a little error in it, avoiding Dropbox to start automatically:
A 'd' is missing at the end of line 6: DAEMON=.dropbox-dist/dropbox
It used to be DAEMON=.dropbox-dist/dropboxd

Thanks for the script anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment