diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e594810 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.rpm +*.log +*spec-20* +*.tar.xz diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2fd5ac5 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +# Makefile for source rpm: e-smith-nutUPS +# $Id: Makefile,v 1.1 2016/02/05 22:19:01 stephdl Exp $ +NAME := e-smith-nutUPS +SPECFILE = $(firstword $(wildcard *.spec)) + +define find-makefile-common +for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done +endef + +MAKEFILE_COMMON := $(shell $(find-makefile-common)) + +ifeq ($(MAKEFILE_COMMON),) +# attept a checkout +define checkout-makefile-common +test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 +endef + +MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) +endif + +include $(MAKEFILE_COMMON) diff --git a/README.md b/README.md index fa6ec42..3767f89 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,17 @@ -# e-smith-nutUPS +# e-smith-nutUPS -SMEServer Koozali developed git repo for e-smith-nutUPS smeserver \ No newline at end of file +SMEServer Koozali developed git repo for e-smith-nutUPS smeserver + +## Wiki +
https://wiki.koozali.org/ + +## Bugzilla +Show list of outstanding bugs: [here](https://bugs.koozali.org/buglist.cgi?component=e-smith-nutUPS&product=SME%20Server%2010.X&query_format=advanced&limit=0&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=CONFIRMED) + +## Description + +
*This description has been generated by an LLM AI system and cannot be relied on to be fully correct.* +*Once it has been checked, then this comment will be deleted* +
+ +e-smith-nutUPS is an open-source software designed to monitor and control an Uninterruptible Power Supply (UPS) device connected to a computer. It offers features such as automatic shutdown of the computer when the UPS battery reaches a critical low-power level, and the capability to remotely monitor and control the UPS from a web browser or from a command line interface. It supports a wide range of UPS devices, and is compatible with most operating systems. With e-smith-nutUPS, users can be assured of reliable and consistent power protection even during power outages. diff --git a/additional/config/hosts.conf b/additional/config/hosts.conf new file mode 100644 index 0000000..9a4b669 --- /dev/null +++ b/additional/config/hosts.conf @@ -0,0 +1,29 @@ +# Network UPS Tools: example hosts.conf +# +# This file is used to control the CGI programs. If you have not +# installed them, you may safely ignore or delete this file. +# +# ----------------------------------------------------------------------- +# +# upsstats will use the list of MONITOR entries when displaying the +# default template (upsstats.html). The "FOREACHUPS" directive in the +# template will use this file to find systems running upsd. +# +# upsstats and upsimage also use this file to determine if a host may be +# monitored. This keeps evil people from using your system to annoy +# others with unintended queries. +# +# upsset presents a list of systems that may be viewed and controlled +# using this file. +# +# ----------------------------------------------------------------------- +# +# Usage: list systems running upsd that you want to monitor +# +# MONITOR "" +# +# Examples: +# +# MONITOR myups@localhost "Local UPS" +# MONITOR su2200@10.64.1.1 "Finance department" +# MONITOR matrix@shs-server.example.edu "Sierra High School data room #1" diff --git a/additional/config/ups.conf b/additional/config/ups.conf new file mode 100644 index 0000000..d7e39a1 --- /dev/null +++ b/additional/config/ups.conf @@ -0,0 +1,93 @@ +# Network UPS Tools: example ups.conf +# +# This is where you configure all the UPSes that this system will be +# monitoring directly. These are usually attached to serial ports, but +# USB devices and SNMP devices are also supported. +# +# This file is used by upsdrvctl to start and stop your driver(s), and +# is also used by upsd to determine which drivers to monitor. The +# drivers themselves also read this file for configuration directives. +# +# The general form is: +# +# [upsname] +# driver = +# port = +# < any other directives here > +# +# The section header ([upsname]) can be just about anything as long as +# it is a single word inside brackets. upsd uses this to uniquely +# identify a UPS on this system. +# +# If you have a UPS called snoopy, your section header would be "[snoopy]". +# On a system called "doghouse", the line in your upsmon.conf to monitor +# it would look something like this: +# +# MONITOR snoopy@doghouse 1 upsmonuser mypassword master +# +# It might look like this if monitoring in slave mode: +# +# MONITOR snoopy@doghouse 1 upsmonuser mypassword slave +# +# Configuration directives +# ------------------------ +# +# These directives are common to all drivers that support ups.conf: +# +# driver: REQUIRED. Specify the program to run to talk to this UPS. +# apcsmart, fentonups, bestups, and sec are some examples. +# +# port: REQUIRED. The serial port where your UPS is connected. +# /dev/ttyS0 is usually the first port on Linux boxes, for example. +# +# sdorder: optional. When you have multiple UPSes on your system, you +# usually need to turn them off in a certain order. upsdrvctl +# shuts down all the 0s, then the 1s, 2s, and so on. To exclude +# a UPS from the shutdown sequence, set this to -1. +# +# The default value for this parameter is 0. +# +# nolock: optional, and not recommended for use in this file. +# +# If you put nolock in here, the driver will not lock the +# serial port every time it starts. This may allow other +# processes to seize the port if you start more than one by +# mistake. +# +# This is only intended to be used on systems where locking +# absolutely must be disabled for the software to work. +# +# maxstartdelay: optional. This can be set as a global variable +# above your first UPS definition and it can also be +# set in a UPS section. This value controls how long +# upsdrvctl will wait for the driver to finish starting. +# This keeps your system from getting stuck due to a +# broken driver or UPS. +# +# The default is 45 seconds. +# +# +# Anything else is passed through to the hardware-specific part of +# the driver. +# +# Examples +# -------- +# +# A simple example for a UPS called "powerpal" that uses the fentonups +# driver on /dev/ttyS0 is: +# +# [powerpal] +# driver = fentonups +# port = /dev/ttyS0 +# +# If your UPS driver requires additional settings, you can specify them +# here. For example, if it supports a setting of "1234" for the +# variable "cable", it would look like this: +# +# [myups] +# driver = mydriver +# port = /dev/ttyS1 +# cable = 1234 +# +# To find out if your driver supports any extra settings, start it with +# with the -h option and/or read the driver's documentation. diff --git a/additional/config/upsd.conf b/additional/config/upsd.conf new file mode 100644 index 0000000..e095cbf --- /dev/null +++ b/additional/config/upsd.conf @@ -0,0 +1,43 @@ +# Network UPS Tools: example upsd configuration file +# +# This file contains passwords, so you should keep it secure. +# +# At the very least it should be owned by root, with mode 0600. +# +# If you want upsd to be able to reload the configuration files, this +# file must be readable by whatever user upsd becomes. See the FAQ. + +# ======================================================================= +# Access Control Lists (ACLs) +# +# ACL +# ACL myhost 10.0.0.1/32 +# +# ACCESS [] +# ACCESS grant login myhost mypass +# +# Use these to define blocks of addresses. See the upsd.conf(5) man page +# for more information. +# +# This default configuration allows localhost to monitor things and denies +# access to the rest of the world. To allow more, see the docs and +# change these lines. + +ACL all 0.0.0.0/0 +ACL localhost 127.0.0.1/32 + +ACCESS grant monitor localhost +ACCESS deny all all + +# ======================================================================= +# MAXAGE +# MAXAGE 15 +# +# This defaults to 15 seconds. After a UPS driver has stopped updating +# the data for this many seconds, upsd marks it stale and stops making +# that information available to clients. After all, the only thing worse +# than no data is bad data. +# +# You should only use this if your driver has difficulties keeping +# the data fresh within the normal 15 second interval. Watch the syslog +# for notifications from upsd about staleness. diff --git a/additional/config/upsd.users b/additional/config/upsd.users new file mode 100644 index 0000000..53c4e68 --- /dev/null +++ b/additional/config/upsd.users @@ -0,0 +1,74 @@ +# Network UPS Tools: Example upsd.users +# +# This file sets the permissions for upsd - the UPS network daemon. +# Users are defined here, are given passwords, and their privileges are +# controlled here too. Since this file will contain passwords, keep it +# secure, with only enough permissions for upsd to read it. +# +# At the very least it should be owned by root, with mode 0600. +# +# If you want upsd to be able to reload the configuration files, this +# file must be readable by whatever user upsd becomes. See the FAQ. + +# -------------------------------------------------------------------------- + +# Each user gets a section. To start a section, put the username in +# brackets on a line by itself. To set something for that user, specify +# it under that section heading. The username is case-sensitive, so +# admin and AdMiN are two different users. +# +# Possible settings: +# +# password: The user's password. This is case-sensitive. +# +# -------------------------------------------------------------------------- +# +# allowfrom: ACL names that this user may connect from. ACLs are +# defined in upsd.conf. +# +# -------------------------------------------------------------------------- +# +# actions: Let the user do certain things with upsd. +# +# Valid actions are: +# +# SET - change the value of certain variables in the UPS +# FSD - set the "forced shutdown" flag in the UPS +# +# -------------------------------------------------------------------------- +# +# instcmds: Let the user initiate specific instant commands. Use "ALL" +# to grant all commands automatically. Here are a few instant +# commands. For the full list, see include/shared-tables.h. +# +# FPTEST - Front panel test +# BTEST0 - Stop battery test +# BTEST1 - Start battery test +# CAL0 - Stop calibration +# CAL1 - Start calibration +# +# -------------------------------------------------------------------------- +# +# Example: +# +# [admin] +# password = mypass +# allowfrom = admworkstation admhome +# actions = SET +# instcmds = ALL +# + +# +# --- Configuring for upsmon +# +# To add a user for your upsmon, use this example: +# +# [monuser] +# password = pass +# allowfrom = bigserver +# +# upsmon master (or upsmon slave) +# +# The matching MONITOR line in your upsmon.conf would look like this: +# +# MONITOR myups@myhost 1 monuser pass slave diff --git a/additional/config/upsmon.conf b/additional/config/upsmon.conf new file mode 100644 index 0000000..97078d9 --- /dev/null +++ b/additional/config/upsmon.conf @@ -0,0 +1,287 @@ +# Network UPS Tools: example upsmon configuration +# +# This file contains passwords, so keep it secure. + +# -------------------------------------------------------------------------- +# RUN_AS_USER +# +# By default, upsmon splits into two processes. One stays as root and +# waits to run the SHUTDOWNCMD. The other one switches to another userid +# and does everything else. +# +# The default nonprivileged user is set at compile-time with +# 'configure --with-user=...'. +# +# You can override it with '-u ' when starting upsmon, or just +# define it here for convenience. +# +# Note: if you plan to use the reload feature, this file (upsmon.conf) +# must be readable by this user! Since it contains passwords, DO NOT +# make it world-readable. Also, do not make it writable by the upsmon +# user, since it creates an opportunity for an attack by changing the +# SHUTDOWNCMD to something malicious. +# +# For best results, you should create a new normal user like "nutmon", +# then specify it here and make it the owner of your upsmon.conf, then +# set the mode on upsmon.conf to 0400. +# +# RUN_AS_USER nutmon + +# -------------------------------------------------------------------------- +# MONITOR ("master"|"slave") +# +# List systems you want to monitor. Not all of these may supply power +# to the system running upsmon, but if you want to watch it, it has to +# be in this section. +# +# You must have at least one of these declared. +# +# is a UPS identifier in the form [@][:] +# like localhost, su700@mybox, etc. +# +# Simple entry: +# +# - "localhost" refers to the first UPS on the local system. +# +# Other possibilities: +# +# - "su700@mybox" means a UPS called "su700" on a system called "mybox" +# +# - "elvis:1234" means the first UPS on a system called "elvis", port 1234. +# +# Finally, to use all of these options: +# +# - "fenton@bigbox:5678" is a UPS called "fenton" on a system called +# "bigbox" which runs upsd on port "5678". Phew! +# +# The UPS names like "su700" and "fenton" are set in your ups.conf +# in [brackets] which identify a section for a particular driver. +# +# If the ups.conf on host "doghouse" has a section called "snoopy", the +# identifier for it would be "snoopy@doghouse". +# +# is an integer - the number of power supplies that this UPS +# feeds on this system. Most computers only have one power supply, so this +# is normally set to 1. You need a pretty big or special box to have any +# other value here. +# +# You can also set this to 0 for a system that doesn't supply any power, +# but you still want to monitor. Use this when you want to hear about +# changes for a given UPS without shutting down when it goes critical. +# +# and must match an entry in that system's +# upsd.users. If your username is "monmaster" and your password is +# "blah", the upsd.users would look like this: +# +# [monmaster] +# password = blah +# allowfrom = (whatever applies to this host) +# upsmon master (or slave) +# +# "master" means this system will shutdown last, allowing the slaves +# time to shutdown first. +# +# "slave" means this system shuts down immediately when power goes critical. +# +# Examples: +# +# MONITOR myups@bigserver 1 monmaster blah master +# MONITOR su700@server.example.com 1 upsmon secretpass slave + +# -------------------------------------------------------------------------- +# MINSUPPLIES +# +# Give the number of power supplies that must be receiving power to keep +# this system running. Most systems have one power supply, so you would +# put "1" in this field. +# +# Large/expensive server type systems usually have more, and can run with +# a few missing. The HP NetServer LH4 can run with 2 out of 4, for example, +# so you'd set that to 2. The idea is to keep the box running as long +# as possible, right? +# +# Obviously you have to put the redundant supplies on different UPS circuits +# for this to make sense! See big-servers.txt in the docs subdirectory +# for more information and ideas on how to use this feature. + +MINSUPPLIES 1 + +# -------------------------------------------------------------------------- +# SHUTDOWNCMD "" +# +# upsmon runs this command when the system needs to be brought down. +# +# This should work just about everywhere ... if it doesn't, well, change it. + +SHUTDOWNCMD "/sbin/shutdown -h +0" + +# -------------------------------------------------------------------------- +# NOTIFYCMD +# +# upsmon calls this to send messages when things happen +# +# This command is called with the full text of the message as one argument. +# The environment string NOTIFYTYPE will contain the type string of +# whatever caused this event to happen. +# +# Note that this is only called for NOTIFY events that have EXEC set with +# NOTIFYFLAG. See NOTIFYFLAG below for more details. +# +# Making this some sort of shell script might not be a bad idea. For more +# information and ideas, see pager.txt in the docs directory. +# +# Example: +# NOTIFYCMD /usr/local/ups/bin/notifyme + +# -------------------------------------------------------------------------- +# POLLFREQ +# +# Polling frequency for normal activities, measured in seconds. +# +# Adjust this to keep upsmon from flooding your network, but don't make +# it too high or it may miss certain short-lived power events. + +POLLFREQ 5 + +# -------------------------------------------------------------------------- +# POLLFREQALERT +# +# Polling frequency in seconds while UPS on battery. +# +# You can make this number lower than POLLFREQ, which will make updates +# faster when any UPS is running on battery. This is a good way to tune +# network load if you have a lot of these things running. +# +# The default is 5 seconds for both this and POLLFREQ. + +POLLFREQALERT 5 + +# -------------------------------------------------------------------------- +# HOSTSYNC - How long upsmon will wait before giving up on another upsmon +# +# The master upsmon process uses this number when waiting for slaves to +# disconnect once it has set the forced shutdown (FSD) flag. If they +# don't disconnect after this many seconds, it goes on without them. +# +# Similarly, upsmon slave processes wait up to this interval for the +# master upsmon to set FSD when a UPS they are monitoring goes critical - +# that is, on battery and low battery. If the master doesn't do its job, +# the slaves will shut down anyway to avoid damage to the file systems. +# +# This "wait for FSD" is done to avoid races where the status changes +# to critical and back between polls by the master. + +HOSTSYNC 15 + +# -------------------------------------------------------------------------- +# DEADTIME - Interval to wait before declaring a stale ups "dead" +# +# upsmon requires a UPS to provide status information every few seconds +# (see POLLFREQ and POLLFREQALERT) to keep things updated. If the status +# fetch fails, the UPS is marked stale. If it stays stale for more than +# DEADTIME seconds, the UPS is marked dead. +# +# A dead UPS that was last known to be on battery is assumed to have gone +# to a low battery condition. This may force a shutdown if it is providing +# a critical amount of power to your system. +# +# Note: DEADTIME should be a multiple of POLLFREQ and POLLFREQALERT. +# Otherwise you'll have "dead" UPSes simply because upsmon isn't polling +# them quickly enough. Rule of thumb: take the larger of the two +# POLLFREQ values, and multiply by 3. + +DEADTIME 15 + +# -------------------------------------------------------------------------- +# POWERDOWNFLAG - Flag file for forcing UPS shutdown on the master system +# +# upsmon will create a file with this name in master mode when it's time +# to shut down the load. You should check for this file's existence in +# your shutdown scripts and run 'upsdrvctl shutdown' if it exists. +# +# See the shutdown.txt file in the docs subdirectory for more information. + +POWERDOWNFLAG /etc/killpower + +# -------------------------------------------------------------------------- +# NOTIFYMSG - change messages sent by upsmon when certain events occur +# +# You can change the stock messages to something else if you like. +# +# NOTIFYMSG "message" +# +# NOTIFYMSG ONLINE "UPS %s is getting line power" +# NOTIFYMSG ONBATT "Someone pulled the plug on %s" +# +# Note that %s is replaced with the identifier of the UPS in question. +# +# Possible values for : +# +# ONLINE : UPS is back online +# ONBATT : UPS is on battery +# LOWBATT : UPS has a low battery (if also on battery, it's "critical") +# FSD : UPS is being shutdown by the master (FSD = "Forced Shutdown") +# COMMOK : Communications established with the UPS +# COMMBAD : Communications lost to the UPS +# SHUTDOWN : The system is being shutdown +# REPLBATT : The UPS battery is bad and needs to be replaced +# NOCOMM : A UPS is unavailable (can't be contacted for monitoring) + +# -------------------------------------------------------------------------- +# NOTIFYFLAG - change behavior of upsmon when NOTIFY events occur +# +# By default, upsmon sends walls (global messages to all logged in users) +# and writes to the syslog when things happen. You can change this. +# +# NOTIFYFLAG [+][+] ... +# +# NOTIFYFLAG ONLINE SYSLOG +# NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC +# +# Possible values for the flags: +# +# SYSLOG - Write the message in the syslog +# WALL - Write the message to all users on the system +# EXEC - Execute NOTIFYCMD (see above) with the message +# IGNORE - Don't do anything +# +# If you use IGNORE, don't use any other flags on the same line. + +# -------------------------------------------------------------------------- +# RBWARNTIME - replace battery warning time in seconds +# +# upsmon will normally warn you about a battery that needs to be replaced +# every 43200 seconds, which is 12 hours. It does this by triggering a +# NOTIFY_REPLBATT which is then handled by the usual notify structure +# you've defined above. +# +# If this number is not to your liking, override it here. + +RBWARNTIME 43200 + +# -------------------------------------------------------------------------- +# NOCOMMWARNTIME - no communications warning time in seconds +# +# upsmon will let you know through the usual notify system if it can't +# talk to any of the UPS entries that are defined in this file. It will +# trigger a NOTIFY_NOCOMM by default every 300 seconds unless you +# change the interval with this directive. + +NOCOMMWARNTIME 300 + +# -------------------------------------------------------------------------- +# FINALDELAY - last sleep interval before shutting down the system +# +# On a master, upsmon will wait this long after sending the NOTIFY_SHUTDOWN +# before executing your SHUTDOWNCMD. If you need to do something in between +# those events, increase this number. Remember, at this point your UPS is +# almost depleted, so don't make this too high. +# +# Alternatively, you can set this very low so you don't wait around when +# it's time to shut down. Some UPSes don't give much warning for low +# battery and will require a value of 0 here for a safe shutdown. +# +# Note: If FINALDELAY on the slave is greater than HOSTSYNC on the master, +# the master will give up waiting for the slave to disconnect. + +FINALDELAY 5 diff --git a/additional/config/upssched.conf b/additional/config/upssched.conf new file mode 100644 index 0000000..2f11631 --- /dev/null +++ b/additional/config/upssched.conf @@ -0,0 +1,95 @@ +# Network UPS Tools - upssched.conf sample file +# +# ============================================================================ +# +# CMDSCRIPT +# +# This script gets called to invoke commands for timers that trigger. +# It is given a single argument - the in your +# AT ... START-TIMER defines. +# +# *** This must be defined *before* the first AT line. Otherwise the +# program will complain and exit without doing anything. +# +# A shell script with a big case..esac construct should work nicely for this. +# An example has been provided to help you get started. + +CMDSCRIPT /usr/sbin/upssched-cmd + +# ============================================================================ +# +# PIPEFN +# +# This sets the file name of the FIFO that will pass communications between +# processes to start and stop timers. This should be set to some path where +# normal users can't create the file, due to the possibility of symlinking +# and other evil. +# +# NOTE: if you are running Solaris or similar, the permissions that upssched +# sets on this file *are not enough* to keep you safe. If your OS ignores +# the permissions on a FIFO, then you MUST put this in a protected directory! +# +# Another thing to think about: upsmon doesn't run the NOTIFYCMD as root +# unless you run it with -p. So, upssched will probably run as nobody +# or similar unless you give upsmon another user with -u. Either way, +# you have to set PIPEFN to something that ONLY the resulting upsmon +# user can access. +# +# This is commented out by default to make you visit this file and think +# about how your system works before potentially opening a hole. +# +# PIPEFN /var/run/upssched.pipe + +# ============================================================================ +# +# AT +# +# Define a handler for a specific event on UPS . +# +# can be the special value * to apply this handler to every +# possible value of . +# +# Run the command via your CMDSCRIPT when it happens. +# +# Note that any AT that matches both the and the +# for the current event will be used. + +# ============================================================================ +# +# Possible AT commands +# +# - START-TIMER +# +# Start a timer called that will trigger after +# seconds, calling your CMDSCRIPT with as the first +# argument. +# +# Example: +# Start a timer that'll execute when any UPS (*) has been gone 10 seconds +# +# AT COMMBAD * START-TIMER upsgone 10 + +# ----------------------------------------------------------------------- +# +# - CANCEL-TIMER [cmd] +# +# Cancel a running timer called , if possible. If the timer +# has passed then pass the optional argument to CMDSCRIPT. +# +# Example: +# If a specific UPS (myups@localhost) comes back online, then stop the +# timer before it triggers +# +# AT COMMOK myups@localhost CANCEL-TIMER upsgone + +# ----------------------------------------------------------------------- +# +# - EXECUTE +# +# Immediately pass as an argument to CMDSCRIPT. +# +# Example: +# If any UPS (*) reverts to utility power, then execute +# 'ups-back-on-line' via CMDSCRIPT. +# +# AT ONLINE * EXECUTE ups-back-on-line diff --git a/additional/config/upsset.conf b/additional/config/upsset.conf new file mode 100644 index 0000000..56795ba --- /dev/null +++ b/additional/config/upsset.conf @@ -0,0 +1,36 @@ +# Network UPS Tools - upsset.conf sample file +# +# This file is provided to ensure that you do not expose your upsd server +# to the world upon installing the CGI programs. Specifically, it keeps +# the upsset.cgi program from running until you have assured it that you +# have secured your web server's CGI directory. +# +# By default, your web server will probably let anyone access upsset.cgi +# once it is installed. This means that anyone could attempt to crack +# upsd logins since they would appear to be coming from your web server, +# rather than the outside world, slipping through any ACL/ACCESS definitions. +# +# For this reason, you *MUST* first secure your CGI programs before +# enabling upsset in this configuration file. If you can't do this in +# your web server, then you should *not* run this program. +# +# For Apache, the .htaccess file can be used in the directory with the +# programs. You'll need something like this: +# +# +# deny from all +# allow from your.network.addresses +# +# +# You will probably have to set "AllowOverride Limit" for this directory in +# your server-level configuration file as well. +# +# If this doesn't make sense, then stop reading and leave this program alone. +# +# Assuming you have all this done (and it works), then you may uncomment +# the line below and start using upsset.cgi through your web browser. +# + +### +### I_HAVE_SECURED_MY_CGI_DIRECTORY +### diff --git a/contriborbase b/contriborbase new file mode 100644 index 0000000..ef36a67 --- /dev/null +++ b/contriborbase @@ -0,0 +1 @@ +sme10 diff --git a/createlinks b/createlinks new file mode 100644 index 0000000..dcf4b81 --- /dev/null +++ b/createlinks @@ -0,0 +1,24 @@ +#!/usr/bin/perl -w + +use esmith::Build::CreateLinks qw(:all); + +my @events = qw(bootstrap-console-save console-save post-install post-upgrade e-smith-nutUPS-update); + +templates2events("/etc/sysconfig/ups", @events); +templates2events("/usr/lib/systemd/system/nut-server.service.d/50koozali.conf", @events); +templates2events("/usr/lib/systemd/system/nut-monitor.service.d/50koozali.conf", @events); + +foreach (qw(ups.conf upsd.users upsmon.conf upssched.conf)) +{ + templates2events("/etc/ups/$_", @events); +} + +foreach (qw(bootstrap-console-save console-save e-smith-nutUPS-update)) +{ + templates2events("/etc/ups/upsd.conf", $_); +} + +my $event="e-smith-nutUPS-update"; +safe_symlink("try-restart", "root/etc/e-smith/events/$event/services2adjust/nut"); +templates2events("/etc/systemd/system-preset/49-koozali.preset", $event); +event_link("systemd-default", $event, "06"); diff --git a/e-smith-nutUPS.spec b/e-smith-nutUPS.spec new file mode 100644 index 0000000..1d0b780 --- /dev/null +++ b/e-smith-nutUPS.spec @@ -0,0 +1,316 @@ +# $Id: e-smith-nutUPS.spec,v 1.16 2022/12/26 03:29:15 jpp Exp $ + +Summary: SME server - nut UPS interaction module +%define name e-smith-nutUPS +Name: %{name} +%define version 2.6.0 +%define release 14 +Version: %{version} +Release: %{release}%{?dist} +License: GPL +Group: Networking/Daemons +Source: %{name}-%{version}.tar.xz + +BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot +Requires: nut nut-client daemontools +Obsoletes: neon <= 0.25.5 +Requires: e-smith-lib >= 1.15.1-16 +BuildArchitectures: noarch +BuildRequires: e-smith-devtools +AutoReqProv: no + +%description +A module which configures the Network UPS Tools suite for operation with +the SME server software. + +%changelog +* Wed Jul 12 2023 cvs2git.sh aka Brian Read 2.6.0-14.sme +- Roll up patches and move to git repo [SME: 12338] + +* Wed Jul 12 2023 BogusDateBot +- Eliminated rpmbuild "bogus date" warnings due to inconsistent weekday, + by assuming the date is correct and changing the weekday. + +* Sun Dec 25 2022 Jean-Philippe Pialasse 2.6.0-13.sme +- fix server failing if set as netserver [SME: 12287] +- remove log noise for tmp files + +* Mon Jun 21 2021 Terry Fage 2.6.0-12.sme +- Misspelling in /usr/lib/systemd/system/nut.service file [SME: 11633] + +* Tue Mar 30 2021 Terry Fage 2.6.0-11.sme +- fix start ordering nut.service [SME: 11488] + +* Sat Mar 27 2021 Terry Fage 2.6.0-10.sme +- fix ExecStartPre path for /usr/lib/tmpfiles.d/nut-run.conf [SME: 11488] + +* Thu Mar 25 2021 Terry Fage 2.6.0-9.sme +- fix ExecStartPre path for nut.service [SME: 11488] + +* Mon Dec 07 2020 Jean-Philipe Pialasse 2.6.0-8.sme +- fix template path for monitor [SME: 9423] + +* Sun Nov 29 2020 John Crisp 2.6.0-6.sme +- Fix preset line endings in 49-koozali.preset [SME: 11215] + +* Wed Nov 18 2020 Jean-Philipe Pialasse 2.6.0-5.sme +- add update event to avoid reboot [SME: 11146] +- adapt nut UPS for systemd [SME: 9423] + +* Fri Feb 05 2016 stephane de Labrusse 2.6.0-2.sme +- Initial release to sme10 + +* Sat Feb 07 2015 stephane de Labrusse 2.4.0-9.sme +- Allow the admin upsd in /etc/hosts.allow [SME: 8826] + +* Tue Feb 03 2015 stephane de Labrusse 2.4.0-7.sme +- Creation Admin Privilege for use of upscmd & upsrw [SME: 8826] +- Remove obsolete directives {allowfrom} [SME: 8793] + +* Sun Jan 25 2015 stephane de Labrusse 2.4.0-5.sme +- Access property created (default value is 'localhost') [SME: 8793] + +* Thu Jan 22 2015 stephane de Labrusse 2.4.0-3.sme +- Remove obsolete directives {ACL,ACCEPT,REJECT} and switch to LISTEN +- in /etc/ups/upsd.conf +- Allow NUT in /etc/hosts.allow and in /etc/services [SME: 8793] +- Code change from Daniel B. + +* Thu Jan 31 2013 Shad L. Lords 2.4.0-2.sme +- Obsolete el5 packages that used to be required [SME: 7273] + +* Thu Jan 31 2013 Shad L. Lords 2.4.0-1.sme +- Roll new stream for sme9 + +* Sun May 17 2009 Jonathan Martens 2.2.0-2.sme +- Fix another instance of ups model for new version of nut [SME: 4750] + +* Tue Oct 7 2008 Shad L. Lords 2.2.0-1.sme +- Roll new stream to separate sme7/sme8 trees [SME: 4633] + +* Tue Jan 08 2008 Stephen Noble 1.2.0-17 +- Start rc7.d/S38nut up from S15 [SME: 3592] + +* Fri Nov 30 2007 Gavin Weight 1.2.0-16 +- Fix use of uninitialized value in nutModel migrate. [SME: 3597] + +* Sun Oct 7 2007 Shad L. Lords 1.2.0-15 +- Fix ups model for new version of nut [SME: 3457] + +* Sun Jun 3 2007 Stephen Noble 1.2.0-14 +- Fix mfr & mdl options in ups.conf [SME: 2791] + +* Fri Jun 1 2007 Stephen Noble 1.2.0-13 +- Add mfr & mdl options to ups.conf [SME: 2791] + +* Fri Jun 1 2007 Stephen Noble 1.2.0-12 +- Only use Type if model=genericups & type is defined [SME: 2748] + +* Sun Apr 29 2007 Shad L. Lords +- Clean up spec so package can be built by koji/plague + +* Tue Apr 10 2007 Stephen Noble 1.2.0-10 +- Only use Type if model=genericups [SME: 2748] + +* Fri Apr 06 2007 Shad L. Lords 1.2.0-9 +- Fix perms on config files [SME: 2712] + +* Fri Jan 19 2007 Shad L. Lords 1.2.0-8 +- Don't expand upsd.conf in post-{install,upgrade} + +* Thu Jan 18 2007 Shad L. Lords 1.2.0-7 +- Fix password generation and simplify [SME: 2323] + +* Sat Jan 13 2007 Shad L. Lords 1.2.0-6 +- Add upstype option to ups.conf [SME: 2286] + +* Thu Jan 04 2007 Shad L. Lords 1.2.0-5 +- Actually call the notify script on ups events. [SME: 1722] +- Allow nut to be a client to another master server. [SME: 2231] + +* Thu Dec 21 2006 Shad L. Lords 1.2.0-4 +- Make password secure for ups users +- Allow local network to monitor ups as slaves +- Make localhost master for ups +- Make startup/shutdown scripts use upsdrvctl so poweroff works + +* Thu Dec 07 2006 Shad L. Lords +- Update to new release naming. No functional changes. +- Make Packager generic + +* Sun May 28 2006 Charlie Brady 1.2.0-02 +- Fix perms on upsd.conf [SME: 1473] + +* Wed Mar 15 2006 Charlie Brady 1.2.0-01 +- Roll stable stream version. [SME: 1016] + +* Thu Feb 2 2006 Gordon Rowell 1.1.0-10 +- Added db default to match last change [SME: 26] + +* Thu Feb 2 2006 Charlie Brady 1.1.0-09 +- Change default model from hidups to newhidups. [SME: 26] + +* Wed Feb 01 2006 Charlie Brady 1.1.0-08 +- Ensure that device node has correct ownership. [SME: 619] + +* Wed Nov 30 2005 Gordon Rowell 1.1.0-07 +- Bump release number only + +* Tue Aug 16 2005 Charlie Brady +- [1.1.0-06] +- Match permissions on /etc/sysconfig/ups to those of the nut RPM. + +* Mon Jul 25 2005 Charlie Brady +- [1.1.0-05] +- Remove unused /etc/usb/usb.usermap template fragment. +- Add nut db entries to default configuration (Shad). +- Add missing templates.metadata files for all templated + files. [MN00064130] + +* Tue Jul 12 2005 Charlie Brady +- [1.1.0-04] +- Use generic_template_expand action in place of nutUPS-conf. + [MN00064130] + +* Tue Jul 12 2005 Charlie Brady +- [1.1.0-03] +- Port to version 2.0 of nut (contributed by Shad Lords). +- Change nutups user to nut to confirm with new package +- Upgrade templates to support new 2.0 format [SF: 1226389] + +* Thu Aug 21 2003 Charlie Brady +- [1.1.0-02] +- Replace nutUPS-conf-startup action with default db fragments. + [charlieb 9553] + +* Thu Aug 21 2003 Charlie Brady +- [1.1.0-01] +- Changing version to development stream number - 1.1.0 + +* Thu Jun 26 2003 Charlie Brady +- [1.0.0-01] +- Creating stable version stream - 1.0.0 + +* Wed Jun 4 2003 Charlie Brady +- [0.0.3-06] +- Create 'nutups' user via create-system-user. [charlieb 6033] + +* Fri May 9 2003 Gordon Rowell +- [0.0.3-05] +- Removed depedency on e-smith-email [gordonr 8405] + +* Fri Apr 25 2003 Charlie Brady +- [0.0.3-04] +- Change group and permissions of various configuration files, so that + files can be reloaded by programs running non-root. This is a merge + of Shad Lord's contributed code and my changes to use group read + permission. [charlieb 8405] + +* Fri Apr 25 2003 Tony Clayton +- [0.0.3-03] +- Don't expand rc.modules template from nutUPS-conf [tonyc 2753] + +* Fri Apr 25 2003 Charlie Brady +- [0.0.3-02] +- Change group of nutUPS.notify script to nutups. [charlieb 8530] + +* Wed Apr 16 2003 Tony Clayton +- [0.0.3-01] +- Remove /etc/rc.modules altogether [tonyc 6556] + +* Tue Mar 18 2003 Lijie Deng +- [0.0.2-12] +- Delete ./etc/rc.modules/template-begin, + and modified %build [lijied 3295] + +* Thu Jan 16 2003 Tony Clayton +- [0.0.2-11] +- fix rc.modules usb drivers again [tonyc 2753] + +* Mon Jan 13 2003 Tony Clayton +- [0.0.2-10] +- fix rc.modules usb drivers to load conditionally [tonyc 2753] + +* Mon Jan 13 2003 Tony Clayton +- [0.0.2-09] +- send stdout/stderr to /dev/null when loading usb modules [tonyc 2753] + +* Mon Jan 13 2003 Tony Clayton +- [0.0.2-08] +- really adding usb* modules in rc.modules [tonyc 2753] + +* Mon Jan 13 2003 Tony Clayton +- [0.0.2-07] +- load usb* modules in rc.modules for hidups support +- add header to template-begin [tonyc 2753] + +* Fri Jan 10 2003 Tony Clayton +- [0.0.2-06] +- fix NOTIFYFLAG entries in upsmon.conf [tonyc 2753] +- turn off nut service by default [tonyc 2753] + +* Thu Dec 5 2002 Charlie Brady +- [0.0.2-05] +- Move mknod of device node to %post script. It can't run in %pre, because + the enclosing directory has not yet been pulled out of the RPM archive. + +* Thu Dec 5 2002 Charlie Brady +- [0.0.2-04] +- Fix syntax errors in one of the upsmon.conf template fragments. +- Add ups runtime state directory. Create hiddev device node with + appropriate permissions inside that directory. + +* Wed Nov 27 2002 Charlie Brady +- [0.0.2-03] +- Change configuration so that most UPS events are logged only to + syslog, but SHUTDOWN is done using "signal-event". Response + to UPS events can be tuned via config DB entries. + +* Tue Nov 19 2002 Charlie Brady +- [0.0.2-02] +- Add /etc/rc.d/init.d/nut symlink so that service starts up. +- Fix up a few broken templates. + +* Mon Nov 18 2002 Charlie Brady +- [0.0.2-01] +- Initial + +%prep +%setup + +rm -rf root/etc/rc.d/init.d/nut root/etc/rc.d/rc7.d/S38nut +mkdir -p root/usr/lib/systemd/system/nut-monitor.service.d root/usr/lib/systemd/system/nut-server.service.d + + +%build +perl createlinks + +%install +rm -rf $RPM_BUILD_ROOT +(cd root ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT) +rm -f %{name}-%{version}-%{release}-filelist +/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \ + | sed -e '/nutUPS.notify/s/root,root/root,nut/' \ + > %{name}-%{version}-%{release}-filelist +echo '%dir %attr(750,nut,nut) /var/lib/ups' \ + >> %{name}-%{version}-%{release}-filelist +echo '%ghost %attr(640,nut,nut) /var/lib/ups/hiddev0' \ + >> %{name}-%{version}-%{release}-filelist +mkdir -p $RPM_BUILD_ROOT/var/lib/ups/ +touch $RPM_BUILD_ROOT/var/lib/ups/hiddev0 + +%pre +/sbin/e-smith/create-system-user nut 57 'NUT UPS user' /var/lib/ups /bin/false + +%post +if [ \! -e /var/lib/ups/hiddev0 ] +then + mknod /var/lib/ups/hiddev0 c 180 96 +fi +chown nut.nut /var/lib/ups/hiddev0 + +%clean +rm -rf $RPM_BUILD_ROOT + +%files -f %{name}-%{version}-%{release}-filelist +%defattr(-,root,root) diff --git a/root/etc/e-smith/db/configuration/defaults/nut/AdminUser b/root/etc/e-smith/db/configuration/defaults/nut/AdminUser new file mode 100644 index 0000000..7a68b11 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/nut/AdminUser @@ -0,0 +1 @@ +disabled diff --git a/root/etc/e-smith/db/configuration/defaults/nut/Model b/root/etc/e-smith/db/configuration/defaults/nut/Model new file mode 100644 index 0000000..08913e7 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/nut/Model @@ -0,0 +1 @@ +usbhid-ups diff --git a/root/etc/e-smith/db/configuration/defaults/nut/access b/root/etc/e-smith/db/configuration/defaults/nut/access new file mode 100644 index 0000000..2fbb50c --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/nut/access @@ -0,0 +1 @@ +localhost diff --git a/root/etc/e-smith/db/configuration/defaults/nut/status b/root/etc/e-smith/db/configuration/defaults/nut/status new file mode 100644 index 0000000..7a68b11 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/nut/status @@ -0,0 +1 @@ +disabled diff --git a/root/etc/e-smith/db/configuration/defaults/nut/type b/root/etc/e-smith/db/configuration/defaults/nut/type new file mode 100644 index 0000000..24e1098 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/nut/type @@ -0,0 +1 @@ +service diff --git a/root/etc/e-smith/db/configuration/migrate/nutModel b/root/etc/e-smith/db/configuration/migrate/nutModel new file mode 100644 index 0000000..7f13a27 --- /dev/null +++ b/root/etc/e-smith/db/configuration/migrate/nutModel @@ -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'); +} + diff --git a/root/etc/e-smith/db/configuration/migrate/nutPass b/root/etc/e-smith/db/configuration/migrate/nutPass new file mode 100644 index 0000000..0a035dd --- /dev/null +++ b/root/etc/e-smith/db/configuration/migrate/nutPass @@ -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'); +} diff --git a/root/etc/e-smith/templates.metadata/etc/sysconfig/ups b/root/etc/e-smith/templates.metadata/etc/sysconfig/ups new file mode 100644 index 0000000..3709f0b --- /dev/null +++ b/root/etc/e-smith/templates.metadata/etc/sysconfig/ups @@ -0,0 +1 @@ +PERMS=0644 diff --git a/root/etc/e-smith/templates.metadata/etc/ups/ups.conf b/root/etc/e-smith/templates.metadata/etc/ups/ups.conf new file mode 100644 index 0000000..5d836f3 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/etc/ups/ups.conf @@ -0,0 +1,3 @@ +UID="root" +GID="nut" +PERMS=0640 diff --git a/root/etc/e-smith/templates.metadata/etc/ups/upsd.conf b/root/etc/e-smith/templates.metadata/etc/ups/upsd.conf new file mode 100644 index 0000000..5d836f3 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/etc/ups/upsd.conf @@ -0,0 +1,3 @@ +UID="root" +GID="nut" +PERMS=0640 diff --git a/root/etc/e-smith/templates.metadata/etc/ups/upsd.users b/root/etc/e-smith/templates.metadata/etc/ups/upsd.users new file mode 100644 index 0000000..5d836f3 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/etc/ups/upsd.users @@ -0,0 +1,3 @@ +UID="root" +GID="nut" +PERMS=0640 diff --git a/root/etc/e-smith/templates.metadata/etc/ups/upsmon.conf b/root/etc/e-smith/templates.metadata/etc/ups/upsmon.conf new file mode 100644 index 0000000..5d836f3 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/etc/ups/upsmon.conf @@ -0,0 +1,3 @@ +UID="root" +GID="nut" +PERMS=0640 diff --git a/root/etc/e-smith/templates.metadata/etc/ups/upssched.conf b/root/etc/e-smith/templates.metadata/etc/ups/upssched.conf new file mode 100644 index 0000000..5d836f3 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/etc/ups/upssched.conf @@ -0,0 +1,3 @@ +UID="root" +GID="nut" +PERMS=0640 diff --git a/root/etc/e-smith/templates/etc/hosts.allow/upsd b/root/etc/e-smith/templates/etc/hosts.allow/upsd new file mode 100644 index 0000000..507575a --- /dev/null +++ b/root/etc/e-smith/templates/etc/hosts.allow/upsd @@ -0,0 +1,3 @@ +{ + $DB->hosts_allow_spec('nut','nut'); +} diff --git a/root/etc/e-smith/templates/etc/hosts.allow/upsd_admin_privileges b/root/etc/e-smith/templates/etc/hosts.allow/upsd_admin_privileges new file mode 100644 index 0000000..9c29edc --- /dev/null +++ b/root/etc/e-smith/templates/etc/hosts.allow/upsd_admin_privileges @@ -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'); +} diff --git a/root/etc/e-smith/templates/etc/services/30Nut b/root/etc/e-smith/templates/etc/services/30Nut new file mode 100644 index 0000000..fce439d --- /dev/null +++ b/root/etc/e-smith/templates/etc/services/30Nut @@ -0,0 +1,3 @@ +#Nut Service +nut 3493/tcp # Network UPS Tools +nut 3493/udp # Network UPS Tools diff --git a/root/etc/e-smith/templates/etc/sysconfig/ups/MODEL b/root/etc/e-smith/templates/etc/sysconfig/ups/MODEL new file mode 100644 index 0000000..6dd3ace --- /dev/null +++ b/root/etc/e-smith/templates/etc/sysconfig/ups/MODEL @@ -0,0 +1 @@ +MODEL=upsdrvctl diff --git a/root/etc/e-smith/templates/etc/sysconfig/ups/SERVER b/root/etc/e-smith/templates/etc/sysconfig/ups/SERVER new file mode 100644 index 0000000..b7d62b1 --- /dev/null +++ b/root/etc/e-smith/templates/etc/sysconfig/ups/SERVER @@ -0,0 +1 @@ +SERVER={ $nut{Master} || 'yes' } diff --git a/root/etc/e-smith/templates/etc/systemd/system-preset/49-koozali.preset/70nutUPS b/root/etc/e-smith/templates/etc/systemd/system-preset/49-koozali.preset/70nutUPS new file mode 100644 index 0000000..dcd6905 --- /dev/null +++ b/root/etc/e-smith/templates/etc/systemd/system-preset/49-koozali.preset/70nutUPS @@ -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"; + } +} diff --git a/root/etc/e-smith/templates/etc/ups/ups.conf/UPS b/root/etc/e-smith/templates/etc/ups/ups.conf/UPS new file mode 100644 index 0000000..544b471 --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/ups.conf/UPS @@ -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"; +} diff --git a/root/etc/e-smith/templates/etc/ups/upsd.conf/10Listen_Local_Network b/root/etc/e-smith/templates/etc/ups/upsd.conf/10Listen_Local_Network new file mode 100644 index 0000000..99cd4bd --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/upsd.conf/10Listen_Local_Network @@ -0,0 +1,6 @@ +{ +my $access = $nut{access} || 'localhost'; + +$OUT .= "LISTEN 127.0.0.1"; +$OUT .= "\nLISTEN $LocalIP" if ($access eq 'private'); +} diff --git a/root/etc/e-smith/templates/etc/ups/upsd.users/monitor b/root/etc/e-smith/templates/etc/ups/upsd.users/monitor new file mode 100644 index 0000000..ac8dd70 --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/upsd.users/monitor @@ -0,0 +1,8 @@ + [upsmaster] + password = { $nut{MasterPass} } + upsmon master + + [upsslave] + password = { $nut{SlavePass} } + upsmon slave + diff --git a/root/etc/e-smith/templates/etc/ups/upsd.users/upsd_administrative_privileges b/root/etc/e-smith/templates/etc/ups/upsd.users/upsd_administrative_privileges new file mode 100644 index 0000000..82535aa --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/upsd.users/upsd_administrative_privileges @@ -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"; +} diff --git a/root/etc/e-smith/templates/etc/ups/upsmon.conf/DEADTIME b/root/etc/e-smith/templates/etc/ups/upsmon.conf/DEADTIME new file mode 100644 index 0000000..ed45211 --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/upsmon.conf/DEADTIME @@ -0,0 +1 @@ +DEADTIME 15 diff --git a/root/etc/e-smith/templates/etc/ups/upsmon.conf/FINALDELAY b/root/etc/e-smith/templates/etc/ups/upsmon.conf/FINALDELAY new file mode 100644 index 0000000..ba45394 --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/upsmon.conf/FINALDELAY @@ -0,0 +1 @@ +FINALDELAY 5 diff --git a/root/etc/e-smith/templates/etc/ups/upsmon.conf/HOSTSYNC b/root/etc/e-smith/templates/etc/ups/upsmon.conf/HOSTSYNC new file mode 100644 index 0000000..e9bdbbd --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/upsmon.conf/HOSTSYNC @@ -0,0 +1 @@ +HOSTSYNC 15 diff --git a/root/etc/e-smith/templates/etc/ups/upsmon.conf/MINSUPPLIES b/root/etc/e-smith/templates/etc/ups/upsmon.conf/MINSUPPLIES new file mode 100644 index 0000000..a6e86ac --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/upsmon.conf/MINSUPPLIES @@ -0,0 +1 @@ +MINSUPPLIES 1 diff --git a/root/etc/e-smith/templates/etc/ups/upsmon.conf/MONITOR b/root/etc/e-smith/templates/etc/ups/upsmon.conf/MONITOR new file mode 100644 index 0000000..9852b3e --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/upsmon.conf/MONITOR @@ -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"; + } +} diff --git a/root/etc/e-smith/templates/etc/ups/upsmon.conf/NOCOMMWARNTIME b/root/etc/e-smith/templates/etc/ups/upsmon.conf/NOCOMMWARNTIME new file mode 100644 index 0000000..12f763c --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/upsmon.conf/NOCOMMWARNTIME @@ -0,0 +1 @@ +NOCOMMWARNTIME 300 diff --git a/root/etc/e-smith/templates/etc/ups/upsmon.conf/NOTIFYCMD b/root/etc/e-smith/templates/etc/ups/upsmon.conf/NOTIFYCMD new file mode 100644 index 0000000..953922f --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/upsmon.conf/NOTIFYCMD @@ -0,0 +1 @@ +NOTIFYCMD /sbin/e-smith/nutUPS.notify diff --git a/root/etc/e-smith/templates/etc/ups/upsmon.conf/NOTIFYFLAG b/root/etc/e-smith/templates/etc/ups/upsmon.conf/NOTIFYFLAG new file mode 100644 index 0000000..a4dda66 --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/upsmon.conf/NOTIFYFLAG @@ -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 diff --git a/root/etc/e-smith/templates/etc/ups/upsmon.conf/POLLFREQ b/root/etc/e-smith/templates/etc/ups/upsmon.conf/POLLFREQ new file mode 100644 index 0000000..f0ee0b1 --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/upsmon.conf/POLLFREQ @@ -0,0 +1 @@ +POLLFREQ 5 diff --git a/root/etc/e-smith/templates/etc/ups/upsmon.conf/POLLFREQALERT b/root/etc/e-smith/templates/etc/ups/upsmon.conf/POLLFREQALERT new file mode 100644 index 0000000..43b05f3 --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/upsmon.conf/POLLFREQALERT @@ -0,0 +1 @@ +POLLFREQALERT 5 diff --git a/root/etc/e-smith/templates/etc/ups/upsmon.conf/POWERDOWNFLAG b/root/etc/e-smith/templates/etc/ups/upsmon.conf/POWERDOWNFLAG new file mode 100644 index 0000000..87921a4 --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/upsmon.conf/POWERDOWNFLAG @@ -0,0 +1 @@ +POWERDOWNFLAG /etc/killpower diff --git a/root/etc/e-smith/templates/etc/ups/upsmon.conf/RBWARNTIME b/root/etc/e-smith/templates/etc/ups/upsmon.conf/RBWARNTIME new file mode 100644 index 0000000..604c521 --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/upsmon.conf/RBWARNTIME @@ -0,0 +1 @@ +RBWARNTIME 43200 diff --git a/root/etc/e-smith/templates/etc/ups/upsmon.conf/SHUTDOWNCMD b/root/etc/e-smith/templates/etc/ups/upsmon.conf/SHUTDOWNCMD new file mode 100644 index 0000000..f8b7382 --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/upsmon.conf/SHUTDOWNCMD @@ -0,0 +1 @@ +SHUTDOWNCMD "/sbin/e-smith/signal-event halt" diff --git a/root/etc/e-smith/templates/etc/ups/upssched.conf/00README b/root/etc/e-smith/templates/etc/ups/upssched.conf/00README new file mode 100644 index 0000000..f200e64 --- /dev/null +++ b/root/etc/e-smith/templates/etc/ups/upssched.conf/00README @@ -0,0 +1 @@ +# For more information see "man upssched.conf" diff --git a/root/etc/e-smith/templates/usr/lib/systemd/system/nut-monitor.service.d/50koozali.conf/20unit b/root/etc/e-smith/templates/usr/lib/systemd/system/nut-monitor.service.d/50koozali.conf/20unit new file mode 100644 index 0000000..a49bbfe --- /dev/null +++ b/root/etc/e-smith/templates/usr/lib/systemd/system/nut-monitor.service.d/50koozali.conf/20unit @@ -0,0 +1,3 @@ +[Unit] +PartOf=nut.service +After=nut.service network-online.target diff --git a/root/etc/e-smith/templates/usr/lib/systemd/system/nut-monitor.service.d/50koozali.conf/40service b/root/etc/e-smith/templates/usr/lib/systemd/system/nut-monitor.service.d/50koozali.conf/40service new file mode 100644 index 0000000..ec62bf9 --- /dev/null +++ b/root/etc/e-smith/templates/usr/lib/systemd/system/nut-monitor.service.d/50koozali.conf/40service @@ -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 diff --git a/root/etc/e-smith/templates/usr/lib/systemd/system/nut-monitor.service.d/50koozali.conf/80install b/root/etc/e-smith/templates/usr/lib/systemd/system/nut-monitor.service.d/50koozali.conf/80install new file mode 100644 index 0000000..aa4f147 --- /dev/null +++ b/root/etc/e-smith/templates/usr/lib/systemd/system/nut-monitor.service.d/50koozali.conf/80install @@ -0,0 +1,2 @@ +[Install] +WantedBy=sme-server.target diff --git a/root/etc/e-smith/templates/usr/lib/systemd/system/nut-server.service.d/50koozali.conf/20unit b/root/etc/e-smith/templates/usr/lib/systemd/system/nut-server.service.d/50koozali.conf/20unit new file mode 100644 index 0000000..cb0f221 --- /dev/null +++ b/root/etc/e-smith/templates/usr/lib/systemd/system/nut-server.service.d/50koozali.conf/20unit @@ -0,0 +1,4 @@ +[Unit] +PartOf=nut.service +After=nut.service network-online.target + diff --git a/root/etc/e-smith/templates/usr/lib/systemd/system/nut-server.service.d/50koozali.conf/40service b/root/etc/e-smith/templates/usr/lib/systemd/system/nut-server.service.d/50koozali.conf/40service new file mode 100644 index 0000000..122b0cd --- /dev/null +++ b/root/etc/e-smith/templates/usr/lib/systemd/system/nut-server.service.d/50koozali.conf/40service @@ -0,0 +1,2 @@ +[Service] +ExecStartPre=/sbin/e-smith/service-status nut diff --git a/root/etc/e-smith/templates/usr/lib/systemd/system/nut-server.service.d/50koozali.conf/80install b/root/etc/e-smith/templates/usr/lib/systemd/system/nut-server.service.d/50koozali.conf/80install new file mode 100644 index 0000000..aa4f147 --- /dev/null +++ b/root/etc/e-smith/templates/usr/lib/systemd/system/nut-server.service.d/50koozali.conf/80install @@ -0,0 +1,2 @@ +[Install] +WantedBy=sme-server.target diff --git a/root/etc/rc.d/init.d/.gitignore b/root/etc/rc.d/init.d/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/rc.d/rc7.d/.gitignore b/root/etc/rc.d/rc7.d/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/root/sbin/e-smith/nutUPS.notify b/root/sbin/e-smith/nutUPS.notify new file mode 100644 index 0000000..b8b555d --- /dev/null +++ b/root/sbin/e-smith/nutUPS.notify @@ -0,0 +1,6 @@ +#! /bin/sh +# UPS notify script. + +/bin/mail -s "$UPSNAME: $NOTIFYTYPE" admin <