Compare commits

...

3 Commits

Author SHA1 Message Date
Paolo Asperti 66a33f797e
test cache_from
continuous-integration/drone/tag Build is passing Details
2023-11-09 18:17:37 +01:00
Paolo Asperti 926aaa0983
test layer squash
continuous-integration/drone/tag Build is passing Details
2023-11-09 18:12:06 +01:00
Paolo Asperti 49d431dc58
splitted entrypoint
continuous-integration/drone/tag Build is passing Details
2023-11-09 18:05:53 +01:00
4 changed files with 45 additions and 40 deletions

View File

@ -15,6 +15,7 @@ steps:
tags:
- latest
force_tag: true
cache_from: docker.asperti.com/paspo/nextcloudclient
trigger:
event:

View File

@ -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
View 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

View File

@ -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[@]}"