abraunegg-onedrive/contrib/docker/entrypoint.sh
abraunegg 7cf2912d2d
Rework directory layout and refactor MD files for readability (#523)
* Move lots of stuff into contrib directory to clean up root folder
* Update autoconf files for new location of some files
* Refactor README split and move to docs directory
* Update INSTALL.md
* Update Makefile.in
* Install docs from new location
* Uninstall docs correctly
* Update Dockerfile
* Fix up Dockerfile spacing
* Move systemd stuff to contrib
* Move docker specific stuff to contrib/docker, update docs
* Fix Alpine and Stretch docker files
* Update configure after changed file locations
* Update INSTALL.md to include pkg-config as requirement
* Move also entrypoint.sh to contrib/docker
* Update 'min-notif-changes' to 'min-notify-changes' which was missed in PR #467
* Update to add --sync-root-files to usage.md and man page
* Update usage.md to include --auth-files ARG details
2019-06-11 18:40:05 +10:00

36 lines
902 B
Bash
Executable file

#!/bin/bash -eu
set +H -xeuo pipefail
ONEDRIVE_UID=$(stat /onedrive/data -c '%u')
ONEDRIVE_GID=$(stat /onedrive/data -c '%g')
# Create new group using target GID
if ! odgroup="$(getent group $ONEDRIVE_GID)"; then
odgroup='onedrive'
groupadd "${odgroup}" -g $ONEDRIVE_GID
else
odgroup=${odgroup%%:*}
fi
# Create new user using target UID
if ! oduser="$(getent passwd $ONEDRIVE_UID)"; then
oduser='onedrive'
useradd "${oduser}" -u $ONEDRIVE_UID -g $ONEDRIVE_GID
else
oduser="${oduser%%:*}"
usermod -g "${odgroup}" "${oduser}"
grep -qv root <( groups "${oduser}" ) || { echo 'ROOT level priviledges prohibited!'; exit 1; }
fi
chown "${oduser}:${odgroup}" /onedrive/ /onedrive/conf
# Default parameters
ARGS=(--monitor --verbose --confdir /onedrive/conf --syncdir /onedrive/data)
if [ ${#} -gt 0 ]; then
ARGS=("${@}")
fi
exec gosu "${oduser}" /usr/local/bin/onedrive "${ARGS[@]}"