commit 7c2524edb8e12f3ebd740073f146fbbabb0697393250cc509e86e773e0f4db7a Author: OBS User unknown Date: Mon Jan 15 23:27:08 2007 +0000 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/nut?expand=0&rev=1 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/README.SUSE b/README.SUSE new file mode 100644 index 0000000..12e043a --- /dev/null +++ b/README.SUSE @@ -0,0 +1,131 @@ +NUT is preconfigured to use a local or remote UPS as far as possible. +But it still requires a minimal manual configuration before the first +use. + +This document contains: +- How to configure local or remote UPS (mandatory reading). +- How to configure to suspend to disk (optional reading). +- What to do in environment with possible service timeouts (optional + reading). + + +The default setup uses one local UPS. You have to define UPS type in +file /etc/ups/ups.conf. + + +It requires only few adoptions before you can start the service: + + + * Configuration of a locally connected UPS: + + In /etc/ups/ups.conf: + - Go to the [myups] section at the end of the file. + - Set driver key to the driver name supporting your UPS. + (see /usr/lib/ups/driver/ for possible drivers. Each driver + has a man page. Many USB UPSes are hidups.) + - Set port key to the device your UPS is connected to, + e.g. /dev/ttyS0 for first serial port (COM1) or /dev/hiddev0 + for USB HID UPS. + - Adjust desc key as you want. + + Start the service: + - "/etc/init.d/upsd start" + + + * Configuration of a UPS connected to a remote machine: + + In /etc/ups/ups.conf: + - Comment out or remove the [myups] section at the end of the + file. + + In /etc/ups/upsmon.conf: + - Find the uncommented MONITOR line followed by + "myups@localhost" and change it to: +MONITOR myups@remote_machine 1 upsslave remote_password slave + Where: + remote_machine is a hostname of the remote machine. + remote_password is the password used for upsslave on the + remote machine (you can find it in the remote file + /etc/ups/upsd.users). + + In /etc/ups/hosts.conf: + - Find the uncommented MONITOR line followed by + "myups@localhost". + - Change the hostname from "localhost" to the hostname of + the remote machine. + - Change the description as you want. + + In the remote /etc/ups/upsd.users: + - Find the line allowfrom for upsslave user. + - Add your local machine name to the allowfrom list. + + Start the service: + - "/etc/init.d/upsd start" on both local and remote machines. + - If you have edited configuration of a running server, run + "/etc/init.d/upsd reload" + + + * Test the configuration using upsc or upslog: + + - "upsc myups@localhost" + Should display information about the UPS status. + + - "upslog -s myups@localhost -l -" + Should display UPS status log every 30 seconds. + (Press Ctrl-C keys to stop upslog). + +Notes: + +- Predefined user upsmaster + + There are two predefined users - upsmaster and upsslave. The passwords + for them are generated during the installation (see the "password" + lines in /etc/ups/upsd.users). + + User upsmaster has privileges to shut down master machine (default for + local UPS), upsslave has privileges to shut down slave machines. + + If you change it, or add another user, don't forget to adopt the + MONITOR lines in upsmon.conf on all machines using this user and + password combination to connect to the upsd. + + + +Suspend to disk + +If you want to configure nut to do suspend to disk instead of shutdown +you should: + +- Verify, that suspend to disk works correctly with your desktop: + shutdown -z +0 + (You can lose your unsaved data, if your computer does not support + suspend.) +- Change SHUTDOWNCMD in /etc/ups/upsmon.conf to: +SHUTDOWNCMD "/sbin/shutdown -z +0" +- Verify, that your UPS provides reasonable grant period to complete + suspend in all situations. + + + +Environment with possible service timeouts + +In some environments, there is no guarantee, that the machine will +correctly shut down, either because other machines providing critical +services are already down or because some services (e. g. squid) are +stopping too long and battery power is not sufficient. In this case, +you can prefer incorrect but fast shutdown. + +To fix this problem, you need to do: + +- Copy upsd-early-powerdown script to your /etc/init.d/ directory. + +- Edit following lines: + + Replace "FIXME scripts which should not stop before powerdown" by an + appropriate init script list. + + Replace "FIXME scripts which should stop before powerdown" by an + appropriate init script list. + +- Start YaST Runlevel Editor and enable this meta-service in + runlevels, where you want to apply early shutdown. diff --git a/nut-2.0.4-overflow.patch b/nut-2.0.4-overflow.patch new file mode 100644 index 0000000..ba89cb4 --- /dev/null +++ b/nut-2.0.4-overflow.patch @@ -0,0 +1,33 @@ +--- drivers/newhidups.c ++++ drivers/newhidups.c +@@ -578,7 +578,7 @@ + + void upsdrv_initups(void) + { +- char *regex_array[5]; ++ char *regex_array[6]; + int r; + int i; + +--- drivers/rhino.h ++++ drivers/rhino.h +@@ -59,7 +59,7 @@ + /* data vetor from received and configuration data package - not used yet + unsigned char Dados[ 161 ]; */ + /* identification group */ +-char Model[12]; ++char Model[15]; + int RhinoModel; /*, imodel; */ + int PotenciaNominal, PowerFactor; + /* input group */ +--- drivers/tripplite_usb.c ++++ drivers/tripplite_usb.c +@@ -1038,7 +1038,7 @@ + */ + void upsdrv_initups(void) + { +- char *regex_array[5]; ++ char *regex_array[6]; + int r; + + #if 0 diff --git a/nut-2.0.4.tar.bz2 b/nut-2.0.4.tar.bz2 new file mode 100644 index 0000000..eea85ec --- /dev/null +++ b/nut-2.0.4.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bae249bd862bcd28c7e3760b0205267ec94fe8785c0bdd3cdd9b43f3f7551a73 +size 547224 diff --git a/nut-notifyflag.patch b/nut-notifyflag.patch new file mode 100644 index 0000000..9f5da6e --- /dev/null +++ b/nut-notifyflag.patch @@ -0,0 +1,18 @@ +--- conf/upsmon.conf ++++ conf/upsmon.conf +@@ -243,6 +243,15 @@ + # IGNORE - Don't do anything + # + # If you use IGNORE, don't use any other flags on the same line. ++# ++NOTIFYFLAG ONLINE SYSLOG ++NOTIFYFLAG COMMOK SYSLOG ++NOTIFYFLAG SHUTDOWN SYSLOG ++NOTIFYFLAG ONBATT SYSLOG+WALL ++NOTIFYFLAG LOWBATT SYSLOG+WALL ++NOTIFYFLAG FSD SYSLOG+WALL ++NOTIFYFLAG NOCOMM SYSLOG+WALL ++NOTIFYFLAG COMMBAD SYSLOG+WALL + + # -------------------------------------------------------------------------- + # RBWARNTIME - replace battery warning time in seconds diff --git a/nut-powersave.patch b/nut-powersave.patch new file mode 100644 index 0000000..1ee80cc --- /dev/null +++ b/nut-powersave.patch @@ -0,0 +1,28 @@ +--- conf/upsmon.conf ++++ conf/upsmon.conf +@@ -130,6 +130,8 @@ + # Example: + # NOTIFYCMD /usr/local/ups/bin/notifyme + ++NOTIFYCMD /usr/lib/powersave/powersave-notify ++ + # -------------------------------------------------------------------------- + # POLLFREQ + # +@@ -247,11 +249,11 @@ + NOTIFYFLAG ONLINE SYSLOG + NOTIFYFLAG COMMOK SYSLOG + NOTIFYFLAG SHUTDOWN SYSLOG +-NOTIFYFLAG ONBATT SYSLOG+WALL +-NOTIFYFLAG LOWBATT SYSLOG+WALL +-NOTIFYFLAG FSD SYSLOG+WALL +-NOTIFYFLAG NOCOMM SYSLOG+WALL +-NOTIFYFLAG COMMBAD SYSLOG+WALL ++NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC ++NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC ++NOTIFYFLAG FSD SYSLOG+WALL+EXEC ++NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC ++NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC + + # -------------------------------------------------------------------------- + # RBWARNTIME - replace battery warning time in seconds diff --git a/nut-preconfig.patch b/nut-preconfig.patch new file mode 100644 index 0000000..8e61b0a --- /dev/null +++ b/nut-preconfig.patch @@ -0,0 +1,82 @@ +--- conf/Makefile.in ++++ conf/Makefile.in +@@ -17,14 +17,14 @@ + + install: + @for f in $(SECFILES) ; do \ +- $(INSTALLCMD) -m 0600 $$f $(CONFPATH)/$$f.sample; \ ++ $(INSTALLCMD) -m 0600 $$f $(CONFPATH)/$$f; \ + done + + @for f in $(PUBFILES) ; do \ +- $(INSTALLCMD) -m 0644 $$f $(CONFPATH)/$$f.sample; \ ++ $(INSTALLCMD) -m 0644 $$f $(CONFPATH)/$$f; \ + done + + install-cgi-conf: + @for f in $(CGIPUB) ; do \ +- $(INSTALLCMD) -m 0644 $$f $(CONFPATH)/$$f.sample; \ ++ $(INSTALLCMD) -m 0644 $$f $(CONFPATH)/$$f; \ + done +--- conf/hosts.conf ++++ conf/hosts.conf +@@ -27,3 +27,5 @@ + # 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" ++ ++MONITOR myups@localhost "Local UPS" +--- conf/ups.conf ++++ conf/ups.conf +@@ -102,3 +102,8 @@ + # + # To find out if your driver supports any extra settings, start it with + # the -h option and/or read the driver's documentation. ++ ++[myups] ++ driver = undefined ++ port = /dev/undefined ++ desc = "Local UPS" +--- conf/upsd.users ++++ conf/upsd.users +@@ -68,3 +68,13 @@ + # The matching MONITOR line in your upsmon.conf would look like this: + # + # MONITOR myups@myhost 1 monuser pass master (or slave) ++ ++[upsmaster] ++ password = @UPSD_INITIAL_MASTER_PASSWORD@ ++ allowfrom = localhost ++ upsmon master ++ ++[upsslave] ++ password = @UPSD_INITIAL_SLAVE_PASSWORD@ ++ allowfrom = localhost ++ upsmon slave +--- conf/upsmon.conf ++++ conf/upsmon.conf +@@ -21,13 +21,13 @@ + # 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", ++# For best results, you should create a new normal user like "@UPSD_USER@", + # and make it a member of a "nut" group or similar. Then specify it + # here and grant read access to the upsmon.conf for that group. + # + # This user should not have write access to upsmon.conf. + # +-# RUN_AS_USER nutmon ++# RUN_AS_USER @UPSD_USER@ + + # -------------------------------------------------------------------------- + # MONITOR ("master"|"slave") +@@ -83,6 +83,8 @@ + # MONITOR myups@bigserver 1 monmaster blah master + # MONITOR su700@server.example.com 1 upsmon secretpass slave + ++MONITOR myups@localhost 1 upsmaster @UPSD_INITIAL_MASTER_PASSWORD@ master ++ + # -------------------------------------------------------------------------- + # MINSUPPLIES + # diff --git a/nut.changes b/nut.changes new file mode 100644 index 0000000..ebce50c --- /dev/null +++ b/nut.changes @@ -0,0 +1,449 @@ +------------------------------------------------------------------- +Mon Sep 18 15:24:30 CEST 2006 - anosek@suse.cz + +- fixed compiler warning: array subscript out of range [#204417] + (overflow.patch) + +------------------------------------------------------------------- +Fri Sep 1 10:19:07 CEST 2006 - anosek@suse.cz + +- updated to 2.0.4 + * A bug has been fixed in NUT core to support resuming from + suspend-to-disk. This should also fix other similar issues, + like time synchronisation through the NTP. + * The mge-shut driver now better detects the Low Battery status, + support new models and fixes some wrong status and data. + It also fixes some issue where the UPS wasn't restarting + (refer to mge-shut manpage). + * The genericups custom configuration through ups.conf + is working again + * The genericups driver type 22 also support CyberPower 725SL + (and maybe others SL models) + * The new megatec driver, which will replace a bunch of drivers + by nut 2.2 (refer to docs/megatec.txt and UPGRADING) has been + backported from the trunk (Development tree). The powermust + driver has also received some attention. + * The new rhino driver was added to support Microsol Rhino UPS + hardware. The solis has also been improved for solaris + compatibility, and internal / external shutdown programming. + Solis can now save external shutdown programming to ups, + and support new cables for solis 3 +- dropped obsolete patch (nut-2.0.4-memset.patch) +- fixed subscript out of range [#185610] (overflow.patch) + +------------------------------------------------------------------- +Fri Jun 23 11:18:12 CEST 2006 - sbrabec@suse.cz + +- Typo fix in the init script. + +------------------------------------------------------------------- +Thu Apr 27 13:40:30 CEST 2006 - sbrabec@suse.cz + +- Work correctly, if port is a symlink (168611#c6). + +------------------------------------------------------------------- +Tue Apr 25 19:16:15 CEST 2006 - sbrabec@suse.cz + +- Fixed init script to behave correctly for port = auto (#168611). + +------------------------------------------------------------------- +Fri Mar 24 13:56:16 CET 2006 - sbrabec@suse.cz + +- Typo fixes. + +------------------------------------------------------------------- +Tue Mar 21 11:39:44 CET 2006 - sbrabec@suse.cz + +- Added D-BUS policy file (#159668). + +------------------------------------------------------------------- +Mon Mar 20 17:56:33 CET 2006 - sbrabec@suse.cz + +- Support for UPS powerdown using HALT_POWERDOWN_INSERT. +- Added upsd-early-powerdown template and improved README.SUSE. +- Remove obsolete /etc/sysconfig/smartups in %post. + +------------------------------------------------------------------- +Fri Mar 17 13:28:10 CET 2006 - sbrabec@suse.cz + +- README.SUSE fixes (Marius Tomaschewski). +- Init script fix. +- Install all driver manual pages. +- Use new powersave-notify path. + +------------------------------------------------------------------- +Wed Mar 15 18:01:35 CET 2006 - sbrabec@suse.cz + +- Build all available drivers. + +------------------------------------------------------------------- +Tue Mar 14 19:31:14 CET 2006 - sbrabec@suse.cz + +- Improved README.SUSE and predefined configuration. +- Checks and fixes in the init script. +- Improved notify flags, integrate with powersave. + (Some fixes provided by Marius Tomaschewski.) + +------------------------------------------------------------------- +Fri Mar 10 17:25:00 CET 2006 - sbrabec@suse.cz + +- Fixed memset error in upsrw.c. +- Fixed upsmon typo in the init script. +- Preconfigure upsd with one local UPS as default. + +------------------------------------------------------------------- +Thu Mar 9 19:01:50 CET 2006 - sbrabec@suse.cz + +- Updated to version 2.0.3. +- Removed SuSEconfig, wrote new init script + (#27721, #141948, #156614). + +------------------------------------------------------------------- +Mon Feb 20 15:27:51 CET 2006 - mmarek@suse.cz + +- fix array index out of range + [#133610] (overflow.patch) + +------------------------------------------------------------------- +Wed Jan 25 21:38:51 CET 2006 - mls@suse.de + +- converted neededforbuild to BuildRequires + +------------------------------------------------------------------- +Thu Jan 12 20:23:43 CET 2006 - sbrabec@suse.cz + +- Updated to version 2.0.3-pre2. + +------------------------------------------------------------------- +Wed Nov 2 23:04:50 CET 2005 - dmueller@suse.de + +- don't build as root + +------------------------------------------------------------------- +Mon Aug 1 15:58:42 CEST 2005 - sbrabec@suse.cz + +- Updated to version 2.0.2. + +------------------------------------------------------------------- +Fri Jan 21 15:48:35 CET 2005 - sbrabec@suse.cz + +- Updated to version 2.0.1-pre4. + +------------------------------------------------------------------- +Mon Aug 23 15:17:12 CEST 2004 - sbrabec@suse.cz + +- Updated to version 2.0.0. + +------------------------------------------------------------------- +Mon Apr 19 01:45:49 CEST 2004 - ro@suse.de + +- build with apache2 + +------------------------------------------------------------------- +Wed Apr 14 08:23:44 CEST 2004 - aj@suse.de + +- build without kernel-source. + +------------------------------------------------------------------- +Tue Mar 23 14:53:43 CET 2004 - sbrabec@suse.cz + +- Force-define HID_MAX_USAGES (kernel 2.6.4 include file bug, should + be fixed in later kernels). + +------------------------------------------------------------------- +Mon Feb 09 16:24:35 CET 2004 - sbrabec@suse.cz + +- Updated to version 1.4.1. + +------------------------------------------------------------------- +Thu Oct 2 11:14:28 CEST 2003 - stark@suse.de + +- adapted pre-configuration and startscript to reflect changes + in 1.4.0 +- changed file-permissions + +------------------------------------------------------------------- +Mon Sep 29 13:13:17 CEST 2003 - stark@suse.de + +- update to 1.4.0 + +------------------------------------------------------------------- +Tue Aug 19 11:29:46 CEST 2003 - mmj@suse.de + +- Add sysconfig metadata [#28939] + +------------------------------------------------------------------- +Thu Jun 26 13:54:30 CEST 2003 - stark@suse.de + +- update to 1.2.2 +- removed config-check in init-script + +------------------------------------------------------------------- +Fri Jun 20 23:45:07 CEST 2003 - ro@suse.de + +- added directories to filelist + +------------------------------------------------------------------- +Tue May 13 15:02:19 CEST 2003 - mmj@suse.de + +- use %defattr + +------------------------------------------------------------------- +Thu Feb 20 19:53:03 CET 2003 - mmj@suse.de + +- Add sysconfig metadata [#22688] + +------------------------------------------------------------------- +Tue Aug 6 10:53:57 CEST 2002 - olh@suse.de + +- use X-UnitedLinux-Should-Start + +------------------------------------------------------------------- +Mon Aug 5 14:30:12 CEST 2002 - olh@suse.de + +- Required-start: setserial, add Prereq + +------------------------------------------------------------------- +Fri Aug 2 01:06:47 CEST 2002 - ro@suse.de + +- adapt server-root + +------------------------------------------------------------------- +Sat Jul 27 21:52:59 CEST 2002 - kukuk@suse.de + +- fix SuSEconfig.nut: + - don't include rc.config [Bug #17267] + - use correct path to sysconfig directory + +------------------------------------------------------------------- +Fri Jul 26 23:03:11 CEST 2002 - adrian@suse.de + +- fix neededforbuild + +------------------------------------------------------------------- +Tue May 28 15:20:18 CEST 2002 - stark@suse.de + +- update to 0.50.0 +- changed init-script to use upsdrvctl + (make it possible to change config-files manually without + changing /etc/sysconfig/smartups) + +------------------------------------------------------------------- +Tue Apr 9 12:35:40 CEST 2002 - stark@suse.de + +- update to 0.45.5 +- fixed SuSEconfig.nut to sysconfig scheme + +------------------------------------------------------------------- +Fri Feb 1 00:26:13 CET 2002 - ro@suse.de + +- changed neededforbuild to + +------------------------------------------------------------------- +Sat Jan 12 11:02:37 CET 2002 - stark@suse.de + +- little ifarch fix again :-( + +------------------------------------------------------------------- +Fri Jan 11 09:54:37 CET 2002 - stark@suse.de + +- changed rc.config.d leftover in rcups +- build hidups on all archs excluding s390 (finally) + +------------------------------------------------------------------- +Tue Jan 8 10:19:59 CET 2002 - stark@suse.de + +- build hidups only on i386 + +------------------------------------------------------------------- +Thu Jan 3 11:00:43 CET 2002 - stark@suse.de + +- build hidups driver for EXPERIMENTAL USB usage + +------------------------------------------------------------------- +Wed Dec 12 09:46:49 CET 2001 - stark@suse.de + +- updated to 0.45.3 +- removed START_SMARTUPS +- renamed package to nut +- b2zipped sources +- moved rc.config.d/smartups.rc.config -> sysconfig/smartups + +------------------------------------------------------------------- +Mon Oct 22 09:16:58 CEST 2001 - stark@suse.de + +- fixed init-script to POWERDOWN correctly (#11909) +- added rc.config variable UPSLOG_INTERVAL + +------------------------------------------------------------------- +Tue Sep 18 07:24:17 CEST 2001 - stark@suse.de + +- changed STATEPATH to /var/lib/ups according to FHS (#8678) + +------------------------------------------------------------------- +Fri Sep 7 11:40:27 CEST 2001 - stark@suse.de + +- added Conflicts: apcupsd + (/usr/local/httpd/cgi-bin/multimon.cgi is in both packages) + +------------------------------------------------------------------- +Mon Sep 3 10:17:32 CEST 2001 - stark@suse.de + +- added a patch to be able to write the POWERDOWNFLAG to + only-root-writable directories + +------------------------------------------------------------------- +Mon Aug 13 11:26:17 CEST 2001 - stark@suse.de + +- update to 0.45.1 + +------------------------------------------------------------------- +Mon Jun 18 09:12:25 CEST 2001 - stark@suse.de + +- update to 0.45.0 + +------------------------------------------------------------------- +Fri Apr 27 12:29:36 CEST 2001 - stark@suse.de + +- minor changes in init-script to avoid premature aborts + +------------------------------------------------------------------- +Thu Apr 19 07:44:34 CEST 2001 - stark@suse.de + +- minor changes on %config-files and %clean +- changed upsd-exec-group to uucp +- added libjpeg freetype2 freetype2-devel xf86 + to neededforbuild + +------------------------------------------------------------------- +Tue Apr 17 09:11:58 CEST 2001 - stark@suse.de + +- init-script cleanup: try-restart and exitcodes + +------------------------------------------------------------------- +Fri Mar 23 10:18:32 CET 2001 - stark@suse.de + +- update to 0.44.3 + +------------------------------------------------------------------- +Fri Mar 16 09:17:56 CET 2001 - stark@suse.de + +- minor changes in init-script and documentation + +------------------------------------------------------------------- +Thu Jan 4 09:31:34 CET 2001 - stark@suse.de + +- update to 0.44.2 + +------------------------------------------------------------------- +Thu Dec 14 08:26:53 CET 2000 - stark@suse.de + +- fixed case in rc-script +- move SuSE scripts and configs out of the diff +- minor changes in config for insserv (use macros) + +------------------------------------------------------------------- +Mon Nov 27 12:41:28 CET 2000 - stark@suse.de + +- moved /sbin/init.d -> /etc/init.d + +------------------------------------------------------------------- +Fri Nov 24 08:26:23 CET 2000 - stark@suse.de + +- init script more LSB compliant + +------------------------------------------------------------------- +Wed Nov 22 09:54:41 CET 2000 - stark@suse.de + +- improved runlevel position +- spec now uses %{_tmppath} + +------------------------------------------------------------------- +Tue Nov 21 10:04:07 CET 2000 - stark@suse.de + +- removed runlevel-links from spec-file and moved to insserv +- added init information to rc-script + +------------------------------------------------------------------- +Mon Nov 20 11:15:26 CET 2000 - stark@suse.de + +- minor changes in rc-script (status) + +------------------------------------------------------------------- +Wed Nov 15 18:29:49 CET 2000 - ro@suse.de + +- fixed neededforbuild gdlib -> gd gd-devel + +------------------------------------------------------------------- +Thu Nov 9 10:00:17 CET 2000 - ro@suse.de + +- neededforbuild gd -> perl-GD + +------------------------------------------------------------------- +Wed Nov 8 12:31:00 CET 2000 - stark@suse.de + +- adapted rc-script to use rc.status + +------------------------------------------------------------------- +Thu Oct 5 13:46:46 CEST 2000 - stark@suse.de + +- fixed typo in SuSEconfig.smartups + +------------------------------------------------------------------- +Mon Sep 18 10:27:20 CEST 2000 - stark@suse.de + +- update to 0.44.1 +- new spec-file (with buildroot etc.) +- fixed rc-script for server/client +- added SuSEconfig.smartups + +------------------------------------------------------------------- +Thu Sep 14 13:16:49 CEST 2000 - stark@suse.de + +- fixed rc-script (added . /etc/rc.config) + +------------------------------------------------------------------- +Tue Jul 11 20:47:27 CEST 2000 - lemsi@suse.de + +- bugfix in ups start-script +- changed /etc/rc.config to /etc/rc.config.d/smartups.rc.config + +------------------------------------------------------------------- +Mon Feb 28 15:30:35 CET 2000 - kukuk@suse.de + +- Move most variables from rc.config -> rc.config.d + +------------------------------------------------------------------- +Thu Feb 24 10:08:44 CET 2000 - lemsi@suse.de + +- new version +- the orginal source is renamed, new name is nut-0.XX.X.tar.gz +- added 2 new variables in rc.config; GENERICUPS_MODEL; SMARTUPS_MASTER +- model check in rcups for genericups +- starting all 4 deamons in rcups +- new binary-installpath /usr/sbin +------------------------------------------------------------------- +Wed Nov 10 12:29:40 CET 1999 - ro@suse.de + +- fixed postinstall: (its post and not pre) + +------------------------------------------------------------------- +Tue Oct 26 15:19:09 CEST 1999 - lemsi@suse.de + +- added 2 new variables in rc.config; SMARTUPS_DEVICE; SMARTUPS_MODEL +- modified rcups and smartups.spec +- sending mail after instalation +------------------------------------------------------------------- +Fri Oct 15 02:02:34 CEST 1999 - ro@suse.de + +- added libpng to neededforbuild (now needed for libgd) + +------------------------------------------------------------------- +Fri Oct 15 00:26:28 CEST 1999 - ro@suse.de + +- fixed patch arg + +------------------------------------------------------------------- +Thu Oct 14 16:45:15 CEST 1999 - ray@suse.de + +- new package diff --git a/nut.spec b/nut.spec new file mode 100644 index 0000000..784c1f4 --- /dev/null +++ b/nut.spec @@ -0,0 +1,472 @@ +# +# spec file for package nut (Version 2.0.4) +# +# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + +# norootforbuild + +Name: nut +BuildRequires: apache2-devel gd-devel libusb net-snmp-devel openssl-devel tcpd-devel +%if %suse_version > 1000 +BuildRequires: dbus-1 +%endif +License: GPL +Group: Hardware/UPS +Provides: smartups +Requires: /usr/bin/pgrep /usr/bin/pkill /usr/bin/grep /usr/bin/fgrep /usr/sbin/lsusb /usr/bin/readlink +%if %suse_version > 1000 +Requires: powersave +%endif +Obsoletes: smartups +Conflicts: apcupsd +Autoreqprov: on +Summary: UPS Monitoring Software +Version: 2.0.4 +Release: 3 +URL: http://www.networkupstools.org/ +Source: %{name}-%{version}.tar.bz2 +Source1: upsd.init +Source2: README.SUSE +Source3: upsd-early-powerdown.init +Source4: upsd.dbus-1 +Patch: nut-preconfig.patch +Patch1: %{name}-%{version}-overflow.patch +Patch3: nut-notifyflag.patch +Patch4: nut-powersave.patch +BuildRoot: %{_tmppath}/%{name}-%{version}-build +PreReq: %insserv_prereq /bin/chown /bin/chmod /usr/bin/fgrep /usr/bin/grep /usr/bin/sed /usr/bin/head /usr/bin/md5sum +%define apache_serverroot %(/usr/sbin/apxs2 -q datadir 2>/dev/null || /usr/sbin/apxs -q PREFIX) +%define CGIPATH %{apache_serverroot}/cgi-bin +%define MODELPATH /usr/lib/ups/driver +%define STATEPATH /var/lib/ups +%define CONFPATH %{_sysconfdir}/ups +%define USER upsd + +%description +This is a developing project to monitor a large assortment of UPS +hardware. Many models have ports on the back to allow other devices to +check the status. If it gives basic information about the power and +battery status, it can probably be supported without too much +difficulty. More advanced features on the higher-end models are also +supported to allow tracking of values over time such as temperature and +voltage. + +Network communications are used so that multiple systems can monitor a +single physical UPS and shut down together if necessary without any +special "sharing hardware" on the UPS itself. Detailed information +about supported hardware can be found in +/usr/share/doc/packages/nut/README. + + +_=====_ + + +- APC Smart-UPS, Back-UPS Pro, Matrix-UPS, Belkin Regulator Pro, + Best Power Fortress, Fortress (FOR), Fortress Telecom (FTC), + Patriot Pro (PRO), Patriot Pro II (PR2), Engetron Jr, Fenton + Technologies PowerPal, PowerOn, PowerPure, Effekta MI/MT/MH + models (2502 cable), PowerGuard PG-600, IPT Anzen, MGE Pulsar, + MGE Pulsar/Comet/Galaxy, Mustek Electronics, Opti-UPS, Advice + Partner/King, PowerCom, Toshiba 1500 series, Trust (KingPro) + 425/625, Microdowell BBox, IMV/Victron + +- Many models that use the same basic principle to communicate with the +computer. See generic-ups.txt in /usr/share/doc/packages/nut for more +information, including a list of supported equipment. + + + +Authors: +-------- + Russell Kroll + Arnaud Quette + Arjen de Korte + Fabio Di Niro + +%prep +%setup +cp -a %{S:1} %{S:2} %{S:3} %{S:4} . +mv upsd-early-powerdown.init upsd-early-powerdown +%patch +%patch1 +%patch3 +%if %suse_version > 1000 +%patch4 +%endif +USB_IDS=$(sed -n 1000 +mkdir -p $RPM_BUILD_ROOT/etc/dbus-1/system.d +install -m 644 upsd.dbus-1 $RPM_BUILD_ROOT/etc/dbus-1/system.d/upsd.conf +%endif + +%pre +# 2>/dev/null +usr/sbin/useradd -r -o -g daemon -s /bin/false \ + -c "UPS daemon" -d /sbin %USER 2>/dev/null || : + +%post +%{fillup_and_insserv -f -n upsd} +# Generate initial passwords. +if usr/bin/fgrep -q "password = @UPSD_INITIAL_MASTER_PASSWORD@" %{CONFPATH}/{upsmon.conf,upsd.users} ; then + UPSD_INITIAL_MASTER_PASSWORD=$(usr/bin/head -c 20 /dev/urandom | usr/bin/md5sum | usr/bin/head -c 10) + usr/bin/sed -i s/@UPSD_INITIAL_MASTER_PASSWORD@/$UPSD_INITIAL_MASTER_PASSWORD/ %{CONFPATH}/{upsmon.conf,upsd.users} +fi +if usr/bin/fgrep -q "password = @UPSD_INITIAL_SLAVE_PASSWORD@" %{CONFPATH}/upsd.users ; then + UPSD_INITIAL_SLAVE_PASSWORD=$(usr/bin/head -c 20 /dev/urandom | usr/bin/md5sum | usr/bin/head -c 10) + usr/bin/sed -i s/@UPSD_INITIAL_SLAVE_PASSWORD@/$UPSD_INITIAL_SLAVE_PASSWORD/ %{CONFPATH}/upsd.users +fi +# Be sure that all files are owned by a dedicated user. +bin/chown -R %USER:root %STATEPATH +bin/chown %USER:root %{CONFPATH}/upsd.conf %{CONFPATH}/upsmon.conf %{CONFPATH}/upsd.users +bin/chmod 600 %{CONFPATH}/upsd.conf %{CONFPATH}/upsmon.conf %{CONFPATH}/upsd.users +# Install HALT_POWERDOWN_INSERT +%if %suse_version > 1000 +if usr/bin/grep -q '^HALT_POWERDOWN_INSERT="\(/etc/init\.d/upsd try-powerdown\|\)"' etc/sysconfig/shutdown ; then + usr/bin/sed -i 's:^\(HALT_POWERDOWN_INSERT="\).*"[[:space:]]*:\1/etc/init.d/upsd try-powerdown":' etc/sysconfig/shutdown +else + echo >&2 "nut: WARNING: Unknown value of HALT_POWERDOWN_INSERT in /etc/sysconfig/shutdown." + echo >&2 " Keeping unchanged. Should be:" + echo >&2 "HALT_POWERDOWN_INSERT=\"/etc/init.d/upsd try-powerdown\"" +fi +%endif +# Silently remove /etc/sysconfig/smartups. File is now obsolete and +# values are copied to not replaced config files. +# /etc/sysconfig/smartups was last present in SuSE Linux 10.0 +rm -f /etc/sysconfig/smartups + +%preun +%{stop_on_removal upsd} + +%postun +%{restart_on_update upsd} +# Remove HALT_POWERDOWN_INSERT +%if %suse_version > 1000 +if test $1 -eq 0 -a ! -f /etc/init.d/upsd ; then + if usr/bin/grep -q '^HALT_POWERDOWN_INSERT="/etc/init\.d/upsd try-powerdown"' etc/sysconfig/shutdown ; then + usr/bin/sed -i 's:^\(HALT_POWERDOWN_INSERT="\)/etc/init\.d/upsd try-powerdown":\1":' etc/sysconfig/shutdown + else + echo >&2 "nut: WARNING: Unknown value of HALT_POWERDOWN_INSERT in /etc/sysconfig/shutdown." + echo >&2 " Keeping unchanged. Should be:" + echo >&2 "HALT_POWERDOWN_INSERT=\"\"" + fi + if test -f /etc/init.d/upsd-early-powerdown ; then + echo >&2 "nut: WARNING: You may want to remove your /etc/init.d/upsd-early-powerdown." + fi +fi +%endif +%insserv_cleanup + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%defattr(-,root,root) +%doc docs/ CHANGES COPYING CREDITS INSTALL MAINTAINERS NEWS README README.SUSE UPGRADING upsd-early-powerdown +%doc %{_mandir}/man8/* +%doc %{_mandir}/man5/* +%dir %{CONFPATH} +%config(noreplace) %{CONFPATH}/hosts.conf +%config(noreplace) %attr(600,%{USER},root) %{CONFPATH}/upsd.conf +%config(noreplace) %attr(600,%{USER},root) %{CONFPATH}/upsd.users +%config(noreplace) %attr(600,%{USER},root) %{CONFPATH}/upsmon.conf +%config(noreplace) %{CONFPATH}/ups.conf +%config(noreplace) %{CONFPATH}/upsset.conf +%config(noreplace) %{CONFPATH}/upssched.conf +%config(noreplace) %{CONFPATH}/upsstats-single.html +%config(noreplace) %{CONFPATH}/upsstats.html +/etc/init.d/upsd +%if %suse_version > 1000 +/etc/dbus-1/system.d/upsd.conf +%endif +%dir %attr(700,%{USER},nogroup) %{STATEPATH} +%dir /usr/lib/ups +%{MODELPATH} +/usr/bin/* +/usr/sbin/* +%dir /usr/share/nut +/usr/share/nut/* +%{CGIPATH}/upsimage.cgi +%{CGIPATH}/upsstats.cgi +%{CGIPATH}/upsset.cgi +%attr(700,%{USER},root) %STATEPATH + +%changelog -n nut +* Mon Sep 18 2006 - anosek@suse.cz +- fixed compiler warning: array subscript out of range [#204417] + (overflow.patch) +* Fri Sep 01 2006 - anosek@suse.cz +- updated to 2.0.4 + * A bug has been fixed in NUT core to support resuming from + suspend-to-disk. This should also fix other similar issues, + like time synchronisation through the NTP. + * The mge-shut driver now better detects the Low Battery status, + support new models and fixes some wrong status and data. + It also fixes some issue where the UPS wasn't restarting + (refer to mge-shut manpage). + * The genericups custom configuration through ups.conf + is working again + * The genericups driver type 22 also support CyberPower 725SL + (and maybe others SL models) + * The new megatec driver, which will replace a bunch of drivers + by nut 2.2 (refer to docs/megatec.txt and UPGRADING) has been + backported from the trunk (Development tree). The powermust + driver has also received some attention. + * The new rhino driver was added to support Microsol Rhino UPS + hardware. The solis has also been improved for solaris + compatibility, and internal / external shutdown programming. + Solis can now save external shutdown programming to ups, + and support new cables for solis 3 +- dropped obsolete patch (nut-2.0.4-memset.patch) +- fixed subscript out of range [#185610] (overflow.patch) +* Fri Jun 23 2006 - sbrabec@suse.cz +- Typo fix in the init script. +* Thu Apr 27 2006 - sbrabec@suse.cz +- Work correctly, if port is a symlink (168611#c6). +* Tue Apr 25 2006 - sbrabec@suse.cz +- Fixed init script to behave correctly for port = auto (#168611). +* Fri Mar 24 2006 - sbrabec@suse.cz +- Typo fixes. +* Tue Mar 21 2006 - sbrabec@suse.cz +- Added D-BUS policy file (#159668). +* Mon Mar 20 2006 - sbrabec@suse.cz +- Support for UPS powerdown using HALT_POWERDOWN_INSERT. +- Added upsd-early-powerdown template and improved README.SUSE. +- Remove obsolete /etc/sysconfig/smartups in %%post. +* Fri Mar 17 2006 - sbrabec@suse.cz +- README.SUSE fixes (Marius Tomaschewski). +- Init script fix. +- Install all driver manual pages. +- Use new powersave-notify path. +* Wed Mar 15 2006 - sbrabec@suse.cz +- Build all available drivers. +* Tue Mar 14 2006 - sbrabec@suse.cz +- Improved README.SUSE and predefined configuration. +- Checks and fixes in the init script. +- Improved notify flags, integrate with powersave. + (Some fixes provided by Marius Tomaschewski.) +* Fri Mar 10 2006 - sbrabec@suse.cz +- Fixed memset error in upsrw.c. +- Fixed upsmon typo in the init script. +- Preconfigure upsd with one local UPS as default. +* Thu Mar 09 2006 - sbrabec@suse.cz +- Updated to version 2.0.3. +- Removed SuSEconfig, wrote new init script + (#27721, #141948, #156614). +* Mon Feb 20 2006 - mmarek@suse.cz +- fix array index out of range + [#133610] (overflow.patch) +* Wed Jan 25 2006 - mls@suse.de +- converted neededforbuild to BuildRequires +* Thu Jan 12 2006 - sbrabec@suse.cz +- Updated to version 2.0.3-pre2. +* Wed Nov 02 2005 - dmueller@suse.de +- don't build as root +* Mon Aug 01 2005 - sbrabec@suse.cz +- Updated to version 2.0.2. +* Fri Jan 21 2005 - sbrabec@suse.cz +- Updated to version 2.0.1-pre4. +* Mon Aug 23 2004 - sbrabec@suse.cz +- Updated to version 2.0.0. +* Mon Apr 19 2004 - ro@suse.de +- build with apache2 +* Wed Apr 14 2004 - aj@suse.de +- build without kernel-source. +* Tue Mar 23 2004 - sbrabec@suse.cz +- Force-define HID_MAX_USAGES (kernel 2.6.4 include file bug, should + be fixed in later kernels). +* Mon Feb 09 2004 - sbrabec@suse.cz +- Updated to version 1.4.1. +* Thu Oct 02 2003 - stark@suse.de +- adapted pre-configuration and startscript to reflect changes + in 1.4.0 +- changed file-permissions +* Mon Sep 29 2003 - stark@suse.de +- update to 1.4.0 +* Tue Aug 19 2003 - mmj@suse.de +- Add sysconfig metadata [#28939] +* Thu Jun 26 2003 - stark@suse.de +- update to 1.2.2 +- removed config-check in init-script +* Fri Jun 20 2003 - ro@suse.de +- added directories to filelist +* Tue May 13 2003 - mmj@suse.de +- use %%defattr +* Thu Feb 20 2003 - mmj@suse.de +- Add sysconfig metadata [#22688] +* Tue Aug 06 2002 - olh@suse.de +- use X-UnitedLinux-Should-Start +* Mon Aug 05 2002 - olh@suse.de +- Required-start: setserial, add Prereq +* Fri Aug 02 2002 - ro@suse.de +- adapt server-root +* Sat Jul 27 2002 - kukuk@suse.de +- fix SuSEconfig.nut: +- don't include rc.config [Bug #17267] +- use correct path to sysconfig directory +* Fri Jul 26 2002 - adrian@suse.de +- fix neededforbuild +* Tue May 28 2002 - stark@suse.de +- update to 0.50.0 +- changed init-script to use upsdrvctl + (make it possible to change config-files manually without + changing /etc/sysconfig/smartups) +* Tue Apr 09 2002 - stark@suse.de +- update to 0.45.5 +- fixed SuSEconfig.nut to sysconfig scheme +* Fri Feb 01 2002 - ro@suse.de +- changed neededforbuild to +* Sat Jan 12 2002 - stark@suse.de +- little ifarch fix again :-( +* Fri Jan 11 2002 - stark@suse.de +- changed rc.config.d leftover in rcups +- build hidups on all archs excluding s390 (finally) +* Tue Jan 08 2002 - stark@suse.de +- build hidups only on i386 +* Thu Jan 03 2002 - stark@suse.de +- build hidups driver for EXPERIMENTAL USB usage +* Wed Dec 12 2001 - stark@suse.de +- updated to 0.45.3 +- removed START_SMARTUPS +- renamed package to nut +- b2zipped sources +- moved rc.config.d/smartups.rc.config -> sysconfig/smartups +* Mon Oct 22 2001 - stark@suse.de +- fixed init-script to POWERDOWN correctly (#11909) +- added rc.config variable UPSLOG_INTERVAL +* Tue Sep 18 2001 - stark@suse.de +- changed STATEPATH to /var/lib/ups according to FHS (#8678) +* Fri Sep 07 2001 - stark@suse.de +- added Conflicts: apcupsd + (/usr/local/httpd/cgi-bin/multimon.cgi is in both packages) +* Mon Sep 03 2001 - stark@suse.de +- added a patch to be able to write the POWERDOWNFLAG to + only-root-writable directories +* Mon Aug 13 2001 - stark@suse.de +- update to 0.45.1 +* Mon Jun 18 2001 - stark@suse.de +- update to 0.45.0 +* Fri Apr 27 2001 - stark@suse.de +- minor changes in init-script to avoid premature aborts +* Thu Apr 19 2001 - stark@suse.de +- minor changes on %%config-files and %%clean +- changed upsd-exec-group to uucp +- added libjpeg freetype2 freetype2-devel xf86 + to neededforbuild +* Tue Apr 17 2001 - stark@suse.de +- init-script cleanup: try-restart and exitcodes +* Fri Mar 23 2001 - stark@suse.de +- update to 0.44.3 +* Fri Mar 16 2001 - stark@suse.de +- minor changes in init-script and documentation +* Thu Jan 04 2001 - stark@suse.de +- update to 0.44.2 +* Thu Dec 14 2000 - stark@suse.de +- fixed case in rc-script +- move SuSE scripts and configs out of the diff +- minor changes in config for insserv (use macros) +* Mon Nov 27 2000 - stark@suse.de +- moved /sbin/init.d -> /etc/init.d +* Fri Nov 24 2000 - stark@suse.de +- init script more LSB compliant +* Wed Nov 22 2000 - stark@suse.de +- improved runlevel position +- spec now uses %%{_tmppath} +* Tue Nov 21 2000 - stark@suse.de +- removed runlevel-links from spec-file and moved to insserv +- added init information to rc-script +* Mon Nov 20 2000 - stark@suse.de +- minor changes in rc-script (status) +* Wed Nov 15 2000 - ro@suse.de +- fixed neededforbuild gdlib -> gd gd-devel +* Thu Nov 09 2000 - ro@suse.de +- neededforbuild gd -> perl-GD +* Wed Nov 08 2000 - stark@suse.de +- adapted rc-script to use rc.status +* Thu Oct 05 2000 - stark@suse.de +- fixed typo in SuSEconfig.smartups +* Mon Sep 18 2000 - stark@suse.de +- update to 0.44.1 +- new spec-file (with buildroot etc.) +- fixed rc-script for server/client +- added SuSEconfig.smartups +* Thu Sep 14 2000 - stark@suse.de +- fixed rc-script (added . /etc/rc.config) +* Tue Jul 11 2000 - lemsi@suse.de +- bugfix in ups start-script +- changed /etc/rc.config to /etc/rc.config.d/smartups.rc.config +* Mon Feb 28 2000 - kukuk@suse.de +- Move most variables from rc.config -> rc.config.d +* Thu Feb 24 2000 - lemsi@suse.de +- new version +- the orginal source is renamed, new name is nut-0.XX.X.tar.gz +- added 2 new variables in rc.config; GENERICUPS_MODEL; SMARTUPS_MASTER +- model check in rcups for genericups +- starting all 4 deamons in rcups +- new binary-installpath /usr/sbin +* Wed Nov 10 1999 - ro@suse.de +- fixed postinstall: (its post and not pre) +* Tue Oct 26 1999 - lemsi@suse.de +- added 2 new variables in rc.config; SMARTUPS_DEVICE; SMARTUPS_MODEL +- modified rcups and smartups.spec +- sending mail after instalation +* Fri Oct 15 1999 - ro@suse.de +- added libpng to neededforbuild (now needed for libgd) +* Fri Oct 15 1999 - ro@suse.de +- fixed patch arg +* Thu Oct 14 1999 - ray@suse.de +- new package diff --git a/ready b/ready new file mode 100644 index 0000000..473a0f4 diff --git a/upsd-early-powerdown.init b/upsd-early-powerdown.init new file mode 100644 index 0000000..fd22b2e --- /dev/null +++ b/upsd-early-powerdown.init @@ -0,0 +1,132 @@ +#! /bin/sh +# +# Sample script for early powerdown. Edit and copy to /etc/init.d/. See +# /usr/share/doc/packages/nut/README.SUSE for more. +# +# Copyright (c) 2006 SUSE / Novell Inc. +# All rights reserved. +# +# Author: Stanislav Brabec, 2006 +# Please send feedback to http://www.suse.de/feedback/ +# +# /etc/init.d/upsd-early-powerdown +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# System startup script for NUT UPS daemon +# +# LSB compatible service control script; see http://www.linuxbase.org/spec/ +# +### BEGIN INIT INFO +# Provides: upsd-early-powerdown +# Required-Start: +# Should-Start: FIXME scripts which should not stop before powerdown +# Required-Stop: +# Should-Stop: FIXME scripts which should stop before powerdown +# Default-Start: 3 5 +# Default-Stop: 0 1 2 6 +# Short-Description: Early UPS powerdown +# Description: Script for early, quick but incorrect power down +# while going out of batteries. You need it only if you run slowly +# stopping services and UPS battery power fails before stopping of +# these services. +### END INIT INFO +# +# Note on runlevels: +# 0 - halt/poweroff 6 - reboot +# 1 - single user 2 - multiuser without network exported +# 3 - multiuser w/ network (text mode) 5 - multiuser w/ network and X11 (xdm) +# + +# Check for existence of needed config files +UPSMON_CONFIG=/etc/ups/upsmon.conf +test -r $UPSMON_CONFIG || { echo "$UPSMON_CONFIG not existing"; + if [ "$1" = "stop" ]; then exit 0; else exit 6; fi; +} +# If this file exists, power is failing. +POWERDOWNFLAG=$(sed -n 's/^POWERDOWNFLAG[[:space:]]*//p' set local and overall rc status to +# rc_reset clear both the local and overall rc status +# rc_exit exit appropriate to overall rc status +# rc_active checks whether a service is activated by symlinks +. /etc/rc.status + +# Reset status of this service +rc_reset + +# Return values acc. to LSB for all commands but status: +# 0 - success +# 1 - generic or unspecified error +# 2 - invalid or excess argument(s) +# 3 - unimplemented feature (e.g. "reload") +# 4 - user had insufficient privileges +# 5 - program is not installed +# 6 - program is not configured +# 7 - program is not running +# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl) +# +# Note that starting an already running service, stopping +# or restarting a not-running service as well as the restart +# with force-reload (in case signaling is not supported) are +# considered a success. + +case "$1" in + start|probe) + ## Start silently. No action. + ;; + stop) + # If power is failing and shutdown is running, shutdown as fast as possible. + if test "$RUNLEVEL" = "0" -a -n "$POWERDOWNFLAG " -a -f "$POWERDOWNFLAG" ; then + echo "Initiating early UPS power down..." + echo "Power is failing. Running fast shutdown." + echo "Sending all processes the TERM signal..." + killall5 -15 + sleep 3 + echo "Sending all processes the KILL signal..." + killall5 -9 + echo "Remounting filesystems read-only." + mounts=/etc/fstab + test -r /proc/mounts && mounts=/proc/mounts + while read des fs rest; do + mount -v -n -o remount,ro $fs + done < $mounts + /etc/init.d/upsd powerdown + fi + ;; + restart|try-restart|condrestart|force-reload|reload) + # Unimplemented. + rc_failed 3 + rc_status -v + ;; + status) + # Service status unknown. + rc_failed 4 + rc_status -v + ;; + *) + echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}" + exit 1 + ;; +esac +rc_exit diff --git a/upsd.dbus-1 b/upsd.dbus-1 new file mode 100644 index 0000000..9e7474d --- /dev/null +++ b/upsd.dbus-1 @@ -0,0 +1,9 @@ + + + + + + + diff --git a/upsd.init b/upsd.init new file mode 100644 index 0000000..e51cf56 --- /dev/null +++ b/upsd.init @@ -0,0 +1,372 @@ +#! /bin/sh +# Copyright (c) 1995-2006 SUSE / Novell Inc. +# All rights reserved. +# +# Author: Frank Lemser +# Wolfgang Rosenauer, 2000-2003 +# Arjen de Korte, 2006 +# Stanislav Brabec, 2006 +# Please send feedback to http://www.suse.de/feedback/ +# +# /etc/init.d/upsd +# and its symbolic link +# /(usr/)sbin/rcupsd +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# System startup script for NUT UPS daemon +# +# LSB compatible service control script; see http://www.linuxbase.org/spec/ +# +### BEGIN INIT INFO +# Provides: ups +# Required-Start: $network $syslog $remote_fs +# Should-Start: $time ypbind sendmail +# Required-Stop: $network $syslog $remote_fs +# Should-Stop: $time ypbind sendmail +# Default-Start: 3 5 +# Default-Stop: 0 1 2 6 +# Short-Description: UPS monitoring software (remote/local) +# Description: Network UPS Tools provides remote or local +# monitoring of UPS. +### END INIT INFO +# +# Note on runlevels: +# 0 - halt/poweroff 6 - reboot +# 1 - single user 2 - multiuser without network exported +# 3 - multiuser w/ network (text mode) 5 - multiuser w/ network and X11 (xdm) +# + +DRIVER_BIN=/usr/lib/ups/driver +DRIVER_RUN=/var/lib/ups + +# Location of upsd.pid file: +UPSD_PID=${DRIVER_RUN}/upsd.pid + +# Check for missing binaries (stale symlinks should not happen) +# Note: Special treatment of stop for LSB conformance +UPSD_BIN=/usr/sbin/upsd +UPSMON_BIN=/usr/sbin/upsmon +UPSDRVCTL_BIN=$DRIVER_BIN/upsdrvctl +test -x $UPSD_BIN || { echo "$UPSD_BIN not installed"; + if [ "$1" = "stop" ]; then exit 0; + else exit 5; fi; } +test -x $UPSMON_BIN || { echo "$UPSMON_BIN not installed"; + if [ "$1" = "stop" ]; then exit 0; + else exit 5; fi; } +test -x $UPSDRVCTL_BIN || { echo "$UPSDRVCTL_BIN not installed"; + if [ "$1" = "stop" ]; then exit 0; + else exit 5; fi; } + +# Check for existence of needed config files +UPS_CONFIG=/etc/ups/ups.conf +UPSD_CONFIG=/etc/ups/upsd.conf +UPSMON_CONFIG=/etc/ups/upsmon.conf +test -r $UPS_CONFIG || { echo "$UPS_CONFIG not existing"; + if [ "$1" = "stop" ]; then exit 0; else exit 6; fi; +} +test -r $UPSD_CONFIG || { echo "$UPSD_CONFIG not existing"; + if [ "$1" = "stop" ]; then exit 0; else exit 6; fi; +} +test -r $UPSMON_CONFIG || { echo "$UPSMON_CONFIG not existing"; + if [ "$1" = "stop" ]; then exit 0; else exit 6; fi; +} +# verify, that we have at least a configured monitor +grep -q '^MONITOR' $UPSMON_CONFIG || { + echo "$UPSMON_CONFIG not configured"; + if [ "$1" = "stop" ]; then exit 0; else exit 6; fi; +} +# verify, that user configured ups.conf. +if grep -q '^[[:space:]][[:space:]]*driver[[:space:]]*=[[:space:]]*undefined' $UPS_CONFIG ; then + echo "$UPS_CONFIG not configured, see /usr/share/doc/packages/nut/README.SUSE"; + if [ "$1" = "stop" ]; then exit 0; else exit 6; fi; +fi + +# Preconfigured user ID of UPS devices. +UPSD_USER="@UPSD_USER@" + +# Owner of UPS port devices (empty to skip device check): +UPS_OWNER="$UPSD_USER:root" + +# If this file exists, power is failing. +POWERDOWNFLAG=$(sed -n 's/^POWERDOWNFLAG[[:space:]]*//p' set local and overall rc status to +# rc_reset clear both the local and overall rc status +# rc_exit exit appropriate to overall rc status +# rc_active checks whether a service is activated by symlinks +. /etc/rc.status + +# Reset status of this service +rc_reset + +# Return values acc. to LSB for all commands but status: +# 0 - success +# 1 - generic or unspecified error +# 2 - invalid or excess argument(s) +# 3 - unimplemented feature (e.g. "reload") +# 4 - user had insufficient privileges +# 5 - program is not installed +# 6 - program is not configured +# 7 - program is not running +# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl) +# +# Note that starting an already running service, stopping +# or restarting a not-running service as well as the restart +# with force-reload (in case signaling is not supported) are +# considered a success. + +case "$1" in + start) + test -n "$POWERDOWNFLAG" && rm -f "$POWERDOWNFLAG" + if grep -q '^\[' $UPS_CONFIG ; then + # Read current user in the config: + USER=$(sed -n 's/^[[:space:]]*user[[:space:]]*=[[:space:]]*//p' < $UPS_CONFIG) + if test -n "$USER" ; then + UPS_OWNER="$USER:root" + UPSD_USER="$USER" + fi + + if test -n "$UPS_OWNER" ; then + PORTS=$(sed -n 's/^[[:space:]][[:space:]]*port[[:space:]]*=[[:space:]]*//p' < $UPS_CONFIG) + ## Change permissions of devices. + for PORT in $PORTS ; do + if test "$PORT" = auto ; then + PORT=$(LANG=C LC_ALL=C lsusb | grep '\(@USB_IDS@\)' | sed 's:^:/dev/bus/usb/:;s/Bus //;s/ Device /\//;s/: .*//') + if test -z "$PORT" ; then + echo -n "$0: no device for \"port = auto\" in $UPS_CONFIG" + rc_failed 1 ; rc_status -v ; rc_exit + fi + fi + if test -L "$PORT" ; then + PORT=$(readlink -f $PORT) + fi + if test -n "$PORT" && test -c "$PORT" ; then + chown $UPS_OWNER $PORT || { rc_failed ; rc_status -v ; rc_exit ; } + else + echo -n "$0: invalid $PORT in $UPS_CONFIG" + rc_failed 2 ; rc_status -v ; rc_exit + fi + done + fi + + echo -n "Starting NUT UPS drivers " + # Do not start upsdrvctl more times. + if ! test -f /var/run/upsdrvctl ; then + ## Start daemon with startproc(8). If this fails + ## the return value is set appropriately by startproc. + $UPSDRVCTL_BIN start >/dev/null 2>&1 || rc_failed + # Remember status and be verbose + rc_status -v || rc_exit + touch /var/run/upsdrvctl + else + rc_status -s ; rc_reset + fi + + echo -n "Starting NUT UPS server " + ## Start daemon with startproc(8). If this fails + ## the return value is set appropriately by startproc. + startproc -q -p $UPSD_PID $UPSD_BIN ${UPSD_USER:+-u $UPSD_USER} || { + rc=$? + $UPSDRVCTL_BIN stop >/dev/null 2>&1 + rc_failed $rc + } + # Remember status and be verbose + rc_status -v || rc_exit + fi + + echo -n "Starting NUT UPS monitor " + ## Start daemon with startproc(8). If this fails + ## the return value is set appropriately by startproc. + /sbin/startproc -q $UPSMON_BIN + + # Remember status and be verbose + rc_status -v + ;; + stop) + echo -n "Shutting down NUT UPS monitor " + ## Stop daemon with killproc(8) and if this fails + ## killproc sets the return value according to LSB. + /sbin/killproc -TERM $UPSMON_BIN + # Remember status and be verbose + rc_status -v + + echo -n "Shutting down NUT UPS server " + ## Stop daemon with killproc(8) and if this fails + ## killproc sets the return value according to LSB. + killproc -TERM -p $UPSD_PID $UPSD_BIN + # Remember status and be verbose + rc_status -v + + # NOTE: Command should return OK, if no drivers are running. + # WARNING: There is no chance to stop daemons after ups.conf change! + # (except of some sort of find for pid's in ${DRIVER_RUN} dir ) + echo -n "Shutting down NUT UPS drivers" + $UPSDRVCTL_BIN stop >/dev/null 2>&1 || : + # Remember status and be verbose + FAILED=true + for (( n=0 ; n<10 ; n++ )) ; do + if ! pgrep >/dev/null -f /usr/lib/ups/driver ; then + echo -n " " + FAILED=false + break + fi + sleep 1 + echo -n "." + done + if $FAILED ; then + # Try again with pkill. Maybe configuration was changed. + # Drivers are not properly terminated after configuration + # change. + for (( n=0 ; n<10 ; n++ )) ; do + if ! pkill -TERM >/dev/null -f /usr/lib/ups/driver ; then + echo -n " " + FAILED=false + break + fi + sleep 1 + echo -n "." + done + fi + if $FAILED ; then + rc_failed + fi + rm -f /var/run/upsdrvctl + rc_status -v + ;; + try-restart|condrestart) + ## Do a restart only if the service was active before. + ## Note: try-restart is now part of LSB (as of 1.9). + ## RH has a similar command named condrestart. + if test "$1" = "condrestart"; then + echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}" + fi + $0 status + if test $? = 0; then + $0 restart + else + rc_reset # Not running is not a failure. + fi + # Remember status and be quiet + rc_status + ;; + restart) + ## Stop the service and regardless of whether it was + ## running or not, start it again. + $0 stop + $0 start + + # Remember status and be quiet + rc_status + ;; + force-reload) + ## Signal the daemon to reload its config. Most daemons + ## do this on signal 1 (SIGHUP). + echo -n "Reload service NUT UPS " + ## if it supports it: + $UPSDRVCTL_BIN stop >/dev/null 2>&1 || : + $UPSDRVCTL_BIN start >/dev/null 2>&1 || : + /sbin/killproc -HUP -p $UPSD_PID $UPSD_BIN + /sbin/killproc -HUP $UPSMON_BIN + rc_status -v + ;; + reload) + ## Signal the daemon to reload its config. Most daemons + ## do this on signal 1 (SIGHUP). + # WARNING: upsdrvctl does not support reload! + # Use force-reload unstead. + echo -n "Reload service NUT UPS (excluding upsdrvctl) " + ## if it supports it: + /sbin/killproc -HUP -p $UPSD_PID $UPSD_BIN + /sbin/killproc -HUP $UPSMON_BIN + rc_status -v + ;; + status) + ## Check status with checkproc(8), if process is running + ## checkproc will return with exit status 0. + + # Return value is slightly different for the status command: + # 0 - service up and running + # 1 - service dead, but /var/run/ pid file exists + # 2 - service dead, but /var/lock/ lock file exists + # 3 - service not running (unused) + # 4 - service status unknown :-( + # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.) + + # NOTE: checkproc returns LSB compliant status values. + # NOTE: rc_status knows that we called this init script with + # "status" option and adapts its messages accordingly. + + echo -n "Checking for service NUT UPS server " + /sbin/checkproc -p $UPSD_PID $UPSD_BIN + # show & reset status - we need the status from monitor for + # try-restart in case that only the monitor is running. + rc_status -v -r + + echo -n "Checking for service NUT UPS monitor " + /sbin/checkproc $UPSMON_BIN + rc_status -v + ;; + probe) + ## Optional: Probe for the necessity of a reload, print out the + ## argument to this init script which is required for a reload. + ## Note: probe is not (yet) part of LSB (as of 1.9) + if test -f $UPSD_PID && test $UPS_CONFIG -nt $UPSD_PID ; then + echo reload + elif test -f $UPSD_PID && test $UPSD_CONFIG -nt $UPSD_PID ; then + echo reload + elif test -f $UPSD_PID && test /etc/ups/upsd.users -nt $UPSD_PID ; then + echo reload + elif test -f /var/run/upsmon.pid && test $UPS_CONFIG -nt /var/run/upsmon.pid ; then + echo reload + elif test -f /var/run/upsmon.pid && test $UPSMON_CONFIG -nt /var/run/upsmon.pid ; then + echo reload + elif test -f /var/run/upsmon.pid && test /etc/ups/upsd.users -nt /var/run/upsmon.pid ; then + echo reload + fi + ;; + powerdown) + ## Special command: Instruct UPS to shutdown. + sync & + if grep -q '^\[' $UPS_CONFIG ; then + echo -n "Instructing UPS to powerdown " + $UPSDRVCTL_BIN shutdown >/dev/null 2>&1 || rc_failed + rc_check + else + echo "No local UPS defined, skipping powerdown " + fi + rc_status -v + ;; + try-powerdown) + ## Special command: Instruct UPS to shutdown, if halt is running + ## and power is failing. Otherwise silently quit. + if test "$RUNLEVEL" = "0" -a -n "$POWERDOWNFLAG" -a -f "$POWERDOWNFLAG" ; then + exec $0 powerdown + fi + ;; + *) + echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe|powerdown|try-powerdown}" + exit 1 + ;; +esac +rc_exit