Added a fork of the NUT Package

* Forked of the community repo version to enable CGI components
This commit is contained in:
2025-02-14 23:34:41 +01:00
parent bfda455c47
commit 227d70ac16
6 changed files with 212 additions and 0 deletions

112
nut/APKBUILD Normal file
View File

@@ -0,0 +1,112 @@
# Contributor: Bram Prieshof <alpine.pkgs@bprieshof.nl>
# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Contributor: Kozak Ivan <kozak-iv@yandex.ru>
# Maintainer: Bram Prieshof <alpine.pkgs@bprieshof.nl>
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
"

6
nut/nut.pre-install Normal file
View File

@@ -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

17
nut/powerfail.initd Normal file
View File

@@ -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
}

41
nut/upsd.initd Normal file
View File

@@ -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 $?
}

35
nut/upsmon.initd Normal file
View File

@@ -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 $?
}