Skip to content

Instantly share code, notes, and snippets.

@OnkelTem
Last active April 28, 2016 08:50
Show Gist options
  • Save OnkelTem/cddf1df69955ea5b0b3a to your computer and use it in GitHub Desktop.
Save OnkelTem/cddf1df69955ea5b0b3a to your computer and use it in GitHub Desktop.
Dropbox startup script for Debian (start-stop-daemon). Place it into /etc/init.d/
#!/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 startup script for Debian (start-stop-daemon).
# Note that the version is hardcoded into the script, so you have to edit the 20th line when dropbox is updated.
# The reason for such a blunt behavior — in the way how dropbox daemon runs: it doesn't create a PID file.
#dropbox service
DROPBOX_USERS="dropbox"
DROPBOX_FUCKEDUP_SCRIPT=.dropbox-dist/dropboxd
DROPBOX_FUCKEDUP_DAEMON=.dropbox-dist/dropbox-lnx.x86_64-3.14.7/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/$DROPBOX_FUCKEDUP_SCRIPT
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/$DROPBOX_FUCKEDUP_DAEMON
fi
done
}
status() {
for dbuser in $DROPBOX_USERS; do
HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
if [ -x $HOMEDIR/$DAEMON ]; then
start-stop-daemon -o -c $dbuser -T -u $dbuser -x $HOMEDIR/$DROPBOX_FUCKEDUP_DAEMON
status=$?
echo -n "dropboxd for USER $dbuser: "
case "$status" in
0) echo "running."
;;
1|3) echo "not running."
;;
*) echo " error while determing state."
;;
esac
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
@ctonge
Copy link

ctonge commented Apr 4, 2016

Hi, please disregard, i found this instead and it works perfectly for me.... https://github.com/zzolo/dropbox-upstart

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