Last active
April 6, 2024 10:45
Revisions
-
2b revised this gist
Oct 22, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -148,7 +148,7 @@ upsmon -DDD #additional - Growl notifications #install GrowlNotify - http://growl.info/extras.php#growlnotify #then configure Growl to listen for incoming notifications and set pass #test with command growlnotify -s -n "TEST" -m "test" -P "PA$$W0RD" cd /usr/local/Cellar/nut/2.7.3/etc/ -
2b revised this gist
Oct 22, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -138,7 +138,7 @@ upsmon -DDD #to each LaunchAgent/LaunchDaemon plist #and change debug level from -D to -DDD at least - <string>-DDD</string> #fyi - "upsdrvctl start" doesnt work properly with blazer_usb - getting Error: Data stale -
2b revised this gist
Oct 22, 2015 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -148,10 +148,9 @@ upsmon -DDD #additional - Growl notifications #install GrowlNotify - http://growl.info/extras.php#growlnotify #then configure it to listen for incoming notifications and set pass #test with command growlnotify -s -n "TEST" -m "test" -P "PA$$W0RD" cd /usr/local/Cellar/nut/2.7.3/etc/ mv upssched.conf.sample upssched.conf -
2b revised this gist
Oct 22, 2015 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -95,7 +95,7 @@ vi ~/Library/LaunchAgents/org.networkupstools.upsd.plist </plist> :wq #upsmon splits into two processes, one with PPID 1, cuz it need root permissions to shutdown OS #so create LaunchDaemon instead of LaunchAgent sudo vi /Library/LaunchDaemons/org.networkupstools.upsmon.plist <?xml version="1.0" encoding="UTF-8"?> @@ -121,7 +121,7 @@ launchctl load ~/Library/LaunchAgents/org.networkupstools.blazer_usb.plist launchctl load ~/Library/LaunchAgents/org.networkupstools.upsd.plist sudo launchctl load /Library/LaunchDaemons/org.networkupstools.upsmon.plist #it's done #check status and watch some info upsc upsname @@ -132,9 +132,9 @@ upsmon -DDD #or add <key>StandardOutPath</key> <string>/Users/Username/Desktop/upsmon.log</string> <key>StandardErrorPath</key> <string>/Users/Username/Desktop/upsmon.log</string> #to each LaunchAgent/LaunchDaemon plist #and change debug level from -D to -DDD at least - <string>-DDD</string> -
2b revised this gist
Oct 22, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -207,8 +207,8 @@ vi uspmon.conf :wq vi /usr/local/Cellar/nut/2.7.3/bin/shutdown.applescript #!/usr/bin/osascript tell application "loginwindow" to «event aevtrsdn» :wq vi /usr/local/Cellar/nut/2.7.3/bin/upssched-cmd -
2b revised this gist
Oct 22, 2015 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -176,7 +176,9 @@ vi upssched.conf :wq vi uspmon.conf #unfortunately, we can't use SHUTDOWNCMD "/usr/bin/osascript -e 'tell app \"loginwindow\" to «event aevtrsdn»'" #because of angle brakets (upsmon filtering them), so we'll create shutdown.applescript #but if you don't need additional time for cancel shutdown - use second SHUTDOWNCMD SHUTDOWNCMD "sudo -u Username /usr/local/Cellar/nut/2.7.3/bin/shutdown.applescript" #SHUTDOWNCMD "/usr/bin/osascript -e 'tell app \"System Events\" to shut down'" NOTIFYCMD "/usr/local/sbin/upssched" -
2b revised this gist
Oct 22, 2015 . No changes.There are no files selected for viewing
-
2b revised this gist
Oct 22, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ case $1 in ;; SHUTDOWN) MSG="Auto logout and shutdown proceeding" upscmd -u Username -p Password upsname@localhost shutdown.return ;; REPLBATT) MSG="UPS battery needs to be replaced" -
2b revised this gist
Oct 22, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -148,7 +148,7 @@ upsmon -DDD #additional - Growl notifications #install GrowlNotify - http://growl.info/extras.php#growlnotify #then configure it to listen for incomming notification and set pass #test with command growlnotify -s -n "TEST" -m "test" -P "PA$$W0RD" -
2b revised this gist
Oct 22, 2015 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -146,7 +146,7 @@ upsmon -DDD #additional - Growl notifications #install GrowlNotify - http://growl.info/extras.php#growlnotify #then confugure it to listen for incomming notification and set pass #test with command growlnotify -s -n "TEST" -m "test" -P "PA$$W0RD" @@ -161,11 +161,11 @@ vi upssched.conf PIPEFN /var/state/ups/upssched/upssched.pipe LOCKFN /var/state/ups/upssched/upssched.lock AT ONLINE * EXECUTE ONLINE AT ONLINE * CANCEL-TIMER SHUTDOWN AT ONBATT * EXECUTE ONBATT AT ONBATT * START-TIMER SHUTDOWN 120 AT LOWBATT * EXECUTE LOWBATT AT LOWBATT * START-TIMER FSD 5 AT FSD * EXECUTE FSD AT COMMOK * EXECUTE COMMOK AT COMMBAD * EXECUTE COMMBAD -
2b revised this gist
Oct 22, 2015 . 1 changed file with 40 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ case $1 in ONLINE) MSG="UPS on line power" upscmd -u Username -p Password upsname@localhost shutdown.stop ;; ONBATT) MSG="UPS on battery" ;; LOWBATT) MSG="UPS battery is low" ;; FSD) MSG="UPS forced shutdown in progress" /usr/local/sbin/upsmon -c fsd ;; COMMOK) MSG="Communications with UPS established" ;; COMMBAD) MSG="Communications with UPS lost" ;; SHUTDOWN) MSG="Auto logout and shutdown proceeding" upscmd -u User -p pass upsname@localhost shutdown.return ;; REPLBATT) MSG="UPS battery needs to be replaced" ;; NOCOMM) MSG="UPS is unavailable" ;; NOPARENT) MSG="upsmon parent process died - shutdown impossible" ;; *) MSG="Unrecognized command: $1" ;; esac /usr/local/bin/growlnotify -s -n "UPSNAME" -m "$MSG" -P "PA$$W0RD" -
2b revised this gist
Oct 22, 2015 . 1 changed file with 13 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ cd /usr/local/Cellar/nut/2.7.3/etc/ mv nut.conf.sample nut.conf vi nut.conf MODE=standalone :wq mv ups.conf.sample ups.conf vi ups.conf @@ -29,12 +29,12 @@ vi ups.conf default.battery.voltage.high = 15.00 default.battery.voltage.nominal = 14.00 default.battery.voltage.low = 13.00 :wq mv upsd.conf.sample upsd.conf vi upsd.conf LISTEN 127.0.0.1 3493 :wq mv upsd.users.sample upsd.users vi upsd.users @@ -43,12 +43,12 @@ vi upsd.users actions = SET instcmds = ALL upsmon master :wq mv upsmon.conf.sample upsmon.conf vi uspmon.conf MONITOR upsname@localhost 1 Username Password master :wq #for autostart and control purposes #change to your own driver - check http://www.networkupstools.org/stable-hcl.html @@ -73,7 +73,7 @@ vi ~/Library/LaunchAgents/org.networkupstools.blazer_usb.plist <true/> </dict> </plist> :wq vi ~/Library/LaunchAgents/org.networkupstools.upsd.plist <?xml version="1.0" encoding="UTF-8"?> @@ -93,7 +93,7 @@ vi ~/Library/LaunchAgents/org.networkupstools.upsd.plist <true/> </dict> </plist> :wq #upsmon splits into two processes, one with PPID 1, cuz it need root permissions to shutdown os #so create LaunchDaemon instead of LaunchAgent @@ -115,7 +115,7 @@ sudo vi /Library/LaunchDaemons/org.networkupstools.upsmon.plist <true/> </dict> </plist> :wq launchctl load ~/Library/LaunchAgents/org.networkupstools.blazer_usb.plist launchctl load ~/Library/LaunchAgents/org.networkupstools.upsd.plist @@ -138,7 +138,7 @@ upsmon -DDD #to each LaunchAgent/LaunchDaemon plist #and change debug level from -D to -DDD at least - <string>-DDD</string> #fyi - upsdrvctl start doesnt work with blazer_usb - getting Error: Data stale @@ -173,7 +173,7 @@ vi upssched.conf AT REPLBATT * EXECUTE REPLBATT AT NOCOMM * EXECUTE NOCOMM AT NOPARENT * EXECUTE NOPARENT :wq vi uspmon.conf #unfortunately, we can't use SHUTDOWNCMD "/usr/bin/osascript -e 'tell app \"loginwindow\" to «event aevtrsdn»'" because of angle brakets (upsmon filtering them), so we'll create shutdown.applescript, but if you don't need additional time for cancel shutdown - use second SHUTDOWNCMD @@ -202,12 +202,12 @@ vi uspmon.conf NOTIFYFLAG REPLBATT SYSLOG+EXEC NOTIFYFLAG NOCOMM SYSLOG+EXEC NOTIFYFLAG NOPARENT SYSLOG+EXEC :wq vi /usr/local/Cellar/nut/2.7.3/bin/shutdown.applescript #!/usr/bin/osascript tell application "loginwindow" to «event aevtrsdn» :wq vi /usr/local/Cellar/nut/2.7.3/bin/upssched-cmd case $1 in @@ -251,4 +251,4 @@ vi /usr/local/Cellar/nut/2.7.3/bin/upssched-cmd #change to your growl pass /usr/local/bin/growlnotify -s -n "UPSNAME" -m "$MSG" -P "PA$$W0RD" :wq -
2b created this gist
Oct 22, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,254 @@ #install homebrew ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" #install network ups tools brew install nut #create directories and change permissions sudo mkdir -p /var/state/ups/upssched/ sudo chown -R `whoami`:nobody /var/state/ups sudo chmod 775 /var/state/ups/ sudo chmod 664 /var/state/ups/* sudo chmod 775 /var/state/ups/upssched/ sudo chmod 640 /usr/local/Cellar/nut/2.7.3/etc/* sudo chmod o+r /usr/local/Cellar/nut/2.7.3/etc/upssched.conf cd /usr/local/Cellar/nut/2.7.3/etc/ mv nut.conf.sample nut.conf vi nut.conf MODE=standalone :wq mv ups.conf.sample ups.conf vi ups.conf [upsname] #in my case - its blazer_usb driver. Check here http://www.networkupstools.org/stable-hcl.html driver=blazer_usb port=auto desc = "SVEN UPS 650VA" #set your own battery.voltage values. Check with command "upsc upsname" default.battery.voltage.high = 15.00 default.battery.voltage.nominal = 14.00 default.battery.voltage.low = 13.00 :wq mv upsd.conf.sample upsd.conf vi upsd.conf LISTEN 127.0.0.1 3493 :wq mv upsd.users.sample upsd.users vi upsd.users [Username] password = Password actions = SET instcmds = ALL upsmon master :wq mv upsmon.conf.sample upsmon.conf vi uspmon.conf MONITOR upsname@localhost 1 Username Password master :wq #for autostart and control purposes #change to your own driver - check http://www.networkupstools.org/stable-hcl.html vi ~/Library/LaunchAgents/org.networkupstools.blazer_usb.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>KeepAlive</key> <true/> <key>Label</key> <string>org.networkupstools.blazer_usb</string> <key>ProgramArguments</key> <array> <string>/usr/local/Cellar/nut/2.7.3/bin/blazer_usb</string> <string>-a</string> <string>upsname</string> <string>-D</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist> :wq vi ~/Library/LaunchAgents/org.networkupstools.upsd.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>KeepAlive</key> <true/> <key>Label</key> <string>org.networkupstools.upsd</string> <key>ProgramArguments</key> <array> <string>/usr/local/sbin/upsd</string> <string>-D</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist> :wq #upsmon splits into two processes, one with PPID 1, cuz it need root permissions to shutdown os #so create LaunchDaemon instead of LaunchAgent sudo vi /Library/LaunchDaemons/org.networkupstools.upsmon.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>KeepAlive</key> <true/> <key>Label</key> <string>org.networkupstools.upsmon</string> <key>ProgramArguments</key> <array> <string>/usr/local/sbin/upsmon</string> <string>-D</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist> :wq launchctl load ~/Library/LaunchAgents/org.networkupstools.blazer_usb.plist launchctl load ~/Library/LaunchAgents/org.networkupstools.upsd.plist sudo launchctl load /Library/LaunchDaemons/org.networkupstools.upsmon.plist #its done #check status and watch some info upsc upsname #to debug /usr/local/Cellar/nut/2.7.3/bin/blazer_usb -a upsname -DDD upsd -DDD upsmon -DDD #or add <key>StandardOutPath</key> <string>/Users/User/Desktop/upsmon.log</string> <key>StandardErrorPath</key> <string>/Users/User/Desktop/upsmon.log</string> #to each LaunchAgent/LaunchDaemon plist #and change debug level from -D to -DDD at least - <string>-DDD</string> #fyi - upsdrvctl start doesnt work with blazer_usb - Error: Data stale --------- #additional - Growl notification #install GrowlNotify - http://growl.info/extras.php#growlnotify #then confugure it to listen for incomming notification and set pass #test with command growlnotify -s -n "TEST" -m "test" -P "PA$$W0RD" cd /usr/local/Cellar/nut/2.7.3/etc/ mv upssched.conf.sample upssched.conf #configuring for shutdown after 2min vi upssched.conf CMDSCRIPT /usr/local/Cellar/nut/2.7.3/bin/upssched-cmd PIPEFN /var/state/ups/upssched/upssched.pipe LOCKFN /var/state/ups/upssched/upssched.lock AT ONLINE * EXECUTE ONLINE AT ONLINE * CANCEL-TIMER FSD AT ONBATT * EXECUTE ONBATT AT ONBATT * START-TIMER FSD 120 AT LOWBATT * EXECUTE LOWBATT AT LOWBATT * START-TIMER FSD 10 AT FSD * EXECUTE FSD AT COMMOK * EXECUTE COMMOK AT COMMBAD * EXECUTE COMMBAD AT SHUTDOWN * EXECUTE SHUTDOWN AT REPLBATT * EXECUTE REPLBATT AT NOCOMM * EXECUTE NOCOMM AT NOPARENT * EXECUTE NOPARENT :wq vi uspmon.conf #unfortunately, we can't use SHUTDOWNCMD "/usr/bin/osascript -e 'tell app \"loginwindow\" to «event aevtrsdn»'" because of angle brakets (upsmon filtering them), so we'll create shutdown.applescript, but if you don't need additional time for cancel shutdown - use second SHUTDOWNCMD SHUTDOWNCMD "sudo -u Username /usr/local/Cellar/nut/2.7.3/bin/shutdown.applescript" #SHUTDOWNCMD "/usr/bin/osascript -e 'tell app \"System Events\" to shut down'" NOTIFYCMD "/usr/local/sbin/upssched" NOTIFYMSG ONLINE "UPS %s on line power" NOTIFYMSG ONBATT "UPS %s on battery" NOTIFYMSG LOWBATT "UPS %s battery is low" NOTIFYMSG FSD "UPS %s: forced shutdown in progress" NOTIFYMSG COMMOK "Communications with UPS %s established" NOTIFYMSG COMMBAD "Communications with UPS %s lost" NOTIFYMSG SHUTDOWN "Auto logout and shutdown proceeding" NOTIFYMSG REPLBATT "UPS %s battery needs to be replaced" NOTIFYMSG NOCOMM "UPS %s is unavailable" NOTIFYMSG NOPARENT "upsmon parent process died - shutdown impossible" NOTIFYFLAG ONLINE SYSLOG+EXEC NOTIFYFLAG ONBATT SYSLOG+EXEC NOTIFYFLAG LOWBATT SYSLOG+EXEC NOTIFYFLAG FSD SYSLOG+EXEC NOTIFYFLAG COMMOK SYSLOG+EXEC NOTIFYFLAG COMMBAD SYSLOG+EXEC NOTIFYFLAG SHUTDOWN SYSLOG+EXEC NOTIFYFLAG REPLBATT SYSLOG+EXEC NOTIFYFLAG NOCOMM SYSLOG+EXEC NOTIFYFLAG NOPARENT SYSLOG+EXEC :wq vi /usr/local/Cellar/nut/2.7.3/bin/shutdown.applescript #!/usr/bin/osascript tell application "loginwindow" to «event aevtrsdn» :wq vi /usr/local/Cellar/nut/2.7.3/bin/upssched-cmd case $1 in ONLINE) MSG="UPS on line power" upscmd -u Username -p Password upsname@localhost shutdown.stop ;; ONBATT) MSG="UPS on battery" ;; LOWBATT) MSG="UPS battery is low" ;; FSD) MSG="UPS forced shutdown in progress" /usr/local/sbin/upsmon -c fsd ;; COMMOK) MSG="Communications with UPS established" ;; COMMBAD) MSG="Communications with UPS lost" ;; SHUTDOWN) MSG="Auto logout and shutdown proceeding" upscmd -u User -p pass upsname@localhost shutdown.return ;; REPLBATT) MSG="UPS battery needs to be replaced" ;; NOCOMM) MSG="UPS is unavailable" ;; NOPARENT) MSG="upsmon parent process died - shutdown impossible" ;; *) MSG="Unrecognized command: $1" ;; esac #change to your growl pass /usr/local/bin/growlnotify -s -n "UPSNAME" -m "$MSG" -P "PA$$W0RD" :wq