mirror of
https://github.com/nextcloud/nextcloudpi.git
synced 2026-01-09 14:42:01 -03:30
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:
parent
d9313da25c
commit
afbf651412
@ -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)
|
||||
|
||||
[](https://github.com/nextcloud/nextcloudpi/actions/workflows/vm-tests.yml)
|
||||
[](https://github.com/nextcloud/nextcloudpi/actions/workflows/vm-tests.yml)
|
||||
|
||||
## Features
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user