Last active
April 28, 2016 08:50
-
-
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/
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 | |
### 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 |
Also should I un-comment all the init info lines? thanks again.
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
Hey thanks for this, but I'm somewhat of a newb to this stuff with init.d (mostly use upstart) and I'm not a seasoned linux guy. When I test this it says permission denied....i've change the user to my admin user, but maybe this is wrong to do. Trying it with the dropbox user you have in the script gives the same result. So somewhere along the line I don't have the correct permissions...any help narrowing that down is appreciated. Thanks!