Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias K <6317548+theCalcaholic@users.noreply.github.com>2022-04-08 15:54:58 +0300
committerTobias K <6317548+theCalcaholic@users.noreply.github.com>2022-04-08 16:07:34 +0300
commitd42a0c8cd5bf33334fecd8c23eeda0353a993d5c (patch)
tree5462fd6e1c0b7cf8ffed21da78c11b94988e2ced
parentfa0fbffb047cc0721b8296274ec86e745ba13ff3 (diff)
metrics.sh: Reinstall metrics when upgradingv1.47.0
- Upgrade ncp-metrics-exporter to v1.1.0 - Install prometheus-node-exporter-collectors when dist-upgrading from buster Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com>
-rwxr-xr-xbin/ncp-dist-upgrade3
-rw-r--r--bin/ncp/BACKUPS/nc-backup-auto.sh4
-rw-r--r--bin/ncp/SYSTEM/metrics.sh51
-rw-r--r--changelog.md8
-rw-r--r--updates/1.47.0.sh20
5 files changed, 57 insertions, 29 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/BACKUPS/nc-backup-auto.sh b/bin/ncp/BACKUPS/nc-backup-auto.sh
index b698147a..11837ad8 100644
--- a/bin/ncp/BACKUPS/nc-backup-auto.sh
+++ b/bin/ncp/BACKUPS/nc-backup-auto.sh
@@ -14,10 +14,6 @@ tmpl_get_destination() {
)
}
-is_active() {
- [[ $ACTIVE == "yes" ]]
-}
-
configure()
{
[[ $ACTIVE != "yes" ]] && {
diff --git a/bin/ncp/SYSTEM/metrics.sh b/bin/ncp/SYSTEM/metrics.sh
index 7674d01f..5aa7de30 100644
--- a/bin/ncp/SYSTEM/metrics.sh
+++ b/bin/ncp/SYSTEM/metrics.sh
@@ -1,5 +1,10 @@
#!/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
@@ -84,13 +89,12 @@ ARGS="--collector.filesystem.ignored-mount-points=\"^/(dev|proc|run|sys|mnt|var/
EOF
arch="$(uname -m)"
- [[ "$arch" =~ ("arm"|"aarch").* ]] && bin_arch="armv7" || bin_arch="i686"
- [[ "$(lsb_release -r)" =~ .*10 ]] && gcclib="lib32gcc1" || gcclib="lib32gcc-s1"
- [[ "$arch" == "x86_64" ]] && apt_install "$gcclib" libc6-i386
+ [[ "${arch}" =~ ^"arm" ]] && arch="armv7"
- wget -O "/usr/local/bin/ncp-metrics-exporter" \
- "https://github.com/theCalcaholic/ncp-metrics-exporter/releases/download/v1.0.0/${bin_arch}-ncp-metrics-exporter"
- chmod +x /usr/local/bin/ncp-metrics-exporter
+ 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
@@ -104,12 +108,12 @@ EOF
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 prometheus-node-exporter prometheus-node-exporter-collectors
+ 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 prometheus-node-exporter prometheus-node-exporter-collectors
+ apt_install_with_recommends prometheus-node-exporter
fi
if [[ "$DOCKERBUILD" == 1 ]]
@@ -134,7 +138,7 @@ NCP_CONFIG_DIR=/usr/local/etc
set +a
NAME=ncp-exporter
-DAEMON=/usr/local/bin/ncp-metrics-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"
@@ -173,7 +177,7 @@ Description=NCP Metrics Exporter
[Service]
Environment=NCP_CONFIG_DIR=/usr/local/etc
-ExecStart=/usr/local/bin/ncp-metrics-exporter
+ExecStart=/usr/local/lib/ncp-metrics/ncp-metrics-exporter
SyslogIdentifier=ncp-metrics
Restart=on-failure
RestartSec=30
@@ -218,19 +222,22 @@ configure() {
return 1
}
- [[ -n "$PASSWORD" ]] || {
- echo -e "ERROR: Password can not be empty!" >&2
- return 1
- }
+ 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
- }
+ [[ ${#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"
+ 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
@@ -252,7 +259,7 @@ configure() {
return 1
}
- echo "Metrics 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
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/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