initial commit of file from CVS for e-smith-nutUPS on Wed 12 Jul 09:01:20 BST 2023

This commit is contained in:
Brian Read
2023-07-12 09:01:20 +01:00
parent d9332aba34
commit 667523a800
63 changed files with 1241 additions and 2 deletions

View File

@@ -0,0 +1 @@
disabled

View File

@@ -0,0 +1 @@
usbhid-ups

View File

@@ -0,0 +1 @@
localhost

View File

@@ -0,0 +1 @@
disabled

View File

@@ -0,0 +1 @@
service

View File

@@ -0,0 +1,6 @@
{
my $nutmod = $DB->get_prop('nut', 'Model');
return unless $nutmod;
$DB->set_prop('nut', 'Model', 'usbhid-ups') if ($nutmod eq 'newhidups');
}

View File

@@ -0,0 +1,8 @@
{
use MIME::Base64 qw(encode_base64);
my $nutrec = $DB->get('nut') || $DB->new_record('nut', {type => 'service'});
$nutrec->set_prop('MasterPass', sprintf("%15.0f", int( (1000000000000000) * rand() ))) if not $nutrec->prop('MasterPass');
$nutrec->set_prop('SlavePass', sprintf("%15.0f", int( (1000000000000000) * rand() ))) if not $nutrec->prop('SlavePass');
$nutrec->set_prop('AdminPass', sprintf("%15.0f", int( (1000000000000000) * rand() ))) if not $nutrec->prop('AdminPass');
}

View File

@@ -0,0 +1 @@
PERMS=0644

View File

@@ -0,0 +1,3 @@
UID="root"
GID="nut"
PERMS=0640

View File

@@ -0,0 +1,3 @@
UID="root"
GID="nut"
PERMS=0640

View File

@@ -0,0 +1,3 @@
UID="root"
GID="nut"
PERMS=0640

View File

@@ -0,0 +1,3 @@
UID="root"
GID="nut"
PERMS=0640

View File

@@ -0,0 +1,3 @@
UID="root"
GID="nut"
PERMS=0640

View File

@@ -0,0 +1,3 @@
{
$DB->hosts_allow_spec('nut','nut');
}

View File

@@ -0,0 +1,11 @@
{
return "# The upsd admin is not allowed" if ($nut{AdminUser} ne 'enabled');
return "# The upsd admin has no password" if (($nut{AdminPass} || '') eq '');
return "# The upsd admin is not allowed when nut access is set to public" if $nut{access} eq 'public';
my $upsd = $DB->hosts_allow_spec('nut','upsd');
$upsd =~ s|upsd:|upsd: admin op |;
$OUT .= qq(#Allow the Admin User of upsd
$upsd : ALLOW) if ($nut{status} eq 'enabled');
}

View File

@@ -0,0 +1,3 @@
#Nut Service
nut 3493/tcp # Network UPS Tools
nut 3493/udp # Network UPS Tools

View File

@@ -0,0 +1 @@
MODEL=upsdrvctl

View File

@@ -0,0 +1 @@
SERVER={ $nut{Master} || 'yes' }

View File

@@ -0,0 +1,16 @@
# nut UPS specific subservices
{
$nutstatus = $nut{status} || 'disabled';
$master = $nut{Master} || 'yes';
if ($nutstatus eq 'enabled') {
$OUT .= "enable nut-server.service\n" if ($master eq 'yes');
$OUT .= "disable nut-server.service\n" unless ($master eq 'yes');
$OUT .= "enable nut-monitor.service\n";
}
else
{
$OUT .= "disable nut-server.service\n";
$OUT .= "disable nut-monitor.service\n";
}
}

View File

@@ -0,0 +1,16 @@
{
my $model = $nut{Model} || "usbhid-ups";
my $device = $nut{Device} || "/var/lib/ups/hiddev0";
my $type = $nut{Type};
my $mfr = $nut{mfr};
my $mdl = $nut{mdl};
$OUT .= "[UPS]\n";
$OUT .= "\tdriver = $model\n";
if ($model eq 'genericups')
{
$OUT .= "\tupstype = $type\n" if defined $type;
$OUT .= "\tmfr = $mfr\n" if defined $mfr;
$OUT .= "\tmodel = $mdl\n" if defined $mdl;
}
$OUT .= "\tport = $device\n";
}

View File

@@ -0,0 +1,6 @@
{
my $access = $nut{access} || 'localhost';
$OUT .= "LISTEN 127.0.0.1";
$OUT .= "\nLISTEN $LocalIP" if ($access eq 'private');
}

View File

@@ -0,0 +1,8 @@
[upsmaster]
password = { $nut{MasterPass} }
upsmon master
[upsslave]
password = { $nut{SlavePass} }
upsmon slave

View File

@@ -0,0 +1,14 @@
{
# create admin user for upsd to allow setting of
# UPS parameters via upsrw
$OUT .= "";
return unless (($nut{AdminUser} || 'disabled') eq 'enabled');
return unless (($nut{AdminPass} || '') ne '');
$OUT .= "\n";
$OUT .= " [admin]\n";
$OUT .= " password = $nut{AdminPass}\n";
$OUT .= " actions = set\n";
$OUT .= " instcmds = all\n";
}

View File

@@ -0,0 +1 @@
DEADTIME 15

View File

@@ -0,0 +1 @@
FINALDELAY 5

View File

@@ -0,0 +1 @@
HOSTSYNC 15

View File

@@ -0,0 +1 @@
MINSUPPLIES 1

View File

@@ -0,0 +1,7 @@
{
if ( ($nut{Master} || 'yes') ne 'no' ) {
$OUT = "MONITOR UPS\@localhost 1 upsmaster $nut{MasterPass} master";
} else {
$OUT = "MONITOR $nut{SlaveUPS} 1 upsslave $nut{SlavePass} slave";
}
}

View File

@@ -0,0 +1 @@
NOCOMMWARNTIME 300

View File

@@ -0,0 +1 @@
NOTIFYCMD /sbin/e-smith/nutUPS.notify

View File

@@ -0,0 +1,9 @@
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC
NOTIFYFLAG FSD SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC

View File

@@ -0,0 +1 @@
POLLFREQ 5

View File

@@ -0,0 +1 @@
POLLFREQALERT 5

View File

@@ -0,0 +1 @@
POWERDOWNFLAG /etc/killpower

View File

@@ -0,0 +1 @@
RBWARNTIME 43200

View File

@@ -0,0 +1 @@
SHUTDOWNCMD "/sbin/e-smith/signal-event halt"

View File

@@ -0,0 +1 @@
# For more information see "man upssched.conf"

View File

@@ -0,0 +1,3 @@
[Unit]
PartOf=nut.service
After=nut.service network-online.target

View File

@@ -0,0 +1,4 @@
[Service]
ExecStartPre=
ExecStartPre=-/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-run.conf
ExecStartPre=/sbin/e-smith/service-status nut

View File

@@ -0,0 +1,2 @@
[Install]
WantedBy=sme-server.target

View File

@@ -0,0 +1,4 @@
[Unit]
PartOf=nut.service
After=nut.service network-online.target

View File

@@ -0,0 +1,2 @@
[Service]
ExecStartPre=/sbin/e-smith/service-status nut

View File

@@ -0,0 +1,2 @@
[Install]
WantedBy=sme-server.target

0
root/etc/rc.d/init.d/.gitignore vendored Normal file
View File

0
root/etc/rc.d/rc7.d/.gitignore vendored Normal file
View File

View File

@@ -0,0 +1,6 @@
#! /bin/sh
# UPS notify script.
/bin/mail -s "$UPSNAME: $NOTIFYTYPE" admin <<END
$*
END

View File

@@ -0,0 +1,14 @@
#------------------------------------------------------------
# !!DO NOT MODIFY THIS FILE!!
#
# Manual changes will be lost when this file is regenerated.
#
# Please read the developer's guide, which is available
# at http://www.contribs.org/development/
#
# Copyright (C) 1999-2006 Mitel Networks Corporation
#------------------------------------------------------------
[Service]
ExecStartPre=
ExecStartPre=-/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-run.conf

View File

@@ -0,0 +1,23 @@
[Unit]
Description=Network UPS Tools - Parent service for Koozali SME Server
After=local-fs.target network.target network-online.target
Before=nut-server.service
[Service]
ExecStartPre=/sbin/e-smith/service-status nut
ExecStartPre=-/sbin/e-smith/expand-template /etc/sysconfig/ups
ExecStartPre=-/sbin/e-smith/expand-template /etc/ups/ups.conf
ExecStartPre=-/sbin/e-smith/expand-template /etc/ups/upsd.conf
ExecStartPre=-/sbin/e-smith/expand-template /etc/ups/upsd.users
ExecStartPre=-/sbin/e-smith/expand-template /etc/ups/upsmon.conf
ExecStartPre=-/sbin/e-smith/expand-template /etc/ups/upssched.conf
# The dummy program will exit
Type=oneshot
# Execute a dummy program
ExecStart=/bin/true
# This service shall be considered active after start
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target sme-server.target