move nut plugin to separate repo
This commit is contained in:
parent
db2b39db09
commit
68210a716a
|
@ -1,69 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Slackware startup script for Network UPS Tools
|
||||
# Copyright 2010 V'yacheslav Stetskevych
|
||||
# Edited for unRAID by macester macecapri@gmail.com
|
||||
|
||||
DPATH=/usr/bin
|
||||
FILE=/boot/config/plugins/nut/nut.cfg
|
||||
export PATH=$DPATH:$PATH
|
||||
|
||||
|
||||
|
||||
start_driver() {
|
||||
/usr/sbin/upsdrvctl -u root start || exit 1
|
||||
}
|
||||
|
||||
start_upsd() {
|
||||
/usr/sbin/upsd -u root || exit 1
|
||||
}
|
||||
|
||||
start_upsmon() {
|
||||
/usr/sbin/upsmon -u root || exit 1
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo "Stopping the UPS services... "
|
||||
if pgrep upsd 2>&1 >/dev/null; then
|
||||
/usr/sbin/upsd -c stop; fi
|
||||
if pgrep upsmon 2>&1 >/dev/null; then
|
||||
/usr/sbin/upsmon -c stop; fi
|
||||
/usr/sbin/upsdrvctl stop
|
||||
sleep 2
|
||||
if [ -f /var/run/upsmon.pid ]; then
|
||||
rm /var/run/upsmon.pid; fi
|
||||
}
|
||||
|
||||
write_config() {
|
||||
/usr/local/emhttp/plugins/nut/scripts/write_config.sh
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start) # starts everything (for a ups server box)
|
||||
sleep 1
|
||||
write_config
|
||||
sleep 3
|
||||
start_driver
|
||||
start_upsd
|
||||
start_upsmon
|
||||
;;
|
||||
start_upsmon) # starts upsmon only (for a ups client box)
|
||||
start_upsmon
|
||||
;;
|
||||
stop) # stops all UPS-related daemons
|
||||
stop
|
||||
;;
|
||||
shutdown) # shuts down the UPS
|
||||
echo "Killing inverter..."
|
||||
/usr/sbin/upsdrvctl shutdown
|
||||
;;
|
||||
reload)
|
||||
write_config
|
||||
/usr/sbin/upsd -c reload
|
||||
/usr/sbin/upsmon -c reload
|
||||
;;
|
||||
write_config)
|
||||
write_config
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|start_upsmon|stop|shutdown|reload|restart|write_config}"
|
||||
esac
|
|
@ -1,3 +0,0 @@
|
|||
[ups]
|
||||
driver=none
|
||||
port=auto
|
|
@ -1 +0,0 @@
|
|||
LISTEN 0.0.0.0
|
|
@ -1,11 +0,0 @@
|
|||
[admin]
|
||||
password=adminpass
|
||||
actions=set
|
||||
actions=fsd
|
||||
instcmds=all
|
||||
[monuser]
|
||||
password=monpass
|
||||
upsmon master
|
||||
[slaveuser]
|
||||
password=slavepass
|
||||
upsmon slave
|
|
@ -1,6 +0,0 @@
|
|||
MONITOR ups@localhost 1 monuser monpass master
|
||||
SHUTDOWNCMD "/usr/local/sbin/powerdown"
|
||||
POWERDOWNFLAG /etc/ups/flag/killpower
|
||||
NOTIFYFLAG ONBATT SYSLOG+EXEC
|
||||
NOTIFYFLAG ONLINE SYSLOG+EXEC
|
||||
NOTIFYCMD "/etc/ups/notifycmd"
|
|
@ -1 +0,0 @@
|
|||
|
|
@ -1,160 +0,0 @@
|
|||
Menu="OtherSettings"
|
||||
Type="xmenu"
|
||||
Title="NUT Settings"
|
||||
Icon="nut.png"
|
||||
---
|
||||
<?PHP
|
||||
/* Copyright 2015, Dan Landon.
|
||||
* Copyright 2015, Bergware International.
|
||||
* Copyright 2015, Lime Technology
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Modified by macester macecapri@gmail.com for NUT plugin
|
||||
*
|
||||
*/
|
||||
|
||||
$sName = "nut";
|
||||
$cfg = parse_plugin_cfg($sName);
|
||||
?>
|
||||
|
||||
<table class="tablesorter shift nut" <?if (!file_exists('/var/run/upsmon.pid')):?>style="display:none"<?endif;?>>
|
||||
<thead><tr><th>UPS Status</th><th>Battery Charge %</th><th>Runtime Left </th><th>Nominal Power</th><th>UPS Load</th><th>UPS Load %</th></tr></thead>
|
||||
<tbody id="nut_summary"><tr><td colspan="6"> </td></tr></tbody>
|
||||
</table>
|
||||
|
||||
<form markdown="1" name="nut_settings" method="POST" action="/update.php" target="progressFrame">
|
||||
<input type="hidden" name="#file" value="<?=$sName?>/<?=$sName?>.cfg">
|
||||
<input type="hidden" name="#include" value="/plugins/<?=$sName?>/include/update.nut.php">
|
||||
<span style="float:right;margin-right:10px"><a href="http://www.networkupstools.org/docs/user-manual.chunked/" target="_blank" title="NUT UPS user manual"><i class="fa fa-file-text-o"></i> <u>Online Manual</u></a></span>
|
||||
|
||||
Start NUT UPS service:
|
||||
: <select name="SERVICE" size="1">
|
||||
<?=mk_option($cfg['SERVICE'], "disable", "No");?>
|
||||
<?=mk_option($cfg['SERVICE'], "enable", "Yes");?>
|
||||
</select>
|
||||
|
||||
> Set to 'Yes' to enable NUT and start the service, set to 'No' to disable NUT and stop the service.
|
||||
> Setting 'Yes' will also enable NUT on unRAID boot.
|
||||
|
||||
UPS Driver:
|
||||
: <select id="DRIVER" name="DRIVER" size="1" >
|
||||
<?=mk_option($cfg['DRIVER'], "blazer_usb", "Blazer_usb");?>
|
||||
<?=mk_option($cfg['DRIVER'], "blazer_ser", "Blazer_ser");?>
|
||||
<?=mk_option($cfg['DRIVER'], "bcmxcp_usb", "Bcmxcp_usb");?>
|
||||
<?=mk_option($cfg['DRIVER'], "richcomm_usb", "Richcomm_usb");?>
|
||||
<?=mk_option($cfg['DRIVER'], "tripplite_usb", "Tripplite_usb");?>
|
||||
<?=mk_option($cfg['DRIVER'], "usbhid-ups", "Usbhid-ups");?>
|
||||
<?=mk_option($cfg['DRIVER'], "custom", "Custom");?>
|
||||
</select><input type="text" class="serial" name="SERIAL" class="narrow" maxlength="40" value="<?=$cfg['SERIAL'];?>">
|
||||
|
||||
> **Check the link below to find the driver matching your UPS**
|
||||
>
|
||||
> + <a href="http://www.networkupstools.org/stable-hcl.html" target="_blank">http://www.networkupstools.org/stable-hcl.html</a>
|
||||
>
|
||||
> For other devices set **Custom** and enter the driver manually below.
|
||||
> Dont forget to match the port with your driver
|
||||
> Use the *Link* above to find which Driver to choose.
|
||||
> Dont forget to match the port with your driver
|
||||
|
||||
|
||||
UPS Port:
|
||||
: <input type="text" name="PORT" class="narrow" maxlength="40" value="<?=$cfg['PORT'];?>">
|
||||
|
||||
> Enter the *port* which your UPS connects to.
|
||||
>
|
||||
> + **auto** - Set to "auto" if the ups is connected by usb.
|
||||
> + **/dev/tty0** - Example, for seriall devices**
|
||||
|
||||
|
||||
UPS Mode:
|
||||
: <select name="MODE" size="1">
|
||||
<?=mk_option($cfg['MODE'], "standalone", "Standalone");?>
|
||||
<?=mk_option($cfg['MODE'], "netserver", "Netserver");?>
|
||||
</select>
|
||||
|
||||
> Select the *mode* which mode your UPS will run in.
|
||||
>
|
||||
> + **standalone** - When the ups is only used by the local host**
|
||||
> + **netserver** - When nut clients/slaves need to connect to the ups**
|
||||
|
||||
|
||||
UPS Shutdown Mode:
|
||||
: <select name="SHUTDOWN" size="1">
|
||||
<?=mk_option($cfg['SHUTDOWN'], "batt_level", "Battery Level");?>
|
||||
<?=mk_option($cfg['SHUTDOWN'], "batt_timer", "Runtime Left");?>
|
||||
<?=mk_option($cfg['SHUTDOWN'], "sec_timer", "Time on Battery");?>
|
||||
</select>
|
||||
|
||||
> Select the *Shutdown mode* for NUT, this mode determines which "timer" to use for when the UPS will shutdown the system.
|
||||
>
|
||||
> + **Battery Level** - Shuts down the system when there is X percentage left on the battery **
|
||||
> + **Runtime Left** - Shuts down the system when there is X runtime left on the battery (in seconds)**
|
||||
> + **Time on Battery** - Shuts down the system when the user defined timer reaches zero (in seconds)**
|
||||
|
||||
|
||||
Battery level to initiate shutdown (%):
|
||||
: <input type="text" name="BATTERYLEVEL" class="narrow" maxlength="2" value="<?=$cfg['BATTERYLEVEL'];?>">
|
||||
|
||||
> If during a power failure, the remaining battery percentage (as reported by the UPS) is below or equal to *Battery level*, NUT will initiate a system shutdown.
|
||||
|
||||
|
||||
Runtime left to initiate shutdown (seconds):
|
||||
: <input type="text" name="SECONDS" class="narrow" maxlength="4" value="<?=$cfg['SECONDS'];?>">
|
||||
|
||||
> If during a power failure, the remaining runtime seconds (as calculated internally by the UPS) is below or equal to *seconds*, NUT will initiate a system shutdown.
|
||||
> **Note** depeding on your ups this value can "fluctuate" so be aware. if yot ups have an old battery dont use this
|
||||
|
||||
Time on battery before shutdown (seconds):
|
||||
: <input type="text" name="TIMEOUT" class="narrow" maxlength="4" value="<?=$cfg['TIMEOUT'];?>">
|
||||
|
||||
> The time in seconds before the system will power down if a power failure accours.
|
||||
|
||||
|
||||
Turn off UPS after shutdown:
|
||||
: <select name="UPSKILL" size="1">
|
||||
<?=mk_option($cfg['UPSKILL'], "disable", "No");?>
|
||||
<?=mk_option($cfg['UPSKILL'], "enable", "Yes");?>
|
||||
</select>
|
||||
|
||||
> Set to *Yes* to turn off the power to the UPS after a shutdown.
|
||||
>
|
||||
> Check your bios and enable, "Automatically power on after power loss" so that the server starts again when powers is restored.
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
> **Additional Notes**
|
||||
>
|
||||
> The usernames and passwords for *admin* and *slave* accounts in *upsd.users* file **
|
||||
>
|
||||
> + **Admin Account**: "admin / adminpass" - **Slave Account**: "slaveuser / slavepass"
|
||||
>
|
||||
> NUT is set to listen on all interface in upsd.conf "LISTEN 0.0.0.0"
|
||||
>
|
||||
> macester (macecapri@gmail.com)
|
||||
|
||||
<input type="submit" name="#default" value="Default">
|
||||
: <input type="submit" name="#apply" value="Apply"><input type="button" value="Done" onclick="done()">
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
showStatus('upsmon');
|
||||
|
||||
$('#DRIVER').change(checkSerial);
|
||||
checkSerial();
|
||||
});
|
||||
|
||||
function checkSerial(){
|
||||
if ($('#DRIVER')[0].selectedIndex == 6)
|
||||
$('.serial').css('visibility','visible')
|
||||
else
|
||||
$('.serial').css('visibility','hidden')
|
||||
}
|
||||
</script>
|
|
@ -1,3 +0,0 @@
|
|||
####Network UPS Tools (NUT)####
|
||||
|
||||
A Plugin that supports a wide variety of UPS brands and models.
|
Binary file not shown.
Before Width: | Height: | Size: 952 B |
Binary file not shown.
Before Width: | Height: | Size: 421 B |
|
@ -1,32 +0,0 @@
|
|||
<?PHP
|
||||
/* Copyright 2015, Dan Landon.
|
||||
* Copyright 2015, Bergware International.
|
||||
* Copyright 2015, Lime Technology
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* Edited by macester for NUT Plugin.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$cfg = "/boot/config/plugins/nut/nut.cfg";
|
||||
$connection = $_POST['DRIVER']=='custom' ? $_POST['SERIAL'] : $_POST['DRIVER'];
|
||||
|
||||
exec("/etc/rc.d/rc.nut stop");
|
||||
exec("sed -i -e '/^SERVICE/c\\SERVICE=\"'{$_POST['SERVICE']}'\"' $cfg");
|
||||
exec("sed -i -e '/^PORT/c\\PORT=\"'{$_POST['PORT']}'\"' $cfg");
|
||||
exec("sed -i -e '/^MODE/c\\MODE=\"'{$_POST['MODE']}'\"' $cfg");
|
||||
exec("sed -i -e '/^SHUTDOWN/c\\SHUTDOWN=\"'{$_POST['SHUTDOWN']}'\"' $cfg");
|
||||
exec("sed -i -e '/^BATTERYLEVEL/c\\BATTERYLEVEL=\"'{$_POST['BATTERYLEVEL']}'\"' $cfg");
|
||||
exec("sed -i -e '/^SECONDS/c\\SECONDS=\"'{$_POST['SECONDS']}'\"' $cfg");
|
||||
exec("sed -i -e '/^TIMEOUT/c\\TIMEOUT=\"'{$_POST['TIMEOUT']}'\"' $cfg");
|
||||
exec("sed -i -e '/^UPSKILL/c\\UPSKILL=\"'{$_POST['UPSKILL']}'\"' $cfg");
|
||||
exec("sed -i -e '/^DRIVER/c\\DRIVER=\"'{$connection}'\"' $cfg");
|
||||
|
||||
if ($_POST['SERVICE']=='enable') exec("/usr/local/emhttp/plugins/nut/scripts/rc.nut start");
|
||||
?>
|
|
@ -1,69 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Slackware startup script for Network UPS Tools
|
||||
# Copyright 2010 V'yacheslav Stetskevych
|
||||
# Edited for unRAID by macester macecapri@gmail.com
|
||||
|
||||
DPATH=/usr/bin
|
||||
FILE=/boot/config/plugins/nut/nut.cfg
|
||||
export PATH=$DPATH:$PATH
|
||||
|
||||
|
||||
|
||||
start_driver() {
|
||||
/usr/sbin/upsdrvctl -u root start || exit 1
|
||||
}
|
||||
|
||||
start_upsd() {
|
||||
/usr/sbin/upsd -u root || exit 1
|
||||
}
|
||||
|
||||
start_upsmon() {
|
||||
/usr/sbin/upsmon -u root || exit 1
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo "Stopping the UPS services... "
|
||||
if pgrep upsd 2>&1 >/dev/null; then
|
||||
/usr/sbin/upsd -c stop; fi
|
||||
if pgrep upsmon 2>&1 >/dev/null; then
|
||||
/usr/sbin/upsmon -c stop; fi
|
||||
/usr/sbin/upsdrvctl stop
|
||||
sleep 2
|
||||
if [ -f /var/run/upsmon.pid ]; then
|
||||
rm /var/run/upsmon.pid; fi
|
||||
}
|
||||
|
||||
write_config() {
|
||||
/usr/local/emhttp/plugins/nut/scripts/write_config.sh
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start) # starts everything (for a ups server box)
|
||||
sleep 1
|
||||
write_config
|
||||
sleep 3
|
||||
start_driver
|
||||
start_upsd
|
||||
start_upsmon
|
||||
;;
|
||||
start_upsmon) # starts upsmon only (for a ups client box)
|
||||
start_upsmon
|
||||
;;
|
||||
stop) # stops all UPS-related daemons
|
||||
stop
|
||||
;;
|
||||
shutdown) # shuts down the UPS
|
||||
echo "Killing inverter..."
|
||||
/usr/sbin/upsdrvctl shutdown
|
||||
;;
|
||||
reload)
|
||||
write_config
|
||||
/usr/sbin/upsd -c reload
|
||||
/usr/sbin/upsmon -c reload
|
||||
;;
|
||||
write_config)
|
||||
write_config
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|start_upsmon|stop|shutdown|reload|restart|write_config}"
|
||||
esac
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
if [ -f /usr/local/emhttp/plugins/nut/scripts/nut_restart_udev ]; then
|
||||
. /usr/local/emhttp/plugins/nut/scripts/nut_restart_udev
|
||||
fi
|
|
@ -1,99 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# NUT plugin configuration script for unRAID
|
||||
# By macester macecapri@gmail.com
|
||||
#
|
||||
NUTCFG=/boot/config/plugins/nut/nut.cfg
|
||||
|
||||
|
||||
# Killpower flag permissions
|
||||
chmod 777 /etc/ups/flag
|
||||
|
||||
# Add nut user and group for udev at shutdown
|
||||
GROUP=$( grep -ic "218" /etc/group )
|
||||
USER=$( grep -ic "218" /etc/passwd )
|
||||
|
||||
if [ $GROUP -ge 1 ]; then
|
||||
echo "NUT Group already configured"
|
||||
else
|
||||
groupadd -g 218 nut
|
||||
fi
|
||||
|
||||
if [ $USER -ge 1 ]; then
|
||||
echo "NUT User already configured"
|
||||
else
|
||||
useradd -u 218 -g nut -s /bin/false nut
|
||||
fi
|
||||
|
||||
# Nut config files
|
||||
|
||||
# Add the driver config
|
||||
driver_custom=$( grep -ic 'DRIVER="custom"' $NUTCFG )
|
||||
if [ $driver_custom -eq 1 ]; then
|
||||
var1=$( grep -i "SERIAL=" $NUTCFG|cut -d \" -f2|sed 's/^/driver = /' )
|
||||
sed -i "2 s/.*/$var1/" /etc/ups/ups.conf
|
||||
else
|
||||
var2=$( grep -i "DRIVER=" $NUTCFG|cut -d \" -f2|sed 's/^/driver = /' )
|
||||
sed -i "2 s/.*/$var2/" /etc/ups/ups.conf
|
||||
fi
|
||||
|
||||
# add the port
|
||||
var3=$( grep -i "PORT=" $NUTCFG|cut -d \" -f2|sed 's/^/port = /' )
|
||||
sed -i "3 s~.*~$var3~" /etc/ups/ups.conf
|
||||
|
||||
# add mode standalone/netserver
|
||||
var4=$( grep -i "MODE=" $NUTCFG|cut -d \" -f2|sed 's/^/MODE=/' )
|
||||
sed -i "1 s/.*/$var4/" /etc/ups/nut.conf
|
||||
|
||||
# Set which shutdown script NUT should use
|
||||
mode_bat_level=$( grep -ic 'SHUTDOWN="batt_level"' $NUTCFG )
|
||||
mode_bat_timer=$( grep -ic 'SHUTDOWN="batt_timer"' $NUTCFG )
|
||||
|
||||
if [ $mode_bat_level -eq 1 ]; then
|
||||
sed -i "6 s,.*,NOTIFYCMD \"/usr/local/emhttp/plugins/nut/scripts/notifycmd_batterylevel\"," /etc/ups/upsmon.conf
|
||||
else
|
||||
if [ $mode_bat_timer -eq 1 ]; then
|
||||
sed -i "6 s,.*,NOTIFYCMD \"/usr/local/emhttp/plugins/nut/scripts/notifycmd_seconds\"," /etc/ups/upsmon.conf
|
||||
else
|
||||
sed -i "6 s,.*,NOTIFYCMD \"/usr/local/emhttp/plugins/nut/scripts/notifycmd_timeout\"," /etc/ups/upsmon.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
# Edit timers fo shutdown scripts
|
||||
|
||||
# shutdown when battery gets to level
|
||||
var5=$( grep -i "BATTERYLEVEL=" $NUTCFG|cut -d \" -f2|sed 's/^/BATTERYLEVEL=/' )
|
||||
sed -i "6 s/.*/$var5/" /usr/local/emhttp/plugins/nut/scripts/notifycmd_batterylevel
|
||||
|
||||
# shutdown when battery time runs out
|
||||
var6=$( grep -i "SECONDS=" $NUTCFG|cut -d \" -f2|sed 's/^/SECONDS=/' )
|
||||
sed -i "6 s/.*/$var6/" /usr/local/emhttp/plugins/nut/scripts/notifycmd_seconds
|
||||
|
||||
# shutdown on user timer
|
||||
var7=$( grep -i "TIMEOUT=" $NUTCFG|cut -d \" -f2|sed 's/^/TIMEOUT=/' )
|
||||
sed -i "6 s/.*/$var7/" /usr/local/emhttp/plugins/nut/scripts/notifycmd_timeout
|
||||
|
||||
# Set if the ups should be turned off
|
||||
ups_kill=$( grep -ic 'UPSKILL="enable"' $NUTCFG )
|
||||
if [ $ups_kill -eq 1 ]; then
|
||||
var8='POWERDOWNFLAG /etc/ups/flag/killpower'
|
||||
sed -i "3 s,.*,$var8," /etc/ups/upsmon.conf
|
||||
else
|
||||
var9='POWERDOWNFLAG /etc/ups/flag/no_killpower'
|
||||
sed -i "3 s,.*,$var9," /etc/ups/upsmon.conf
|
||||
fi
|
||||
|
||||
# Link shutdown scripts for poweroff in rc.0 and rc.6
|
||||
UDEV=$( grep -ic "/usr/local/emhttp/plugins/nut/scripts/nut_restart_udev" /etc/rc.d/rc.6 )
|
||||
if [ $UDEV -ge 1 ]; then
|
||||
echo "UDEV lines already exist in rc.0,6"
|
||||
else
|
||||
sed -i '/\/bin\/mount -v -n -o remount,ro \//r /usr/local/emhttp/plugins/nut/scripts/txt/udev.txt' /etc/rc.d/rc.6
|
||||
fi
|
||||
|
||||
KILL=$( grep -ic "/usr/local/emhttp/plugins/nut/scripts/nut_kill_inverter" /etc/rc.d/rc.6 )
|
||||
if [ $KILL -ge 1 ]; then
|
||||
echo "KILL_INVERTER lines already exist in rc.0,6"
|
||||
else
|
||||
sed -i -e '/# Now halt (poweroff with APM or ACPI enabled kernels) or reboot./r /usr/local/emhttp/plugins/nut/scripts/txt/kill.txt' -e //N /etc/rc.d/rc.6
|
||||
fi
|
Loading…
Reference in New Issue
Block a user