initial commit of file from CVS for e-smith-nutUPS on Wed 12 Jul 09:01:20 BST 2023
This commit is contained in:
1
root/etc/e-smith/db/configuration/defaults/nut/AdminUser
Normal file
1
root/etc/e-smith/db/configuration/defaults/nut/AdminUser
Normal file
@@ -0,0 +1 @@
|
||||
disabled
|
1
root/etc/e-smith/db/configuration/defaults/nut/Model
Normal file
1
root/etc/e-smith/db/configuration/defaults/nut/Model
Normal file
@@ -0,0 +1 @@
|
||||
usbhid-ups
|
1
root/etc/e-smith/db/configuration/defaults/nut/access
Normal file
1
root/etc/e-smith/db/configuration/defaults/nut/access
Normal file
@@ -0,0 +1 @@
|
||||
localhost
|
1
root/etc/e-smith/db/configuration/defaults/nut/status
Normal file
1
root/etc/e-smith/db/configuration/defaults/nut/status
Normal file
@@ -0,0 +1 @@
|
||||
disabled
|
1
root/etc/e-smith/db/configuration/defaults/nut/type
Normal file
1
root/etc/e-smith/db/configuration/defaults/nut/type
Normal file
@@ -0,0 +1 @@
|
||||
service
|
6
root/etc/e-smith/db/configuration/migrate/nutModel
Normal file
6
root/etc/e-smith/db/configuration/migrate/nutModel
Normal 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');
|
||||
}
|
||||
|
8
root/etc/e-smith/db/configuration/migrate/nutPass
Normal file
8
root/etc/e-smith/db/configuration/migrate/nutPass
Normal 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');
|
||||
}
|
1
root/etc/e-smith/templates.metadata/etc/sysconfig/ups
Normal file
1
root/etc/e-smith/templates.metadata/etc/sysconfig/ups
Normal file
@@ -0,0 +1 @@
|
||||
PERMS=0644
|
3
root/etc/e-smith/templates.metadata/etc/ups/ups.conf
Normal file
3
root/etc/e-smith/templates.metadata/etc/ups/ups.conf
Normal file
@@ -0,0 +1,3 @@
|
||||
UID="root"
|
||||
GID="nut"
|
||||
PERMS=0640
|
3
root/etc/e-smith/templates.metadata/etc/ups/upsd.conf
Normal file
3
root/etc/e-smith/templates.metadata/etc/ups/upsd.conf
Normal file
@@ -0,0 +1,3 @@
|
||||
UID="root"
|
||||
GID="nut"
|
||||
PERMS=0640
|
3
root/etc/e-smith/templates.metadata/etc/ups/upsd.users
Normal file
3
root/etc/e-smith/templates.metadata/etc/ups/upsd.users
Normal file
@@ -0,0 +1,3 @@
|
||||
UID="root"
|
||||
GID="nut"
|
||||
PERMS=0640
|
3
root/etc/e-smith/templates.metadata/etc/ups/upsmon.conf
Normal file
3
root/etc/e-smith/templates.metadata/etc/ups/upsmon.conf
Normal file
@@ -0,0 +1,3 @@
|
||||
UID="root"
|
||||
GID="nut"
|
||||
PERMS=0640
|
@@ -0,0 +1,3 @@
|
||||
UID="root"
|
||||
GID="nut"
|
||||
PERMS=0640
|
3
root/etc/e-smith/templates/etc/hosts.allow/upsd
Normal file
3
root/etc/e-smith/templates/etc/hosts.allow/upsd
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
$DB->hosts_allow_spec('nut','nut');
|
||||
}
|
@@ -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');
|
||||
}
|
3
root/etc/e-smith/templates/etc/services/30Nut
Normal file
3
root/etc/e-smith/templates/etc/services/30Nut
Normal file
@@ -0,0 +1,3 @@
|
||||
#Nut Service
|
||||
nut 3493/tcp # Network UPS Tools
|
||||
nut 3493/udp # Network UPS Tools
|
1
root/etc/e-smith/templates/etc/sysconfig/ups/MODEL
Normal file
1
root/etc/e-smith/templates/etc/sysconfig/ups/MODEL
Normal file
@@ -0,0 +1 @@
|
||||
MODEL=upsdrvctl
|
1
root/etc/e-smith/templates/etc/sysconfig/ups/SERVER
Normal file
1
root/etc/e-smith/templates/etc/sysconfig/ups/SERVER
Normal file
@@ -0,0 +1 @@
|
||||
SERVER={ $nut{Master} || 'yes' }
|
@@ -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";
|
||||
}
|
||||
}
|
16
root/etc/e-smith/templates/etc/ups/ups.conf/UPS
Normal file
16
root/etc/e-smith/templates/etc/ups/ups.conf/UPS
Normal 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";
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
my $access = $nut{access} || 'localhost';
|
||||
|
||||
$OUT .= "LISTEN 127.0.0.1";
|
||||
$OUT .= "\nLISTEN $LocalIP" if ($access eq 'private');
|
||||
}
|
8
root/etc/e-smith/templates/etc/ups/upsd.users/monitor
Normal file
8
root/etc/e-smith/templates/etc/ups/upsd.users/monitor
Normal file
@@ -0,0 +1,8 @@
|
||||
[upsmaster]
|
||||
password = { $nut{MasterPass} }
|
||||
upsmon master
|
||||
|
||||
[upsslave]
|
||||
password = { $nut{SlavePass} }
|
||||
upsmon slave
|
||||
|
@@ -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";
|
||||
}
|
1
root/etc/e-smith/templates/etc/ups/upsmon.conf/DEADTIME
Normal file
1
root/etc/e-smith/templates/etc/ups/upsmon.conf/DEADTIME
Normal file
@@ -0,0 +1 @@
|
||||
DEADTIME 15
|
@@ -0,0 +1 @@
|
||||
FINALDELAY 5
|
1
root/etc/e-smith/templates/etc/ups/upsmon.conf/HOSTSYNC
Normal file
1
root/etc/e-smith/templates/etc/ups/upsmon.conf/HOSTSYNC
Normal file
@@ -0,0 +1 @@
|
||||
HOSTSYNC 15
|
@@ -0,0 +1 @@
|
||||
MINSUPPLIES 1
|
7
root/etc/e-smith/templates/etc/ups/upsmon.conf/MONITOR
Normal file
7
root/etc/e-smith/templates/etc/ups/upsmon.conf/MONITOR
Normal 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";
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
NOCOMMWARNTIME 300
|
1
root/etc/e-smith/templates/etc/ups/upsmon.conf/NOTIFYCMD
Normal file
1
root/etc/e-smith/templates/etc/ups/upsmon.conf/NOTIFYCMD
Normal file
@@ -0,0 +1 @@
|
||||
NOTIFYCMD /sbin/e-smith/nutUPS.notify
|
@@ -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
|
1
root/etc/e-smith/templates/etc/ups/upsmon.conf/POLLFREQ
Normal file
1
root/etc/e-smith/templates/etc/ups/upsmon.conf/POLLFREQ
Normal file
@@ -0,0 +1 @@
|
||||
POLLFREQ 5
|
@@ -0,0 +1 @@
|
||||
POLLFREQALERT 5
|
@@ -0,0 +1 @@
|
||||
POWERDOWNFLAG /etc/killpower
|
@@ -0,0 +1 @@
|
||||
RBWARNTIME 43200
|
@@ -0,0 +1 @@
|
||||
SHUTDOWNCMD "/sbin/e-smith/signal-event halt"
|
@@ -0,0 +1 @@
|
||||
# For more information see "man upssched.conf"
|
@@ -0,0 +1,3 @@
|
||||
[Unit]
|
||||
PartOf=nut.service
|
||||
After=nut.service network-online.target
|
@@ -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
|
@@ -0,0 +1,2 @@
|
||||
[Install]
|
||||
WantedBy=sme-server.target
|
@@ -0,0 +1,4 @@
|
||||
[Unit]
|
||||
PartOf=nut.service
|
||||
After=nut.service network-online.target
|
||||
|
@@ -0,0 +1,2 @@
|
||||
[Service]
|
||||
ExecStartPre=/sbin/e-smith/service-status nut
|
@@ -0,0 +1,2 @@
|
||||
[Install]
|
||||
WantedBy=sme-server.target
|
0
root/etc/rc.d/init.d/.gitignore
vendored
Normal file
0
root/etc/rc.d/init.d/.gitignore
vendored
Normal file
0
root/etc/rc.d/rc7.d/.gitignore
vendored
Normal file
0
root/etc/rc.d/rc7.d/.gitignore
vendored
Normal file
6
root/sbin/e-smith/nutUPS.notify
Normal file
6
root/sbin/e-smith/nutUPS.notify
Normal file
@@ -0,0 +1,6 @@
|
||||
#! /bin/sh
|
||||
# UPS notify script.
|
||||
|
||||
/bin/mail -s "$UPSNAME: $NOTIFYTYPE" admin <<END
|
||||
$*
|
||||
END
|
@@ -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
|
0
root/usr/lib/systemd/system/nut-monitor.service.d/.gitignore
vendored
Normal file
0
root/usr/lib/systemd/system/nut-monitor.service.d/.gitignore
vendored
Normal file
0
root/usr/lib/systemd/system/nut-server.service.d/.gitignore
vendored
Normal file
0
root/usr/lib/systemd/system/nut-server.service.d/.gitignore
vendored
Normal file
23
root/usr/lib/systemd/system/nut.service
Normal file
23
root/usr/lib/systemd/system/nut.service
Normal 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
|
Reference in New Issue
Block a user