- 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
53 lines
1.7 KiB
Bash
53 lines
1.7 KiB
Bash
#!/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
|
|
|