diff options
author | Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> | 2022-04-08 16:09:26 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-08 16:09:26 +0300 |
commit | 2fbb82df856b7885e1c1560ba63e8fd7562e73b8 (patch) | |
tree | 5462fd6e1c0b7cf8ffed21da78c11b94988e2ced | |
parent | 99a3c45592abc4937b12f2f93b0e81a6aa3fd97d (diff) | |
parent | d42a0c8cd5bf33334fecd8c23eeda0353a993d5c (diff) |
Merge pull request #1444 from feature/custom-prometheus-exporter
Add custom metrics exporter
-rwxr-xr-x | bin/ncp-dist-upgrade | 3 | ||||
-rwxr-xr-x | bin/ncp-update | 2 | ||||
-rw-r--r-- | bin/ncp/BACKUPS/nc-backup-auto.sh | 12 | ||||
-rw-r--r-- | bin/ncp/BACKUPS/nc-backup.sh | 11 | ||||
-rw-r--r-- | bin/ncp/BACKUPS/nc-snapshot-sync.sh | 25 | ||||
-rw-r--r-- | bin/ncp/CONFIG/nc-datadir.sh | 5 | ||||
-rw-r--r-- | bin/ncp/CONFIG/nc-nextcloud.sh | 10 | ||||
-rw-r--r-- | bin/ncp/SYSTEM/metrics.sh | 240 | ||||
-rw-r--r-- | changelog.md | 8 | ||||
-rw-r--r-- | etc/ncp-templates/ncp-metrics.cfg.sh | 85 | ||||
-rw-r--r-- | etc/ncp-templates/nextcloud.conf.sh | 22 | ||||
-rwxr-xr-x | update.sh | 3 | ||||
-rw-r--r-- | updates/1.47.0.sh | 20 |
13 files changed, 408 insertions, 38 deletions
diff --git a/bin/ncp-dist-upgrade b/bin/ncp-dist-upgrade index d6c399ab..2deacd13 100755 --- a/bin/ncp-dist-upgrade +++ b/bin/ncp-dist-upgrade @@ -89,6 +89,9 @@ sleep 2 # avoid systemd thinking that PHP is in a crash/restart loop $APTINSTALL -t ${release_new} php${php_ver_new}-gmp #$APTINSTALL -t ${release_new} imagemagick php${php_ver_new}-imagick ghostscript +# Reinstall prometheus-node-exporter, specifically WITH install-recommends to include collectors on bullseye and later +{ dpkg -l | grep '^ii.*prometheus-node-exporter' >/dev/null && apt-get install -y prometheus-node-exporter-collectors; } || true + apt-get autoremove -y apt-get clean diff --git a/bin/ncp-update b/bin/ncp-update index 15752f6b..25f1ed62 100755 --- a/bin/ncp-update +++ b/bin/ncp-update @@ -2,6 +2,8 @@ # update latest NextCloudPi code from github +[[ -z "$DBG" ]] || set -$DBG + { [ "$(id -u)" -ne 0 ] && { printf "Must be run as root. Try 'sudo $0'\n"; exit 1; } diff --git a/bin/ncp/BACKUPS/nc-backup-auto.sh b/bin/ncp/BACKUPS/nc-backup-auto.sh index 40c85fa4..11837ad8 100644 --- a/bin/ncp/BACKUPS/nc-backup-auto.sh +++ b/bin/ncp/BACKUPS/nc-backup-auto.sh @@ -7,6 +7,13 @@ # More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/ # +tmpl_get_destination() { + ( + . /usr/local/etc/library.sh + find_app_param nc-backup-auto DESTDIR + ) +} + configure() { [[ $ACTIVE != "yes" ]] && { @@ -44,6 +51,11 @@ EOF chmod 644 /etc/cron.d/ncp-backup-auto service cron restart + ( + . "${BINDIR}/SYSTEM/metrics.sh" + reload_metrics_config + ) + echo "automatic backups enabled" } diff --git a/bin/ncp/BACKUPS/nc-backup.sh b/bin/ncp/BACKUPS/nc-backup.sh index 25f5285f..c00298e0 100644 --- a/bin/ncp/BACKUPS/nc-backup.sh +++ b/bin/ncp/BACKUPS/nc-backup.sh @@ -7,6 +7,13 @@ # More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/ # +tmpl_get_destination() { + ( + . /usr/local/etc/library.sh + find_app_param nc-backup DESTDIR + ) +} + install() { apt-get update @@ -123,6 +130,10 @@ EOF configure() { + ( + . "${BINDIR}/SYSTEM/metrics.sh" + reload_metrics_config + ) ncp-backup "$DESTDIR" "$INCLUDEDATA" "$COMPRESS" "$BACKUPLIMIT" } diff --git a/bin/ncp/BACKUPS/nc-snapshot-sync.sh b/bin/ncp/BACKUPS/nc-snapshot-sync.sh index f27bf46a..0c4c905e 100644 --- a/bin/ncp/BACKUPS/nc-snapshot-sync.sh +++ b/bin/ncp/BACKUPS/nc-snapshot-sync.sh @@ -9,6 +9,25 @@ # +tmpl_get_destination() { + ( + . /usr/local/etc/library.sh + find_app_param nc-snapshot-sync DESTINATION + ) +} + +tmpl_is_destination_local() { + ( + . /usr/local/etc/library.sh + is_active_app nc-snapshot-sync || exit 1 + ! [[ "$(find_app_param nc-snapshot-sync DESTINATION)" =~ .*"@".*":".* ]] + ) +} + +is_active() { + [[ $ACTIVE == "yes" ]] +} + install() { apt-get update @@ -46,6 +65,12 @@ configure() echo "30 4 */${SYNCDAYS} * * root /usr/local/bin/btrfs-sync -qd $ZIP \"$SNAPDIR\" \"$DESTINATION\"" > /etc/cron.d/ncp-snapsync-auto chmod 644 /etc/cron.d/ncp-snapsync-auto service cron restart + + ( + . "${BINDIR}/SYSTEM/metrics.sh" + reload_metrics_config + ) + echo "snapshot sync enabled" } diff --git a/bin/ncp/CONFIG/nc-datadir.sh b/bin/ncp/CONFIG/nc-datadir.sh index dcb56d14..6e798846 100644 --- a/bin/ncp/CONFIG/nc-datadir.sh +++ b/bin/ncp/CONFIG/nc-datadir.sh @@ -113,6 +113,11 @@ configure() sed -i "s|logpath =.*nextcloud.log|logpath = ${DATADIR}/nextcloud.log|" /etc/fail2ban/jail.local restore_maintenance_mode + + ( + . "${BINDIR}/SYSTEM/metrics.sh" + reload_metrics_config + ) } # License diff --git a/bin/ncp/CONFIG/nc-nextcloud.sh b/bin/ncp/CONFIG/nc-nextcloud.sh index 0d1ce12d..381aeb07 100644 --- a/bin/ncp/CONFIG/nc-nextcloud.sh +++ b/bin/ncp/CONFIG/nc-nextcloud.sh @@ -215,12 +215,14 @@ EOF cat > /etc/systemd/system/notify_push.service <<EOF [Unit] Description = Push daemon for Nextcloud clients -After = mysql.service +After=mysql.service +After=redis.service +Requires=redis.service [Service] -Environment = PORT=7867 -Environment = NEXTCLOUD_URL=https://localhost -ExecStart = /var/www/nextcloud/apps/notify_push/bin/"${arch}"/notify_push --allow-self-signed /var/www/nextcloud/config/config.php +Environment=PORT=7867 +Environment=NEXTCLOUD_URL=https://localhost +ExecStart=/var/www/nextcloud/apps/notify_push/bin/"${arch}"/notify_push --allow-self-signed /var/www/nextcloud/config/config.php User=www-data [Install] diff --git a/bin/ncp/SYSTEM/metrics.sh b/bin/ncp/SYSTEM/metrics.sh index 0790f76f..5aa7de30 100644 --- a/bin/ncp/SYSTEM/metrics.sh +++ b/bin/ncp/SYSTEM/metrics.sh @@ -1,7 +1,20 @@ #!/bin/bash +apt_install_with_recommends() { + apt-get update --allow-releaseinfo-change + DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::="--force-confold" "$@" +} + +is_supported() { + [[ "$DOCKERBUILD" == 1 ]] && [[ "$(lsb_release -r)" =~ .*10 ]] && return 1 + return 0 +} + is_active() { - systemctl is-active -q prometheus-node-exporter || return 1 + is_supported || return 1 + + metrics_services status > /dev/null 2>&1 || return 1 + # systemctl is-active -q prometheus-node-exporter || return 1 return 0 } @@ -13,20 +26,172 @@ tmpl_metrics_enabled() { ) } +reload_metrics_config() { + is_supported || return 0 + + install_template ncp-metrics.cfg.sh "/usr/local/etc/ncp-metrics.cfg" || { + echo "ERROR while generating ncp-metrics.conf!" + return 1 + } + service ncp-metrics-exporter status > /dev/null && { + service ncp-metrics-exporter restart + service ncp-metrics-exporter status > /dev/null 2>&1 || { + rc=$? + echo -e "WARNING: An error ncp-metrics exporter failed to start (exit-code $rc)!" + return 1 + } + } +} + +metrics_services() { + cmd="${1?}" + + if [[ "$cmd" =~ (start|stop|restart|reload|status) ]] + then + rc1=0 + rc2=0 + service prometheus-node-exporter "$cmd" || rc1=$? + service ncp-metrics-exporter "$cmd" || rc2=$? + [[ $rc1 > $rc2 ]] && return $rc1 + return $rc2 + fi + + if ! [[ "$cmd" =~ (en|dis)able ]] + then + echo -e "ERROR: Invalid command: metrics_services ${cmd}!" + exit 1 + fi + + if [[ "$DOCKERBUILD" == 1 ]] + then + update-rc.d ncp-metrics "$cmd" + return $? + else + systemctl "$cmd" prometheus-node-exporter ncp-metrics-exporter + return $? + fi +} + install() { # Subshell to return on failure instead of exiting (due to set -e) ( set -e + + is_supported || { + echo -e "Metrics app is not supported in debian 10 docker containers. Installation will be skipped." + return 0 + } + cat > /etc/default/prometheus-node-exporter <<'EOF' ARGS="--collector.filesystem.ignored-mount-points=\"^/(dev|proc|run|sys|mnt|var/log|var/lib/docker)($|/)\"" EOF - apt_install prometheus-node-exporter - # TODO: Docker support? - systemctl disable prometheus-node-exporter + arch="$(uname -m)" + [[ "${arch}" =~ ^"arm" ]] && arch="armv7" + + mkdir -p /usr/local/lib/ncp-metrics + wget -O "/usr/local/lib/ncp-metrics/ncp-metrics-exporter" \ + "https://github.com/theCalcaholic/ncp-metrics-exporter/releases/download/v1.1.0/ncp-metrics-exporter-${arch}" + chmod +x /usr/local/lib/ncp-metrics/ncp-metrics-exporter + + # Apply fix to init-d-script (https://salsa.debian.org/debian/sysvinit/-/commit/aa40516c) + # Otherwise the init.d scripts of prometheus-node-exporter won't work + # shellcheck disable=SC2016 + sed -i 's|status_of_proc "$DAEMON" "$NAME" ${PIDFILE:="-p ${PIDFILE}"}|status_of_proc ${PIDFILE:+-p "$PIDFILE"} "$DAEMON" "$NAME"|' /lib/init/init-d-script + + if [[ "$DOCKERBUILD" == 1 ]] + then + # during installation of prometheus-node-exporter `useradd` is used to create a user. + # However, `useradd` doesn't the symlink in /etc/shadow, so we need to temporarily move it back + trap "mv /etc/shadow /data/etc/shadow; ln -s /data/etc/shadow /etc/shadow" EXIT + rm /etc/shadow + cp /data/etc/shadow /etc/shadow + apt_install_with_recommends prometheus-node-exporter + mv /etc/shadow /data/etc/shadow + ln -s /data/etc/shadow /etc/shadow + trap - EXIT + else + apt_install_with_recommends prometheus-node-exporter + fi + + if [[ "$DOCKERBUILD" == 1 ]] + then + cat > /etc/init.d/ncp-metrics-exporter <<'EOF' +#!/bin/sh +# Generated by sysd2v v0.3 -- http://www.trek.eu.org/devel/sysd2v +# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing. +if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then + set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script +fi +### BEGIN INIT INFO +# Provides: ncp-metrics-exporter +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Description: NCP Metrics Exporter +### END INIT INFO +set -a +NCP_CONFIG_DIR=/usr/local/etc +set +a + +NAME=ncp-exporter +DAEMON=/usr/local/lib/ncp-metrics/ncp-metrics-exporter +PIDFILE=/var/run/ncp-metrics-exporter.pid +LOGFILE=/var/log/ncp-metrics.log +START_ARGS="--background --make-pidfile" +EOF + chmod +x /etc/init.d/ncp-metrics-exporter + + cat > /etc/services-available.d/101ncp-metrics <<EOF +#!/bin/bash + +source /usr/local/etc/library.sh +[[ "\$1" == "stop" ]] && { + echo "stopping prometheus-node-exporter..." service prometheus-node-exporter stop + echo "done." + echo "stopping ncp-metrics-exporter" + service ncp-metrics-exporter stop + echo "done." + exit 0 +} + +persistent_cfg /etc/default/prometheus-node-exporter + +echo "starting prometheus-node-exporter..." +service prometheus-node-exporter start +[[ -n "\$(pgrep prometheus)" ]] || echo -e "ERROR: prometheus-node-exporter failed to start!" +echo "starting ncp-metrics-exporter +service ncp-metrics-exporter start +EOF + chmod +x /etc/services-available.d/101ncp-metrics + + else + + cat <<EOF > /etc/systemd/system/ncp-metrics-exporter.service +[Unit] +Description=NCP Metrics Exporter + +[Service] +Environment=NCP_CONFIG_DIR=/usr/local/etc +ExecStart=/usr/local/lib/ncp-metrics/ncp-metrics-exporter +SyslogIdentifier=ncp-metrics +Restart=on-failure +RestartSec=30 + +[Install] +WantedBy=multi-user.target +EOF + + systemctl daemon-reload + + fi + + metrics_services stop + metrics_services disable ) } @@ -35,43 +200,68 @@ configure() { if [[ "$ACTIVE" != yes ]] then - install_template nextcloud.conf.sh /etc/apache2/sites-available/nextcloud.conf - systemctl disable prometheus-node-exporter - service prometheus-node-exporter stop - else - [[ -n "$USER" ]] || { - echo "ERROR: User can not be empty!" >&2 + install_template nextcloud.conf.sh /etc/apache2/sites-available/nextcloud.conf || { + install_template nextcloud.conf.sh /etc/apache2/sites-available/nextcloud.conf --allow-fallback + echo -e "ERROR while generating nextcloud.conf! Exiting..." return 1 } + echo "Disabling and stopping services..." + metrics_services disable + metrics_services stop + echo "done." + else + + is_supported || { + echo -e "Metrics app is not supported in debian 10 docker containers. Terminating..." + return 0 + } - [[ -n "$PASSWORD" ]] || { - echo "ERROR: Password can not be empty!" >&2 + [[ -n "$USER" ]] || { + echo -e "ERROR: User can not be empty!" >&2 return 1 } - [[ ${#PASSWORD} -ge 10 ]] || { - echo "ERROR: Password must be at least 10 characters long!" >&2 + if [[ "$METRICS_SKIP_PASSWORD_CONFIG" != "true" ]] + then + [[ -n "$PASSWORD" ]] || { + echo -e "ERROR: Password can not be empty!" >&2 + return 1 + } + + [[ ${#PASSWORD} -ge 10 ]] || { + echo -e "ERROR: Password must be at least 10 characters long!" >&2 + return 1 + } + + local htpasswd_file="/usr/local/etc/metrics.htpasswd" + rm -f "${htpasswd_file}" + echo "$PASSWORD" | htpasswd -ciB "${htpasswd_file}" "$USER" + fi + + echo "Generate config..." + reload_metrics_config + echo "done." + + echo "Enabling and starting services..." + metrics_services enable + metrics_services start + metrics_services status || { + echo -e "ERROR: Metrics services not running!" return 1 } + echo "done." - local htpasswd_file="/usr/local/etc/metrics.htpasswd" - rm -f "${htpasswd_file}" - echo "$PASSWORD" | htpasswd -ciB "${htpasswd_file}" "$USER" install_template nextcloud.conf.sh /etc/apache2/sites-available/nextcloud.conf || { - echo "ERROR while generating nextcloud.conf! Exiting..." + install_template nextcloud.conf.sh /etc/apache2/sites-available/nextcloud.conf --allow-fallback + echo -e "ERROR while generating nextcloud.conf! Exiting..." return 1 } - systemctl enable prometheus-node-exporter - service prometheus-node-exporter start - - echo "Metric endpoint enabled. You can test it at https://nextcloudpi.local/metrics/system (or under your NC domain under the same path)" + echo "Metrics endpoint enabled. You can test it at https://nextcloudpi.local/metrics/system and https://nextcloudpi.local/metrics/ncp (or under your NC domain under the same paths)" fi - echo "Apache Test:" - apache2ctl -t - bash -c "sleep 2 && service apache2 reload" &>/dev/null & + bash -c "sleep 2 && service apache2 reload" &>/dev/null & } diff --git a/changelog.md b/changelog.md index 6c8e9be9..79c05f93 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,9 @@ -[v1.46.10](https://github.com/nextcloud/nextcloudpi/commit/c076cb3) (2022-03-26) dnsmasq.sh: Workaround dnsmasq startup failure bug +[v1.47.0](https://github.com/nextcloud/nextcloudpi/commit/1ce2135) (2022-04-08) metrics.sh: Reinstall metrics when upgrading -[v1.46.9](https://github.com/nextcloud/nextcloudpi/commit/cd98b50) (2022-03-07) docker: adjust PHP version in apache config +[v1.46.10](https://github.com/nextcloud/nextcloudpi/commit/99a3c45) (2022-03-26) dnsmasq.sh: Workaround dnsmasq startup failure bug + +[v1.46.9 ](https://github.com/nextcloud/nextcloudpi/commit/cd98b50) (2022-03-07) docker: adjust PHP version in apache config [v1.46.8 ](https://github.com/nextcloud/nextcloudpi/commit/21b7fe7) (2022-03-04) SSH: cannot check for default password because of Debian bug #1003151 @@ -193,7 +195,7 @@ [v1.37.0 ](https://github.com/nextcloud/nextcloudpi/commit/effdd6c) (2021-07-03) upgrade to NC20.0.11 -[v1.36.3 ](https://github.com/nextcloud/nextcloudpi/commit/7b809d1) (2021-05-13) ncp-web: fix port checking for IPv6 dual stack +[v1.36.3, master](https://github.com/nextcloud/nextcloudpi/commit/7b809d1) (2021-05-13) ncp-web: fix port checking for IPv6 dual stack [v1.36.2 ](https://github.com/nextcloud/nextcloudpi/commit/1a8ac71) (2021-05-11) ncp-web: fix port checking diff --git a/etc/ncp-templates/ncp-metrics.cfg.sh b/etc/ncp-templates/ncp-metrics.cfg.sh new file mode 100644 index 00000000..b4adee65 --- /dev/null +++ b/etc/ncp-templates/ncp-metrics.cfg.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash + +set -e +source /usr/local/etc/library.sh + +if [[ "$1" == "--defaults" ]] +then + echo "INFO: Restoring template to default settings" >&2 + cat <<EOF +{ + "backups": [] +} +EOF +exit 0 +fi + +cat <<EOF +{ + "backups": [ +EOF + +NC_BACKUP_DIR="$( + source "${BINDIR}/BACKUPS/nc-backup.sh" + tmpl_get_destination +)" + +NC_BACKUP_AUTO_DIR="$( + source "${BINDIR}/BACKUPS/nc-backup-auto.sh" + tmpl_get_destination +)" +if [[ "$NC_BACKUP_DIR" == "$NC_BACKUP_AUTO_DIR" ]] +then + NC_BACKUP_AUTO_DIR="" +fi + +NC_BACKUP_PATTERN="nextcloud-bkp_(?P<year>\\\\d{4})(?P<month>\\\\d{2})(?P<day>\\\\d{2})_.*\\\\.tar(\\\\.gz)?" + +cat <<EOF + { + "path": "$NC_BACKUP_DIR", + "pattern": "$NC_BACKUP_PATTERN" + } +EOF +[[ -z "$NC_BACKUP_AUTO_DIR" ]] || { + cat <<EOF + ,{ + "path": "$NC_BACKUP_AUTO_DIR", + "pattern": "$NC_BACKUP_PATTERN" + } +EOF +} + +[[ "$DOCKERBUILD" == 1 ]] || { + + DATADIR=$( ncc config:system:get datadirectory ) || { + echo -e "ERROR: Could not get data directory. Is NextCloud running?"; + return 1; + } + NC_SNAPSHOTS_DIR="$(dirname "$DATADIR")/ncp-snapshots" + + NC_SNAPSHOTS_SYNC_DIR="$( + source "${BINDIR}/BACKUPS/nc-snapshot-sync.sh" + if tmpl_is_destination_local + then + tmpl_get_destination + fi + )" + + for snap_dir in "$NC_SNAPSHOTS_DIR" "$NC_SNAPSHOTS_SYNC_DIR" + do + [[ -n "$snap_dir" ]] || continue + cat <<EOF + ,{ + "path": "${snap_dir}", + "pattern": ".*_(?P<year>\\\\d+)-(?P<month>\\\\d+)-(?P<day>\\\\d+)_(?P<hour>\\\\d{2})(?P<minute>\\\\d{2})(?P<second>\\\\d{2})" + } +EOF + done + +} + +cat <<EOF + ] +} +EOF diff --git a/etc/ncp-templates/nextcloud.conf.sh b/etc/ncp-templates/nextcloud.conf.sh index c75deaea..65797779 100644 --- a/etc/ncp-templates/nextcloud.conf.sh +++ b/etc/ncp-templates/nextcloud.conf.sh @@ -86,14 +86,13 @@ if [[ "$1" != "--defaults" ]] && [[ "$METRICS_IS_ENABLED" == yes ]] then cat <<EOF - <Location /metrics/system> ProxyPass http://localhost:9100/metrics Order deny,allow Allow from all AuthType Basic - AuthName "Metrics" + AuthName "System Metrics" AuthUserFile /usr/local/etc/metrics.htpasswd <RequireAll> <RequireAny> @@ -101,7 +100,22 @@ then Require valid-user </RequireAny> </RequireAll> + </Location> + <Location /metrics/ncp> + ProxyPass http://localhost:9000/metrics + + Order deny,allow + Allow from all + AuthType Basic + AuthName "NCP Metrics" + AuthUserFile /usr/local/etc/metrics.htpasswd + <RequireAll> + <RequireAny> + Require host localhost + Require valid-user + </RequireAny> + </RequireAll> </Location> EOF fi @@ -125,6 +139,6 @@ cat <<EOF EOF if ! [[ -f /.ncp-image ]]; then - echo "Apache self check:" >> /var/log/ncp.log - apache2ctl -t >> /var/log/ncp.log 2>&1 + echo "Apache self check:" | tee /var/log/ncp.log >&2 + apache2ctl -t 2>&1 | tee /var/log/ncp.log >&2 fi @@ -10,7 +10,7 @@ source /usr/local/etc/library.sh -set -e +set -e$DBG CONFDIR=/usr/local/etc/ncp-config.d/ UPDATESDIR=updates @@ -37,7 +37,6 @@ nc-zram SSH fail2ban NFS -metrics " if is_docker &>/dev/null; then diff --git a/updates/1.47.0.sh b/updates/1.47.0.sh new file mode 100644 index 00000000..158cd7f7 --- /dev/null +++ b/updates/1.47.0.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +# Stop metrics services if running +for svc in prometheus-node-exporter ncp-metrics-exporter +do + service "$svc" status || [[ $? -ne 4 ]] || continue + service "$svc" stop +done + +# Reinstall metrics services +source /usr/local/etc/library.sh +install_app metrics +is_active_app metrics && ( + export METRICS_SKIP_PASSWORD_CONFIG=true + run_app metrics +) + +exit 0 |