11#! /bin/bash
22
3+ apt_install_with_recommends () {
4+ apt-get update --allow-releaseinfo-change
5+ DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=" --force-confold" " $@ "
6+ }
7+
38is_supported () {
49 [[ " $DOCKERBUILD " == 1 ]] && [[ " $( lsb_release -r) " =~ .* 10 ]] && return 1
510 return 0
@@ -84,13 +89,12 @@ ARGS="--collector.filesystem.ignored-mount-points=\"^/(dev|proc|run|sys|mnt|var/
8489EOF
8590
8691 arch=" $( uname -m) "
87- [[ " $arch " =~ (" arm" | " aarch" ).* ]] && bin_arch=" armv7" || bin_arch=" i686"
88- [[ " $( lsb_release -r) " =~ .* 10 ]] && gcclib=" lib32gcc1" || gcclib=" lib32gcc-s1"
89- [[ " $arch " == " x86_64" ]] && apt_install " $gcclib " libc6-i386
92+ [[ " ${arch} " =~ ^" arm" ]] && arch=" armv7"
9093
91- wget -O " /usr/local/bin/ncp-metrics-exporter" \
92- " https://github.com/theCalcaholic/ncp-metrics-exporter/releases/download/v1.0.0/${bin_arch} -ncp-metrics-exporter"
93- chmod +x /usr/local/bin/ncp-metrics-exporter
94+ mkdir -p /usr/local/lib/ncp-metrics
95+ wget -O " /usr/local/lib/ncp-metrics/ncp-metrics-exporter" \
96+ " https://github.com/theCalcaholic/ncp-metrics-exporter/releases/download/v1.1.0/ncp-metrics-exporter-${arch} "
97+ chmod +x /usr/local/lib/ncp-metrics/ncp-metrics-exporter
9498
9599 # Apply fix to init-d-script (https://salsa.debian.org/debian/sysvinit/-/commit/aa40516c)
96100 # Otherwise the init.d scripts of prometheus-node-exporter won't work
@@ -104,12 +108,12 @@ EOF
104108 trap " mv /etc/shadow /data/etc/shadow; ln -s /data/etc/shadow /etc/shadow" EXIT
105109 rm /etc/shadow
106110 cp /data/etc/shadow /etc/shadow
107- apt_install prometheus-node-exporter prometheus-node-exporter-collectors
111+ apt_install_with_recommends prometheus-node-exporter
108112 mv /etc/shadow /data/etc/shadow
109113 ln -s /data/etc/shadow /etc/shadow
110114 trap - EXIT
111115 else
112- apt_install prometheus-node-exporter prometheus-node-exporter-collectors
116+ apt_install_with_recommends prometheus-node-exporter
113117 fi
114118
115119 if [[ " $DOCKERBUILD " == 1 ]]
@@ -134,7 +138,7 @@ NCP_CONFIG_DIR=/usr/local/etc
134138set +a
135139
136140NAME=ncp-exporter
137- DAEMON=/usr/local/bin /ncp-metrics-exporter
141+ DAEMON=/usr/local/lib/ncp-metrics /ncp-metrics-exporter
138142PIDFILE=/var/run/ncp-metrics-exporter.pid
139143LOGFILE=/var/log/ncp-metrics.log
140144START_ARGS="--background --make-pidfile"
@@ -173,7 +177,7 @@ Description=NCP Metrics Exporter
173177
174178[Service]
175179Environment=NCP_CONFIG_DIR=/usr/local/etc
176- ExecStart=/usr/local/bin /ncp-metrics-exporter
180+ ExecStart=/usr/local/lib/ncp-metrics /ncp-metrics-exporter
177181SyslogIdentifier=ncp-metrics
178182Restart=on-failure
179183RestartSec=30
@@ -218,19 +222,22 @@ configure() {
218222 return 1
219223 }
220224
221- [[ -n " $PASSWORD " ]] || {
222- echo -e " ERROR: Password can not be empty!" >&2
223- return 1
224- }
225+ if [[ " $METRICS_SKIP_PASSWORD_CONFIG " != " true" ]]
226+ then
227+ [[ -n " $PASSWORD " ]] || {
228+ echo -e " ERROR: Password can not be empty!" >&2
229+ return 1
230+ }
225231
226- [[ ${# PASSWORD} -ge 10 ]] || {
227- echo -e " ERROR: Password must be at least 10 characters long!" >&2
228- return 1
229- }
232+ [[ ${# PASSWORD} -ge 10 ]] || {
233+ echo -e " ERROR: Password must be at least 10 characters long!" >&2
234+ return 1
235+ }
230236
231- local htpasswd_file=" /usr/local/etc/metrics.htpasswd"
232- rm -f " ${htpasswd_file} "
233- echo " $PASSWORD " | htpasswd -ciB " ${htpasswd_file} " " $USER "
237+ local htpasswd_file=" /usr/local/etc/metrics.htpasswd"
238+ rm -f " ${htpasswd_file} "
239+ echo " $PASSWORD " | htpasswd -ciB " ${htpasswd_file} " " $USER "
240+ fi
234241
235242 echo " Generate config..."
236243 reload_metrics_config
@@ -252,7 +259,7 @@ configure() {
252259 return 1
253260 }
254261
255- echo " Metrics endpoint enabled. You can test it at https://nextcloudpi.local/metrics/system (or under your NC domain under the same path )"
262+ 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 )"
256263 fi
257264
258265 bash -c " sleep 2 && service apache2 reload" & > /dev/null &
0 commit comments