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-19 02:31:24 +0300
committerTobias K <6317548+theCalcaholic@users.noreply.github.com>2022-04-19 02:31:24 +0300
commitafbf651412147f92958ce8d3f128f0fda027e698 (patch)
tree7bdc7bb2c227aeaca4e6b91f603ffae5916f31c1 /bin/ncp
parentd9313da25c118324ccd9ba422012fb8ed624714c (diff)
dnsmasq, metrics: Fix docker build issues
dnsmasq.sh: Skip systemd-resolved workaround on docker metrics.sh: Fix service installation on docker Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com>
Diffstat (limited to 'bin/ncp')
-rw-r--r--bin/ncp/NETWORKING/dnsmasq.sh2
-rw-r--r--bin/ncp/SYSTEM/metrics.sh29
2 files changed, 21 insertions, 10 deletions
diff --git a/bin/ncp/NETWORKING/dnsmasq.sh b/bin/ncp/NETWORKING/dnsmasq.sh
index 368403e9..79826976 100644
--- a/bin/ncp/NETWORKING/dnsmasq.sh
+++ b/bin/ncp/NETWORKING/dnsmasq.sh
@@ -15,7 +15,7 @@ install()
apt-get install --no-install-recommends -y dnsmasq
rc=0
service dnsmasq status > /dev/null 2>&1 || rc=$?
- [[ $rc -eq 3 ]] && {
+ ! is_docker && [[ $rc -eq 3 ]] && {
echo "Applying workaround for dnsmasq bug (compare issue #1446)"
service systemd-resolved stop
service dnsmasq start
diff --git a/bin/ncp/SYSTEM/metrics.sh b/bin/ncp/SYSTEM/metrics.sh
index 50e46afd..b55fd721 100644
--- a/bin/ncp/SYSTEM/metrics.sh
+++ b/bin/ncp/SYSTEM/metrics.sh
@@ -62,10 +62,14 @@ metrics_services() {
exit 1
fi
- if [[ "$DOCKERBUILD" == 1 ]]
+ if is_docker
then
- update-rc.d ncp-metrics "$cmd"
- return $?
+ rc1=0
+ rc2=0
+ update-rc.d ncp-metrics-exporter "$cmd" || rc1=$?
+ update-rc.d prometheus-node-exporter "$cmd" || rc2=$?
+ [[ $rc1 > $rc2 ]] && return $rc1
+ return $rc2
else
systemctl "$cmd" prometheus-node-exporter ncp-metrics-exporter
return $?
@@ -92,7 +96,7 @@ EOF
[[ "${arch}" =~ ^"arm" ]] && arch="armv7"
mkdir -p /usr/local/lib/ncp-metrics
- wget -O "/usr/local/lib/ncp-metrics/ncp-metrics-exporter" \
+ wget -qO "/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
@@ -105,12 +109,18 @@ EOF
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
+ restore_shadow=true
+ [[ -L /etc/shadow ]] || restore_shadow=false
+ [[ "$restore_shadow" == "false" ]] || {
+ 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
+ [[ "$restore_shadow" == "false" ]] || {
+ mv /etc/shadow /data/etc/shadow
+ ln -s /data/etc/shadow /etc/shadow
+ }
trap - EXIT
else
apt_install_with_recommends prometheus-node-exporter
@@ -144,6 +154,7 @@ LOGFILE=/var/log/ncp-metrics.log
START_ARGS="--background --make-pidfile"
EOF
chmod +x /etc/init.d/ncp-metrics-exporter
+ update-rc.d ncp-metrics-exporter defaults
cat > /etc/services-available.d/101ncp-metrics <<EOF
#!/bin/bash