* Tue Mar 18 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-9.sme
- update config for Nut 2.8.2 [SME: 12657] TODO review master/slave mode TODO convert master/slave to primary/secondary TODO convert to new config data + migrate TODO event and action
This commit is contained in:
52
root/etc/e-smith/events/actions/nut-config
Normal file
52
root/etc/e-smith/events/actions/nut-config
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
# this script is called before template-expand
|
||||
# then another script is called to run /usr/libexec/nut-driver-enumerator.sh and start/stop drivers
|
||||
# then traditionnal services2adjust
|
||||
|
||||
# calling this script to configure unit and drivers
|
||||
if [[ $(/sbin/e-smith/config getprop nut status || echo "disabled") == "disabled" ]] ; then
|
||||
# disable server
|
||||
/sbin/e-smith/config setprop nut-server status disabled
|
||||
/sbin/e-smith/config setprop nut access localhost
|
||||
# disable monitor
|
||||
/sbin/e-smith/config setprop nut-monitor status disabled
|
||||
# TODO get_all_by_prop filter nut-driver@ and foreach $UPS disabled
|
||||
#config keys|grep nut-driver
|
||||
for OUTPUT in $(/sbin/e-smith/config keys|grep nut-driver)
|
||||
do
|
||||
/sbin/e-smith/config setprop $OUTPUT status disabled
|
||||
done
|
||||
|
||||
exit 0;
|
||||
fi
|
||||
# nut is enabled
|
||||
|
||||
# we set services depending on Mode
|
||||
Mode=$(/sbin/e-smith/config getprop nut Mode || echo "standelone")
|
||||
if [[ $Mode == "netserver" ]] ; then
|
||||
/sbin/e-smith/config setprop nut-server status enabled
|
||||
/sbin/e-smith/config setprop nut access private
|
||||
elif [[ $Mode == "netclient" ]] ; then
|
||||
/sbin/e-smith/config setprop nut-server status disabled
|
||||
/sbin/e-smith/config setprop nut access localhost
|
||||
else
|
||||
/sbin/e-smith/config setprop nut-server status enabled
|
||||
/sbin/e-smith/config setprop nut access localhost
|
||||
fi
|
||||
# enable nut-monitor
|
||||
/sbin/e-smith/config setprop nut-monitor status enabled
|
||||
|
||||
# get_all_by_prop filter nut-driver@ and foreach $UPS enable.
|
||||
if [[ $Mode == "netclient" ]] ; then
|
||||
for OUTPUT in $(/sbin/e-smith/config keys|grep nut-driver)
|
||||
do
|
||||
/sbin/e-smith/config setprop $OUTPUT status disabled
|
||||
done
|
||||
else
|
||||
for OUTPUT in $(/sbin/e-smith/config keys|grep nut-driver)
|
||||
do
|
||||
/sbin/e-smith/config setprop $OUTPUT status enabled
|
||||
done
|
||||
fi
|
||||
|
Reference in New Issue
Block a user