58 lines
1.7 KiB
Bash
Executable File
58 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
USER_NAME=${USER_NAME:-nextcloudclient}
|
|
USER_GRP=${USER_NAME}
|
|
USER_UID=${USER_UID:-1000}
|
|
USER_GID=${USER_GID:-1000}
|
|
NEXTCLOUD_USERNAME=${NEXTCLOUD_USERNAME:-username}
|
|
NEXTCLOUD_PASSWORD=${NEXTCLOUD_PASSWORD:-password}
|
|
NEXTCLOUD_URL=${NEXTCLOUD_URL:-https://nextcloud.example.com}
|
|
NEXTCLOUD_DIR=${NEXTCLOUD_DIR:-/data}
|
|
NEXTCLOUD_DIR_CHOWN=${NEXTCLOUD_DIR_CHOWN:-1}
|
|
|
|
# create the user/group
|
|
addgroup -g ${USER_GID} ${USER_GRP}
|
|
adduser -s /bin/false -D -H -G ${USER_GRP} -u ${USER_UID} ${USER_NAME}
|
|
|
|
# create dir if not exists (it should exist if you mapped it outside the container)
|
|
if [ ! -d "${NEXTCLOUD_DIR}" ] ; then
|
|
mkdir -p "${NEXTCLOUD_DIR}"
|
|
fi
|
|
|
|
# replace data directory permissions
|
|
if [ "${NEXTCLOUD_DIR_CHOWN}" = "1" ] ; then
|
|
chown -R ${USER_UID}:${USER_GID} "${NEXTCLOUD_DIR}"
|
|
fi
|
|
|
|
PARAMS=
|
|
if [ "${NEXTCLOUD_FORCE_TRUST}" = "1" ] ; then
|
|
PARAMS="${PARAMS} --trust"
|
|
fi
|
|
if [ ! "${NEXTCLOUD_HTTPPROXY}" = "" ] ; then
|
|
PARAMS="${PARAMS} --httpproxy '${NEXTCLOUD_HTTPPROXY}'"
|
|
fi
|
|
if [ ! "${NEXTCLOUD_UPLIMIT}" = "" ] ; then
|
|
PARAMS="${PARAMS} --uplimit '${NEXTCLOUD_UPLIMIT}'"
|
|
fi
|
|
if [ ! "${NEXTCLOUD_DOWNLIMIT}" = "" ] ; then
|
|
PARAMS="${PARAMS} --downlimit '${NEXTCLOUD_DOWNLIMIT}'"
|
|
fi
|
|
if [ ! "${NEXTCLOUD_EXCLUDEFILE}" = "" ] ; then
|
|
if [ -r "${NEXTCLOUD_EXCLUDEFILE}" ] ; then
|
|
PARAMS="${PARAMS} --exclude '${NEXTCLOUD_EXCLUDEFILE}'"
|
|
fi
|
|
fi
|
|
if [ ! "${NEXTCLOUD_UNSYNCFILE}" = "" ] ; then
|
|
if [ -r "${NEXTCLOUD_UNSYNCFILE}" ] ; then
|
|
PARAMS="${PARAMS} --unsyncedfolders '${NEXTCLOUD_UNSYNCFILE}'"
|
|
fi
|
|
fi
|
|
|
|
PARAMS="${PARAMS} --non-interactive -u ${NEXTCLOUD_USERNAME} -p ${NEXTCLOUD_PASSWORD} ${NEXTCLOUD_DIR} ${NEXTCLOUD_URL}"
|
|
|
|
# main loop
|
|
while true; do
|
|
/bin/su -s /bin/sh ${USER_NAME} -c "/usr/bin/nextcloudcmd ${PARAMS}"
|
|
sleep 10
|
|
done
|