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>
This commit is contained in:
Tobias K 2022-04-19 01:31:24 +02:00
parent d9313da25c
commit afbf651412
No known key found for this signature in database
GPG Key ID: 44FD368932E645C1
3 changed files with 22 additions and 11 deletions

View File

@ -13,7 +13,7 @@ This code also generates the NextCloudPi [docker image](https://hub.docker.com/r
Find the full documentation at [docs.nextcloudpi.com](http://docs.nextcloudpi.com) Find the full documentation at [docs.nextcloudpi.com](http://docs.nextcloudpi.com)
[![VM Integration Tests](https://github.com/nextcloud/nextcloudpi/actions/workflows/vm-tests.yml/badge.svg)](https://github.com/nextcloud/nextcloudpi/actions/workflows/vm-tests.yml) [![VM Integration Tests](https://github.com/nextcloud/nextcloudpi/workflows/VM%20Integration%20Tests/badge.svg)](https://github.com/nextcloud/nextcloudpi/actions/workflows/vm-tests.yml)
## Features ## Features

View File

@ -15,7 +15,7 @@ install()
apt-get install --no-install-recommends -y dnsmasq apt-get install --no-install-recommends -y dnsmasq
rc=0 rc=0
service dnsmasq status > /dev/null 2>&1 || rc=$? 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)" echo "Applying workaround for dnsmasq bug (compare issue #1446)"
service systemd-resolved stop service systemd-resolved stop
service dnsmasq start service dnsmasq start

View File

@ -62,10 +62,14 @@ metrics_services() {
exit 1 exit 1
fi fi
if [[ "$DOCKERBUILD" == 1 ]] if is_docker
then then
update-rc.d ncp-metrics "$cmd" rc1=0
return $? 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 else
systemctl "$cmd" prometheus-node-exporter ncp-metrics-exporter systemctl "$cmd" prometheus-node-exporter ncp-metrics-exporter
return $? return $?
@ -92,7 +96,7 @@ EOF
[[ "${arch}" =~ ^"arm" ]] && arch="armv7" [[ "${arch}" =~ ^"arm" ]] && arch="armv7"
mkdir -p /usr/local/lib/ncp-metrics 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}" "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 chmod +x /usr/local/lib/ncp-metrics/ncp-metrics-exporter
@ -105,12 +109,18 @@ EOF
then then
# during installation of prometheus-node-exporter `useradd` is used to create a user. # 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 # 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 restore_shadow=true
rm /etc/shadow [[ -L /etc/shadow ]] || restore_shadow=false
cp /data/etc/shadow /etc/shadow [[ "$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 apt_install_with_recommends prometheus-node-exporter
mv /etc/shadow /data/etc/shadow [[ "$restore_shadow" == "false" ]] || {
ln -s /data/etc/shadow /etc/shadow mv /etc/shadow /data/etc/shadow
ln -s /data/etc/shadow /etc/shadow
}
trap - EXIT trap - EXIT
else else
apt_install_with_recommends prometheus-node-exporter apt_install_with_recommends prometheus-node-exporter
@ -144,6 +154,7 @@ LOGFILE=/var/log/ncp-metrics.log
START_ARGS="--background --make-pidfile" START_ARGS="--background --make-pidfile"
EOF EOF
chmod +x /etc/init.d/ncp-metrics-exporter chmod +x /etc/init.d/ncp-metrics-exporter
update-rc.d ncp-metrics-exporter defaults
cat > /etc/services-available.d/101ncp-metrics <<EOF cat > /etc/services-available.d/101ncp-metrics <<EOF
#!/bin/bash #!/bin/bash