Examples for setting up NUT on Crux. This is just for the captlloyd port for nut and may not be applicable to others. Suggestions or errors in this howto should be sent to captlloyd@gmail.com 1. Create a user and group for nut. In this howto I use the user nut, and UID and GID of 31 which are unused on my system. # groupadd -g 31 nut # useradd -g nut -u 31 -d /var/state/ups -s /bin/false nut # passwd -l nut 2. Make sure /var/state/ups is in the group nut and not readable by other users # chown .nut /var/state/ups # chmod 770 /var/state/ups 3. Create /etc/nut directory and appropriate config files. Make sure the config files are readable by nut and safe from other users, they contain passwords that would let someone shutdown your computer. The minimum you will need are: ups.conf, upsd.conf, upsd.users, upsmon.conf Choose the correct NUT driver for your UPS, if using a USB UPS you will need to know the vendorid and productid (found with lsusb) to setup nut and the udev rules. Examples of files in /etc/nut: ups.conf: [TEST-UPS] driver = newhidups port = auto vendorid = 0764 productid = 0501 upsd.conf: ACL all 0.0.0.0/0 ACL localhost 127.0.0.1/32 ACCEPT localhost REJECT all upsd.users: [upsmon] password = realpasswordhere allowfrom = localhost 127.0.0.1 instcmds = all actions = set upsmon master upsmon.conf: FINALDELAY 0 MINSUPPLIES 0 SHUTDOWNCMD "/sbin/shutdown -h +0" NOTIFYFLAG ONBATT SYSLOG+WALL NOTIFYFLAG ONLINE SYSLOG+WALL MONITOR TEST-UPS@127.0.0.1 1 upsmon pass_from_upsd.users master 4. Udev rules. In these sample rules I am using a USB UPS with vendorid 0764 and productid of 0501. This information can be found by running 'lsusb'. Modify to suit your needs. /etc/udev/rules.d/82-ups.rules: BUS=="usb", SYSFS{idVendor}=="0764", SYSFS{idProduct}=="0501", ACTION=="add", NAME="%k", GROUP="nut", MODE="0660" SUBSYSTEM=="usb_device", SYSFS{idVendor}=="0764", SYSFS{idProduct}=="0501", ACTION=="add", GROUP="nut", MODE="0660" 5. Allowing console notifications using wall. In the above config files messages are logged to syslog and sent to users via wall. To do this /usr/bin/wall must be setgid tty. This is not required to use NUT, but you may find it useful. # chown .tty /usr/bin/wall # chmod 2755 /usr/bin/wall 6. rc scripts for nut. /etc/rc.d/nut: #!/bin/sh # # /etc/rc.d/nut: start/stop nut # export NUT_CONFPATH=/etc/nut case $1 in start) /usr/bin/upsdrvctl -u nut start &> /dev/null /usr/sbin/upsd -u nut &> /dev/null /usr/sbin/upsmon -u nut &> /dev/null ;; stop) /usr/sbin/upsmon -u nut -c stop &> /dev/null kill `cat /var/state/ups/*.pid` &> /dev/null killall -q upsmon upsd #Just in case our pid files were missing ;; restart) $0 stop sleep 2 $0 start ;; *) echo "usage: $0 [start|stop|restart]" ;; esac Finally add nut to the services line in /etc/rc.conf.