diff options
author | Tobias K <6317548+theCalcaholic@users.noreply.github.com> | 2022-07-25 19:48:36 +0300 |
---|---|---|
committer | Tobias K <6317548+theCalcaholic@users.noreply.github.com> | 2022-07-25 19:48:36 +0300 |
commit | 20eb4a6b06d3ff7f8d546aaef9f4797c51dab5e1 (patch) | |
tree | 0860b3a8f225d17a47eb2302e49f4740f3e19542 | |
parent | ba209a7a5ddb0f9e54274131fad3c8559ead08af (diff) |
metrics.sh: Fix set -u in calling script causing failure
-rw-r--r-- | bin/ncp/CONFIG/nc-datadir.sh | 16 | ||||
-rw-r--r-- | bin/ncp/SYSTEM/metrics.sh | 4 | ||||
-rw-r--r-- | etc/ncp-templates/ncp-metrics.cfg.sh | 1 | ||||
-rw-r--r-- | etc/ncp-templates/nextcloud.conf.sh | 1 |
4 files changed, 13 insertions, 9 deletions
diff --git a/bin/ncp/CONFIG/nc-datadir.sh b/bin/ncp/CONFIG/nc-datadir.sh index 6e798846..2503fce7 100644 --- a/bin/ncp/CONFIG/nc-datadir.sh +++ b/bin/ncp/CONFIG/nc-datadir.sh @@ -31,14 +31,14 @@ configure() echo -e "Error reading data directory. Is NextCloud running and configured?"; return 1; } - [ -d "$SRCDIR" ] || { echo -e "data directory $SRCDIR not found"; return 1; } + [ -d "${SRCDIR?}" ] || { echo -e "data directory $SRCDIR not found"; return 1; } - [[ "$SRCDIR" == "${DATADIR}" ]] && { echo -e "INFO: data already there"; return 0; } + [[ "$SRCDIR" == "${DATADIR?}" ]] && { echo -e "INFO: data already there"; return 0; } [[ "$SRCDIR" == "${DATADIR}"/data ]] && { echo -e "INFO: data already there"; return 0; } BASEDIR="${DATADIR}" # If the user chooses the root of the mountpoint, force a folder - mountpoint -q "${BASEDIR}" && { + mountpoint -q "${BASEDIR?}" && { BASEDIR="${BASEDIR}"/ncdata } @@ -62,7 +62,7 @@ configure() [ -d "${BASEDIR}" ] && { rmdir "${BASEDIR}" &>/dev/null || { local BKP="${BASEDIR}-$(date "+%m-%d-%y.%s")" - echo "INFO: ${BASEDIR} is not empty. Creating backup ${BKP}" + echo "INFO: ${BASEDIR} is not empty. Creating backup ${BKP?}" mv "${BASEDIR}" "${BKP}" } mkdir -p "${BASEDIR}" @@ -84,7 +84,7 @@ configure() # use encryption, if selected if is_active_app nc-encrypt; then # if we have encryption AND BTRFS, then store ncdata_enc in the subvolume - mv "$(dirname "${SRCDIR}")"/ncdata_enc "${ENCDIR}" + mv "$(dirname "${SRCDIR}")"/ncdata_enc "${ENCDIR?}" mkdir "${DATADIR}" && mount --bind "${SRCDIR}" "${DATADIR}" mkdir "$(dirname "${SRCDIR}")"/ncdata_enc && mount --bind "${ENCDIR}" "$(dirname "${SRCDIR}")"/ncdata_enc else @@ -93,7 +93,7 @@ configure() chown www-data: "${DATADIR}" # datadir - sed -i "s|'datadirectory' =>.*|'datadirectory' => '${DATADIR}',|" "$NCDIR"/config/config.php + sed -i "s|'datadirectory' =>.*|'datadirectory' => '${DATADIR}',|" "${NCDIR?}"/config/config.php ncc config:system:set logfile --value="${DATADIR}/nextcloud.log" set_ncpcfg datadir "${DATADIR}" @@ -101,7 +101,7 @@ configure() mkdir -p "${DATADIR}/tmp" chown www-data:www-data "${DATADIR}/tmp" ncc config:system:set tempdirectory --value "$DATADIR/tmp" - sed -i "s|^;\?upload_tmp_dir =.*$|uploadtmp_dir = ${DATADIR}/tmp|" /etc/php/"${PHPVER}"/cli/php.ini + sed -i "s|^;\?upload_tmp_dir =.*$|uploadtmp_dir = ${DATADIR}/tmp|" /etc/php/"${PHPVER?}"/cli/php.ini sed -i "s|^;\?upload_tmp_dir =.*$|upload_tmp_dir = ${DATADIR}/tmp|" /etc/php/"${PHPVER}"/fpm/php.ini sed -i "s|^;\?sys_temp_dir =.*$|sys_temp_dir = ${DATADIR}/tmp|" /etc/php/"${PHPVER}"/fpm/php.ini @@ -115,7 +115,7 @@ configure() restore_maintenance_mode ( - . "${BINDIR}/SYSTEM/metrics.sh" + . "${BINDIR?}/SYSTEM/metrics.sh" reload_metrics_config ) } diff --git a/bin/ncp/SYSTEM/metrics.sh b/bin/ncp/SYSTEM/metrics.sh index 7efb2b4a..83c45150 100644 --- a/bin/ncp/SYSTEM/metrics.sh +++ b/bin/ncp/SYSTEM/metrics.sh @@ -6,7 +6,7 @@ apt_install_with_recommends() { } is_supported() { - [[ "$DOCKERBUILD" == 1 ]] && [[ "$(lsb_release -r)" =~ .*10 ]] && return 1 + [[ "${DOCKERBUILD:-0}" == 1 ]] && [[ "$(lsb_release -r)" =~ .*10 ]] && return 1 return 0 } @@ -87,6 +87,7 @@ install() { ( set -e + set +u is_supported || { echo -e "Metrics app is not supported in debian 10 docker containers. Installation will be skipped." @@ -213,6 +214,7 @@ EOF } configure() { + set +u if [[ "$ACTIVE" != yes ]] then diff --git a/etc/ncp-templates/ncp-metrics.cfg.sh b/etc/ncp-templates/ncp-metrics.cfg.sh index 3571f454..8b99d80e 100644 --- a/etc/ncp-templates/ncp-metrics.cfg.sh +++ b/etc/ncp-templates/ncp-metrics.cfg.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -e +set +u source /usr/local/etc/library.sh if [[ "$1" == "--defaults" ]] diff --git a/etc/ncp-templates/nextcloud.conf.sh b/etc/ncp-templates/nextcloud.conf.sh index 00835d55..7cf6bca4 100644 --- a/etc/ncp-templates/nextcloud.conf.sh +++ b/etc/ncp-templates/nextcloud.conf.sh @@ -1,6 +1,7 @@ #! /bin/bash set -e +set +u source /usr/local/etc/library.sh [[ "$1" != "--defaults" ]] || echo "INFO: Restoring template to default settings" >&2 |