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
path: root/bin/ncp
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 /bin/ncp
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>
Diffstat (limited to 'bin/ncp')
-rw-r--r--bin/ncp/BACKUPS/nc-backup-auto.sh4
-rw-r--r--bin/ncp/SYSTEM/metrics.sh51
2 files changed, 29 insertions, 26 deletions
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 &