fix start script
All checks were successful
continuous-integration/drone/tag Build is passing

This commit is contained in:
Paolo Asperti 2023-11-09 17:27:11 +01:00
parent 8e9a8a90ee
commit ddb252d701
Signed by: paspo
GPG Key ID: 06D46905D19D5182

View File

@ -14,7 +14,7 @@ NEXTCLOUD_SLEEP=${NEXTCLOUD_SLEEP:-30}
# check if group already exists
GRP_NAME=$(getent group "${USER_GID}" )
if [ "${GRP_NAME}" ] ; then
USER_GROUP=$( echo "${GRP_NAME}" | sed 's/\:.*//' )
USER_GROUP="${GRP_NAME//:*/}"
else
# if not, we create the group
addgroup -g "${USER_GID}" "${USER_GROUP}"
@ -23,7 +23,7 @@ fi
# check if user already exists
USR_NAME=$(getent passwd "${USER_UID}" )
if [ "${USR_NAME}" ] ; then
USER_NAME=$( echo "${USR_NAME}" | sed 's/\:.*//' )
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}"
@ -41,46 +41,46 @@ fi
PARAMS=()
if [ "${NEXTCLOUD_FORCE_TRUST}" = "1" ] ; then
PARAMS+="--trust"
PARAMS+=("--trust")
fi
if [ ! "${NEXTCLOUD_HTTPPROXY}" = "" ] ; then
PARAMS+="--httpproxy"
PARAMS+="${NEXTCLOUD_HTTPPROXY}"
PARAMS+=("--httpproxy")
PARAMS+=("${NEXTCLOUD_HTTPPROXY}")
fi
if [ ! "${NEXTCLOUD_UPLIMIT}" = "" ] ; then
PARAMS+="--uplimit"
PARAMS+="${NEXTCLOUD_UPLIMIT}"
PARAMS+=("--uplimit")
PARAMS+=("${NEXTCLOUD_UPLIMIT}")
fi
if [ ! "${NEXTCLOUD_DOWNLIMIT}" = "" ] ; then
PARAMS+="--downlimit"
PARAMS+="${NEXTCLOUD_DOWNLIMIT}"
PARAMS+=("--downlimit")
PARAMS+=("${NEXTCLOUD_DOWNLIMIT}")
fi
if [ ! "${NEXTCLOUD_EXCLUDEFILE}" = "" ] ; then
if [ -r "${NEXTCLOUD_EXCLUDEFILE}" ] ; then
PARAMS+="--exclude"
PARAMS+="${NEXTCLOUD_EXCLUDEFILE}"
PARAMS+=("--exclude")
PARAMS+=("${NEXTCLOUD_EXCLUDEFILE}")
fi
fi
if [ ! "${NEXTCLOUD_UNSYNCFILE}" = "" ] ; then
if [ -r "${NEXTCLOUD_UNSYNCFILE}" ] ; then
PARAMS+="--unsyncedfolders"
PARAMS+="'${NEXTCLOUD_UNSYNCFILE}'"
PARAMS+=("--unsyncedfolders")
PARAMS+=("${NEXTCLOUD_UNSYNCFILE}")
fi
fi
if [ "${NEXTCLOUD_SILENT}" = "1" ] ; then
PARAMS+="--silent"
PARAMS+=("--silent")
fi
PARAMS+="--non-interactive"
PARAMS+="-u"
PARAMS+="${NEXTCLOUD_USERNAME}"
PARAMS+="-p"
PARAMS+="${NEXTCLOUD_PASSWORD}"
PARAMS+="${NEXTCLOUD_DIR}"
PARAMS+="${NEXTCLOUD_URL}"
PARAMS+=("--non-interactive")
PARAMS+=("-u")
PARAMS+=("${NEXTCLOUD_USERNAME}")
PARAMS+=("-p")
PARAMS+=("${NEXTCLOUD_PASSWORD}")
PARAMS+=("${NEXTCLOUD_DIR}")
PARAMS+=("${NEXTCLOUD_URL}")
# main loop
while true; do
/bin/su -s /bin/sh "${USER_NAME}" -c "/usr/bin/nextcloudcmd ${PARAMS[@]}"
/bin/su -s /bin/sh "${USER_NAME}" -c /usr/bin/nextcloudcmd "${PARAMS[@]}"
sleep "${NEXTCLOUD_SLEEP}"
done