Skip to content

Instantly share code, notes, and snippets.

@dblock
Last active Sep 11, 2020
Embed
What would you like to do?
Auto-start Dropbox.
#!/bin/bash
DROPBOX_USERS="root"
DAEMON=.dropbox-dist/dropboxd
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
@dblock
Copy link
Author

dblock commented Sep 11, 2020

After some update the service would fail to start with "Exec format error". This is because the above script was missing a hashbing, #!/bin/bash1.

root@dblock-plum:~# service dropbox status
● dropbox.service
   Loaded: loaded (/etc/init.d/dropbox; bad; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2020-09-11 10:37:38 EDT; 6min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 25052 ExecStart=/etc/init.d/dropbox start (code=exited, status=203/EXEC)

Sep 11 10:37:38 dblock-plum systemd[1]: Stopped dropbox.service.
Sep 11 10:37:38 dblock-plum systemd[1]: Starting dropbox.service...
Sep 11 10:37:38 dblock-plum systemd[25052]: dropbox.service: Failed at step EXEC spawning /etc/init.d/dropbox: Exec format error
Sep 11 10:37:38 dblock-plum systemd[1]: dropbox.service: Control process exited, code=exited status=203
Sep 11 10:37:38 dblock-plum systemd[1]: Failed to start dropbox.service.
Sep 11 10:37:38 dblock-plum systemd[1]: dropbox.service: Unit entered failed state.
Sep 11 10:37:38 dblock-plum systemd[1]: dropbox.service: Failed with result 'exit-code'.

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