| 
									
										
										
										
											2025-05-17 00:44:43 -04:00
										 |  |  | #!/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 | 
					
						
							| 
									
										
										
										
											2025-06-02 22:37:42 -04:00
										 |  |  | Mode=$(/sbin/e-smith/config getprop nut Mode || echo "standalone") | 
					
						
							| 
									
										
										
										
											2025-05-17 00:44:43 -04:00
										 |  |  | 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 | 
					
						
							|  |  |  | 
 |