#!/bin/sh set -e DATA_DIR="/srv/dropbox/data" CFG_DIR="/srv/dropbox/config" USERNAME="dropbox" # Default UID/GID to owner of the data directory USER_UID=${USER_UID:-$(stat -L -c "%u" $DATA_DIR)} USER_GID=${USER_GID:-$(stat -L -c "%u" $DATA_DIR)} if [ "$USER_GID" = 0 -o "$USER_GID" = 0 ]; then echo "User UID/GID could not be discovered, is $DATA_DIR mounted?" exit 1 fi # Create the user and group addgroup -g ${USER_GID} -S ${USERNAME} adduser -u ${USER_UID} -h /home/${USERNAME} -D -G ${USERNAME} ${USERNAME} ln -s /srv/dropbox/data /home/${USERNAME}/Dropbox ln -s /srv/dropbox/config /home/${USERNAME}/.dropbox # Allow runsv to write its superisory files for the main process mkdir /opt/dropbox-srv/supervise chown dropbox:dropbox /opt/dropbox-srv/supervise # Allow runsv to write its superisory files for the log process mkdir /opt/dropbox-srv/log/supervise chown dropbox:dropbox /opt/dropbox-srv/log/supervise if [ "$@" == "/bin/sh" ]; then exec "$@" else exec /usr/bin/dumb-init -c /sbin/su-exec ${USERNAME} "$@" fi