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