diff --git a/Readme.md b/Readme.md index 23e9388..79990a1 100644 --- a/Readme.md +++ b/Readme.md @@ -6,6 +6,7 @@ | minisatip | A small SAT>IP server from https://github.com/catalinii/minisatip | | custom-firmware-mn88472 | Panasonic MN88472 firmware for Xbox One tuner | | rflink | rflink port for raspberrypi https://github.com/seahu/rflink | +| nut | Forked of the community repo version with CGI components enabled | # How to build packages ## Initial Setup diff --git a/nut/APKBUILD b/nut/APKBUILD new file mode 100644 index 0000000..d8106c1 --- /dev/null +++ b/nut/APKBUILD @@ -0,0 +1,112 @@ +# Contributor: Bram Prieshof +# Contributor: Valery Kartel +# Contributor: Kozak Ivan +# Maintainer: Bram Prieshof +pkgname=nut +pkgver=2.8.2 +pkgrel=3 +pkgdesc="Network UPS tools" +url="https://networkupstools.org/" +arch="all" +license="GPL-2.0-or-later" +depends="hidapi libgd eudev udev-init-scripts-openrc" +depends_dev="openssl-dev>3 libmodbus-dev libusb-dev net-snmp-dev neon-dev nss-dev gd-dev" +makedepends="$depends_dev libtool autoconf automake" +pkgusers=$pkgname +pkggroups=$pkgname +install="$pkgname.pre-install" +subpackages="$pkgname-doc $pkgname-dev $pkgname-bash-completion $pkgname-openrc" +source="https://networkupstools.org/source/${pkgver%.*}/nut-$pkgver.tar.gz + powerfail.initd + upsd.initd + upsmon.initd + " + +prepare() { + default_prepare + + # fix version + git init . + git config user.name "abc" + git config user.email "a@a" + git add configure.ac + git commit -m "$pkgver" + git tag "$pkgver" + + autoreconf -fi +} + +build() { + CFLAGS="$CFLAGS -flto=auto" \ + ./configure \ + --build=$CBUILD \ + --host=$CHOST \ + --prefix=/usr \ + --libexecdir=/usr/lib/nut \ + --without-wrap \ + --with-user=$pkgname \ + --with-group=$pkgname \ + --disable-static \ + --with-serial \ + --with-usb \ + --without-avahi \ + --with-snmp \ + --with-modbus \ + --with-neon \ + --without-powerman \ + --without-ipmi \ + --without-freeipmi \ + --with-libltdl \ + --with-cgi \ + --with-drvpath=/usr/lib/nut \ + --datadir=/usr/share/nut \ + --sysconfdir=/etc/nut \ + --with-statepath=/var/run/nut \ + --with-altpidpath=/var/run/nut \ + --with-udev-dir=/usr/lib/udev \ + --with-nss \ + --with-openssl + make +} + +check() { + make check +} + +package() { + make DESTDIR="$pkgdir" install + install -Dm755 "$srcdir"/powerfail.initd "$pkgdir"/etc/init.d/nut-powerfail.initd + install -Dm755 "$srcdir"/upsd.initd "$pkgdir"/etc/init.d/nut-upsd + install -Dm755 "$srcdir"/upsmon.initd "$pkgdir"/etc/init.d/nut-upsmon + install -Dm644 "$builddir"/scripts/logrotate/nutlogd "$pkgdir"/etc/logrotate.d/$pkgname + install -d -o $pkgname -g $pkgname "$pkgdir"/var/lib/$pkgname + + local CgiFile; + for CgiFile in "$pkgdir"/usr/cgi-bin/*.cgi; do + install -Dm755 -o root -g $pkgname -t "$pkgdir"/usr/cgi-bin/nut/ $CgiFile; + done + + local HtmlFile; + for HtmlFile in "$pkgdir"/usr/html/*; do + install -Dm644 -o root -g $pkgname -t "$pkgdir"/usr/html/nut/ $HtmlFile; + done + + rm "$pkgdir"/usr/cgi-bin/*.cgi "$pkgdir"/usr/html/*.html "$pkgdir"/usr/html/*.png + + install -D -m644 "$builddir"/scripts/misc/nut.bash_completion \ + "$pkgdir"/usr/share/bash-completion/completions/$pkgname.bash + + local file; + for file in "$pkgdir"/etc/nut/*.sample; do + chmod 640 $file + chown root:$pkgname $file + mv $file ${file%.sample} + done +} + +sha512sums=" +b6f8f22318e4a4fcb8073a63132b1cb083952c665191b82a7d6765a61b859575a4b0c2ba84ed17cfb8c88d34179876d64520dd2f75f02fe8707b406da2c0821c nut-2.8.2.tar.gz +c32f693e9882602f847b714d2837172b18c0b2fb78cbbf95c0af43a59b3213e3241327890ae038573a9de114ab33bb43d69796c4683b5120ca49cd3174dd5f2d powerfail.initd +5fce1247815e36a0e787f28dfec215077a42b046f6ce35a5ad3cf94479dfc26303d3cf4d5f760d5851ed5273ee398572c36cd354af0645cbebc1f1560414e222 upsd.initd +32470ae473fc363131787cd57f13d40763898947d56d032790ba7f3a5eaa8038b602f7e395ca44f6c5adce8ee5ec496e30ca0eaadb3c78a38015677aea751e12 upsmon.initd +" diff --git a/nut/nut.pre-install b/nut/nut.pre-install new file mode 100644 index 0000000..99ed4dc --- /dev/null +++ b/nut/nut.pre-install @@ -0,0 +1,6 @@ +#!/bin/sh + +addgroup -S nut 2>/dev/null +adduser -S -D -H -h /var/lib/nut -s /sbin/nologin -G nut -g nut nut 2>/dev/null + +exit 0 diff --git a/nut/powerfail.initd b/nut/powerfail.initd new file mode 100644 index 0000000..59aa976 --- /dev/null +++ b/nut/powerfail.initd @@ -0,0 +1,17 @@ +#!/sbin/openrc-run +# Copyright 2009 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +description='Signal the UPS to kill power in a power failure condition' + +depend() { + need mount-ro +} + +start() { + if [ "$RC_RUNLEVEL" = "shutdown" -a -f /etc/killpower ] ; then + ebegin 'Signaling UPS to kill power' + /usr/sbin/upsdrvctl shutdown + eend $? + fi +} diff --git a/nut/upsd.initd b/nut/upsd.initd new file mode 100644 index 0000000..e9b7a22 --- /dev/null +++ b/nut/upsd.initd @@ -0,0 +1,41 @@ +#!/sbin/openrc-run + +name="UPS Server" +pidfile=/run/nut/upsd.pid +command=/usr/sbin/upsd +required_files="/etc/nut/nut.conf /etc/nut/upsd.conf" +extra_started_commands="reload" +start_stop_daemon_args="--quiet" + +depend() { + use net dns + need udev +} + +start_pre() { + . /etc/nut/nut.conf + case $MODE in + standalone|netserver) + checkpath -d --owner nut:nut --mode 750 ${pidfile%/*} || return 1 + /usr/sbin/upsdrvctl start > /dev/null + ;; + none) + eerror "$name disabled, please adjust the configuration to your needs" + eerror "Then set MODE to a suitable value in /etc/nut/nut.conf to enable it" + return 1 + ;; + *) + return 1 + ;; + esac +} + +stop_post() { + /usr/sbin/upsdrvctl stop > /dev/null +} + +reload() { + ebegin "Reloading $name" + start-stop-daemon --signal HUP --pidfile $pidfile + eend $? +} diff --git a/nut/upsmon.initd b/nut/upsmon.initd new file mode 100644 index 0000000..4a7efe8 --- /dev/null +++ b/nut/upsmon.initd @@ -0,0 +1,35 @@ +#!/sbin/openrc-run + +name="UPS Monitor" +pidfile=/run/upsmon.pid +command=/usr/sbin/upsmon +required_files="/etc/nut/nut.conf /etc/nut/upsmon.conf" +extra_started_commands="reload" +start_stop_daemon_args="--quiet" + +depend() { + . /etc/nut/nut.conf + case $MODE in + standalone|netserver) + need nut-upsd + ;; + esac + use net dns +} + +start_pre() { + . /etc/nut/nut.conf + case $MODE in + none) + eerror "$name disabled, please adjust the configuration to your needs" + eerror "Then set MODE to a suitable value in /etc/nut/nut.conf to enable it" + return 1 + ;; + esac +} + +reload() { + ebegin "Reloading $name" + start-stop-daemon --signal HUP --pidfile $pidfile + eend $? +}