Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
# dropbox service
#DROPBOX_USERS="user1 user2"
DROPBOX_GROUP=dropbox
IFS=,
DROPBOX_USERS=$(getent group "${DROPBOX_GROUP}" | cut -d: -f4)
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
@klynch

This comment has been minimized.

Copy link
Owner Author

klynch commented Mar 9, 2011

modified the dropbox init.d startup script from http://wiki.dropbox.com/TipsAndTricks/TextBasedLinuxInstall/UbuntuStartup so that it doesn't need to be edited for every user. Instead, just create a dropbox group and add all users to that.

@jean

This comment has been minimized.

Copy link

jean commented Jan 27, 2014

Hmm, why would I be getting two PIDs here?

jean@klippie:~/repos/git/dropbox-start-script$ /etc/init.d/dropbox status
dropboxd for USER jean: running (pid 1154
3246)

The first is stable, the second new every time. pgrep is stable:

$ pgrep -u jean dropbox
1154
@fbsdev

This comment has been minimized.

Copy link

fbsdev commented Oct 6, 2015

Pertect, install and working from dropbox 3.10.7 -
change only line
DAEMON=.dropbox-dist/dropboxd (with end 'd')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.