From 7d8c59250e495e6dbde26c72ea76303c70e324c7 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 7 Aug 2019 21:49:16 +0200 Subject: [PATCH] #707 improve autostart of apcupsd --- home.admin/00infoBlitz.sh | 2 +- home.admin/config.scripts/blitz.ups.sh | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/home.admin/00infoBlitz.sh b/home.admin/00infoBlitz.sh index ce2355e65..48c3b7d70 100755 --- a/home.admin/00infoBlitz.sh +++ b/home.admin/00infoBlitz.sh @@ -327,5 +327,5 @@ if [ ${#undervoltageReports} -gt 0 ] && [ "${undervoltageReports}" != "0" ]; the elif [ ${#powerFAIL} -gt 0 ] && [ ${powerFAIL} -gt 0 ]; then echo "Weak power supply detected - run 'Hardware Test' in menu" elif [ ${#ups} -gt 1 ] && [ "${upsStatus}" = "n/a" ]; then - echo "Power-Emergency Shutdown may happend - reinstall UPS service" + echo "UPS service activated but not running" fi \ No newline at end of file diff --git a/home.admin/config.scripts/blitz.ups.sh b/home.admin/config.scripts/blitz.ups.sh index c05740a2d..c0f38f31c 100644 --- a/home.admin/config.scripts/blitz.ups.sh +++ b/home.admin/config.scripts/blitz.ups.sh @@ -36,6 +36,12 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then # edit config: /etc/apcupsd/apcupsd.conf sudo systemctl stop apcupsd + sudo systemctl disable apcupsd + + # make service autostart + sudo sed -i '3iAfter=background.service' /lib/systemd/system/apcupsd.service + sudo sed -i '3iWants=background.service' /lib/systemd/system/apcupsd.service + sudo sed -i "s/^UPSCABLE.*/UPSCABLE usb/g" /etc/apcupsd/apcupsd.conf sudo sed -i "s/^UPSTYPE.*/UPSTYPE usb/g" /etc/apcupsd/apcupsd.conf sudo sed -i "s/^DEVICE.*/DEVICE/g" /etc/apcupsd/apcupsd.conf @@ -46,6 +52,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then sudo sed -i "s/^ISCONFIGURED=.*/ISCONFIGURED=yes/g" /etc/default/apcupsd sudo sed -i "s/^SHUTDOWN=.*/SHUTDOWN=\/home\/admin\/XXshutdown.sh/g" /etc/apcupsd/apccontrol sudo sed -i "s/^WALL=.*/#WALL=wall/g" /etc/apcupsd/apccontrol + sudo systemctl enable apcupsd sudo systemctl start apcupsd # add default 'ups' raspiblitz.conf if needed