This commit is contained in:
parent
5ae52fa449
commit
49d431dc58
@ -22,6 +22,6 @@ ENV \
|
||||
NEXTCLOUD_SILENT= \
|
||||
NEXTCLOUD_SLEEP=30
|
||||
|
||||
COPY start.sh /start.sh
|
||||
COPY entrypoint.sh start.sh /
|
||||
|
||||
ENTRYPOINT ["/bin/bash", "/start.sh"]
|
||||
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
|
||||
|
41
entrypoint.sh
Executable file
41
entrypoint.sh
Executable file
@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
USER_NAME=${USER_NAME:-nextcloudclient}
|
||||
USER_GROUP=${USER_GROUP:-nextcloudgroup}
|
||||
USER_UID=${USER_UID:-1000}
|
||||
USER_GID=${USER_GID:-1000}
|
||||
NEXTCLOUD_SLEEP=${NEXTCLOUD_SLEEP:-30}
|
||||
|
||||
# check if group already exists
|
||||
GRP_NAME=$(getent group "${USER_GID}" )
|
||||
if [ "${GRP_NAME}" ] ; then
|
||||
USER_GROUP="${GRP_NAME//:*/}"
|
||||
else
|
||||
# if not, we create the group
|
||||
addgroup -g "${USER_GID}" "${USER_GROUP}"
|
||||
fi
|
||||
|
||||
# check if user already exists
|
||||
USR_NAME=$(getent passwd "${USER_UID}" )
|
||||
if [ "${USR_NAME}" ] ; then
|
||||
USER_NAME="${USR_NAME//:*/}"
|
||||
else
|
||||
# if not, we create the user
|
||||
adduser -s /bin/false -D -H -G "${USER_GROUP}" -u "${USER_UID}" "${USER_NAME}"
|
||||
fi
|
||||
|
||||
# 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
|
||||
|
||||
# main loop
|
||||
while true; do
|
||||
/bin/su -s /bin/sh -c "/start.sh" "${USER_NAME}"
|
||||
sleep "${NEXTCLOUD_SLEEP}"
|
||||
done
|
39
start.sh
39
start.sh
@ -1,43 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
USER_NAME=${USER_NAME:-nextcloudclient}
|
||||
USER_GROUP=${USER_GROUP:-nextcloudgroup}
|
||||
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}
|
||||
NEXTCLOUD_SLEEP=${NEXTCLOUD_SLEEP:-30}
|
||||
|
||||
# check if group already exists
|
||||
GRP_NAME=$(getent group "${USER_GID}" )
|
||||
if [ "${GRP_NAME}" ] ; then
|
||||
USER_GROUP="${GRP_NAME//:*/}"
|
||||
else
|
||||
# if not, we create the group
|
||||
addgroup -g "${USER_GID}" "${USER_GROUP}"
|
||||
fi
|
||||
|
||||
# check if user already exists
|
||||
USR_NAME=$(getent passwd "${USER_UID}" )
|
||||
if [ "${USR_NAME}" ] ; then
|
||||
USER_NAME="${USR_NAME//:*/}"
|
||||
else
|
||||
# if not, we create the user
|
||||
adduser -s /bin/false -D -H -G "${USER_GROUP}" -u "${USER_UID}" "${USER_NAME}"
|
||||
fi
|
||||
|
||||
# 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
|
||||
@ -79,8 +46,4 @@ PARAMS+=("${NEXTCLOUD_PASSWORD}")
|
||||
PARAMS+=("${NEXTCLOUD_DIR}")
|
||||
PARAMS+=("${NEXTCLOUD_URL}")
|
||||
|
||||
# main loop
|
||||
while true; do
|
||||
/bin/su -s /bin/sh "${USER_NAME}" -- /usr/bin/nextcloudcmd "${PARAMS[@]}"
|
||||
sleep "${NEXTCLOUD_SLEEP}"
|
||||
done
|
||||
/usr/bin/nextcloudcmd "${PARAMS[@]}"
|
||||
|
Loading…
Reference in New Issue
Block a user