Skip to content

Instantly share code, notes, and snippets.

@kbrnsr
Last active December 30, 2016 23:08
Embed
What would you like to do?
Retooled dropbox init file to work with dropbox systemd systemunit file. Should be in /bin as /bin/dropbox with permission 755, see my unit file here: https://gist.github.com/kbrnsr/3984a0b45dcce5430d01
#!/bin/sh
# To configure, add line with DROPBOX_USERS="user1 user2" to /etc/sysconfig/dropbox
# Probably should use a dropbox group in /etc/groups instead.
# Source function library.
. /etc/rc.d/init.d/functions
prog=dropboxd
lockfile=${LOCKFILE-/var/lock/subsys/$prog}
RETVAL=0
start() {
echo -n $"Starting $prog"
if [ -z $DROPBOX_USERS ] ; then
echo -n ": unconfigured: $config"
echo_failure
echo
rm -f ${lockfile} ${pidfile}
RETURN=6
return $RETVAL
fi
for dbuser in $DROPBOX_USERS; do
dbuser_home=`cat /etc/passwd | grep "^$dbuser:" | cut -d":" -f6`
daemon --user $dbuser /bin/sh -c "$dbuser_home/.dropbox-dist/dropboxd&"
done
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
status() {
for dbuser in $DROPBOX_USERS; do
dbpid=`pgrep -u $dbuser dropbox | grep -v grep`
if [ -z $dbpid ] ; then
echo "dropboxd for USER $dbuser: not running."
else
echo "dropboxd for USER $dbuser: running (pid $dbpid)"
fi
done
}
stop() {
echo -n $"Stopping $prog"
for dbuser in $DROPBOX_USERS; do
dbuser_home=`cat /etc/passwd | grep "^$dbuser:" | cut -d":" -f6`
killproc $dbuser_home/.dropbox-dist/dropbox
done
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
# See how we were called.
case "$1" in
start)
start
;;
status)
status
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $prog {start|status|stop|restart}"
RETVAL=3
esac
@piotr-dobrogost
Copy link

What's the original init file this one is based of?

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