From c486cef9853640a6642477258bb759fe4d78096a Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Tue, 26 Nov 2024 16:24:24 -0500
Subject: powerpanel: initial inclusion

---
 linhes/powerpanel/.SRCINFO         | 27 ++++++++++++
 linhes/powerpanel/PKGBUILD         | 85 ++++++++++++++++++++++++++++++++++++++
 linhes/powerpanel/hibernate.sh     |  2 +
 linhes/powerpanel/pwrstatd.service | 10 +++++
 linhes/powerpanel/shutdown.sh      |  2 +
 5 files changed, 126 insertions(+)
 create mode 100644 linhes/powerpanel/.SRCINFO
 create mode 100644 linhes/powerpanel/PKGBUILD
 create mode 100755 linhes/powerpanel/hibernate.sh
 create mode 100644 linhes/powerpanel/pwrstatd.service
 create mode 100755 linhes/powerpanel/shutdown.sh

diff --git a/linhes/powerpanel/.SRCINFO b/linhes/powerpanel/.SRCINFO
new file mode 100644
index 0000000..da52b41
--- /dev/null
+++ b/linhes/powerpanel/.SRCINFO
@@ -0,0 +1,27 @@
+pkgbase = powerpanel
+	pkgdesc = CyberPower UPS daemon
+	pkgver = 1.4.1
+	pkgrel = 3
+	url = https://www.cyberpowersystems.com/product/software/powerpanel-for-linux/
+	arch = x86_64
+	arch = i686
+	license = custom:CyberPower
+	depends = libusb
+	depends = openssl-1.1
+	depends = paho-mqtt-c
+	backup = etc/powerpanel/pwrstatd-powerfail.sh
+	backup = etc/powerpanel/pwrstatd-lowbatt.sh
+	backup = etc/powerpanel/pwrstatd-email.sh
+	backup = etc/powerpanel/hibernate.sh
+	backup = etc/powerpanel/shutdown.sh
+	backup = etc/pwrstatd.conf
+	source = pwrstatd.service
+	source = hibernate.sh
+	source = shutdown.sh
+	source = https://dl4jz3rbrsfum.cloudfront.net/software/PPL_64bit_v1.4.1.tar..gz
+	sha256sums = 255e5958346daa9d7c0e96ae3d86095afd3b3ec99880205d15d51b8f20a602df
+	sha256sums = c710ea7765a24fb469adf601f44c8d3857634336bdfc263434ce86c3d67a4a80
+	sha256sums = 10badc96b0ac990959ddc53d1d1cbba6b904e648b54d0eea085194e48d6a0998
+	sha256sums = 6240dae59202531df91ccf0655cf6c61120fe64dc14642c46579366ed0d8212d
+
+pkgname = powerpanel
diff --git a/linhes/powerpanel/PKGBUILD b/linhes/powerpanel/PKGBUILD
new file mode 100644
index 0000000..4630553
--- /dev/null
+++ b/linhes/powerpanel/PKGBUILD
@@ -0,0 +1,85 @@
+# Maintainer: David Gonzalez <neko.eth0 AT gmail DOT com>
+# Contributor: 10101000 <10101000_proton [at] pm.me>
+# Contributor: Jeff Henson <jeff [at] henson.io>
+# Contributor: Justin Settle <jus10 [at] partlycloudy.org>
+# Contributor: Kyle Keen <keenerd [at] gmail.com>, das-ich <das-ich [at] yandex.ru>
+
+pkgname=powerpanel
+pkgver=1.4.1
+pkgrel=3
+pkgdesc="CyberPower UPS daemon"
+arch=("x86_64" "i686")
+url="https://www.cyberpowersystems.com/product/software/powerpanel-for-linux/"
+license=("custom:CyberPower")
+depends=('libusb' 'openssl-1.1' 'paho-mqtt-c')
+backup=(etc/powerpanel/pwrstatd-{powerfail,lowbatt,email}.sh
+        etc/powerpanel/{hibernate,shutdown}.sh
+        etc/pwrstatd.conf)
+
+source=('pwrstatd.service'
+        'hibernate.sh'
+        'shutdown.sh')
+sha256sums=('255e5958346daa9d7c0e96ae3d86095afd3b3ec99880205d15d51b8f20a602df'
+            'c710ea7765a24fb469adf601f44c8d3857634336bdfc263434ce86c3d67a4a80'
+            '10badc96b0ac990959ddc53d1d1cbba6b904e648b54d0eea085194e48d6a0998'
+            '6240dae59202531df91ccf0655cf6c61120fe64dc14642c46579366ed0d8212d')
+
+if [[ $CARCH = 'x86_64' ]]; then
+  # Filename has two dots at the source
+  source+=("https://dl4jz3rbrsfum.cloudfront.net/software/PPL_64bit_v${pkgver}.tar..gz")
+fi
+
+if [[ $CARCH = 'i686' ]]; then
+  source+=("https://dl4jz3rbrsfum.cloudfront.net/software/PPL_32bit_v${pkgver}.tar.gz")
+fi
+
+package() {
+  cd "${srcdir}/$pkgname-$pkgver"
+
+  # PowerPanel for Linux client program
+  install -Dm755 bin/pwrstat "${pkgdir}/usr/bin/pwrstat"
+
+  # PowerPanel for Linux daemon program
+  install -Dm755 bin/pwrstatd "${pkgdir}/usr/bin/pwrstatd"
+
+  # PowerPanel for Linux daemon configuration
+  install -Dm600 conf/pwrstatd.conf "${pkgdir}/etc/pwrstatd.conf"
+  sed -e 's#/etc#/etc/powerpanel#' -i "${pkgdir}/etc/pwrstatd.conf"
+
+  # Script command for event of power failure
+  install -Dm755 script/pwrstatd-powerfail.sh "${pkgdir}/etc/powerpanel/pwrstatd-powerfail.sh"
+  sed -e 's#/etc#/etc/powerpanel#' -i "${pkgdir}/etc/powerpanel/pwrstatd-powerfail.sh"
+
+  # Script command for event of battery low
+  install -Dm755 script/pwrstatd-lowbatt.sh "${pkgdir}/etc/powerpanel/pwrstatd-lowbatt.sh"
+  sed -e 's#/etc#/etc/powerpanel#' -i "${pkgdir}/etc/powerpanel/pwrstatd-lowbatt.sh"
+
+  # Script command for e-mail notification
+  install -Dm755 script/pwrstatd-email.sh "${pkgdir}/etc/powerpanel/pwrstatd-email.sh"
+
+  # Script for hibernate support
+  install -Dm755 "${srcdir}/hibernate.sh" "${pkgdir}/etc/powerpanel/hibernate.sh"
+  ln -s powerpanel/hibernate.sh "${pkgdir}/etc/hibernate.sh"
+
+  # Script for shutdown support
+  install -Dm755 "${srcdir}/shutdown.sh" "${pkgdir}/etc/powerpanel/shutdown.sh"
+  ln -s powerpanel/shutdown.sh "${pkgdir}/etc/shutdown.sh"
+
+  # Systemd unit
+  install -Dm644 "${srcdir}/pwrstatd.service" "${pkgdir}/usr/lib/systemd/system/pwrstatd.service"
+
+  # PowerPanel for Linux client man-page
+  install -Dm644 doc/pwrstat.8 "${pkgdir}/usr/share/man/man8/pwrstat.8"
+
+  # PowerPanel for Linux daemon man-page
+  install -Dm644 doc/pwrstatd.8 "${pkgdir}/usr/share/man/man8/pwrstatd.8"
+
+  #
+  # compress the man page file
+  #
+  gzip -9 "${pkgdir}/usr/share/man/man8/pwrstat.8"
+  gzip -9 "${pkgdir}/usr/share/man/man8/pwrstatd.8"
+
+  # Install License
+  install -D -m644 doc/LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
+}
diff --git a/linhes/powerpanel/hibernate.sh b/linhes/powerpanel/hibernate.sh
new file mode 100755
index 0000000..ea581e0
--- /dev/null
+++ b/linhes/powerpanel/hibernate.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+systemctl hibernate
diff --git a/linhes/powerpanel/pwrstatd.service b/linhes/powerpanel/pwrstatd.service
new file mode 100644
index 0000000..222f4e5
--- /dev/null
+++ b/linhes/powerpanel/pwrstatd.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=PowerPanel for Linux software can be used with most CyberPower UPS products.
+
+[Service]
+Group=power
+UMask=0002
+ExecStart=/usr/bin/pwrstatd
+
+[Install]
+WantedBy=multi-user.target
diff --git a/linhes/powerpanel/shutdown.sh b/linhes/powerpanel/shutdown.sh
new file mode 100755
index 0000000..949e424
--- /dev/null
+++ b/linhes/powerpanel/shutdown.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+systemctl poweroff
-- 
cgit v0.12

