| 
									
										
										
										
											2025-05-14 23:06:09 -04:00
										 |  |  | #!/bin/bash | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-17 00:44:43 -04:00
										 |  |  | # another script is called before template-expand to set services | 
					
						
							|  |  |  | # this script is called to run /usr/libexec/nut-driver-enumerator.sh and start/stop drivers | 
					
						
							|  |  |  | # then traditionnal services2adjust | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # enumerate / configure drivers | 
					
						
							| 
									
										
										
										
											2025-05-17 01:11:29 -04:00
										 |  |  | /usr/libexec/nut-driver-enumerator.sh 2>/dev/null | 
					
						
							| 
									
										
										
										
											2025-05-17 00:44:43 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | event=$1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [[ $i == "post-upgrade" ]] ; then  | 
					
						
							|  |  |  | 	exit 0 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [[ $i == "bootstrap-console-save" ]] ; then | 
					
						
							|  |  |  |         exit 0 | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2025-05-14 23:06:09 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-17 01:11:29 -04:00
										 |  |  | # if disabled stop them | 
					
						
							| 
									
										
										
										
											2025-05-15 23:36:41 -04:00
										 |  |  | if [[ $(/sbin/e-smith/config getprop nut status || echo "disabled") == "disabled" ]] ; then | 
					
						
							| 
									
										
										
										
											2025-05-17 00:44:43 -04:00
										 |  |  | 	# if disabled stop them  | 
					
						
							|  |  |  | 	for OUTPUT in $(/sbin/e-smith/config keys|grep nut-driver) | 
					
						
							|  |  |  | 	 do | 
					
						
							|  |  |  | 	    /usr/bin/systemctl stop $OUTPUT | 
					
						
							|  |  |  | 	done | 
					
						
							|  |  |  |       	exit 0 | 
					
						
							| 
									
										
										
										
											2025-05-14 23:06:09 -04:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-17 01:11:29 -04:00
										 |  |  | # if netclient stop them | 
					
						
							|  |  |  | if [[ $(/sbin/e-smith/config getprop nut Mode || echo "netclient") == "netclient" ]] ; then | 
					
						
							|  |  |  |   # if disabled stop them  | 
					
						
							|  |  |  |   for OUTPUT in $(/sbin/e-smith/config keys|grep nut-driver) | 
					
						
							|  |  |  |    do | 
					
						
							|  |  |  |       /usr/bin/systemctl stop $OUTPUT 2>/dev/null | 
					
						
							|  |  |  |   done | 
					
						
							|  |  |  |         exit 0 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-17 00:44:43 -04:00
										 |  |  | # if we are there we want to restart / start them | 
					
						
							|  |  |  | for OUTPUT in $(/sbin/e-smith/config keys|grep nut-driver) | 
					
						
							|  |  |  |  do | 
					
						
							|  |  |  |     /usr/bin/systemctl restart $OUTPUT | 
					
						
							|  |  |  | done |