diff options
-rw-r--r-- | .SRCINFO | 52 | ||||
-rw-r--r-- | PKGBUILD | 113 | ||||
-rwxr-xr-x | phc-intel.openrc | 41 | ||||
-rwxr-xr-x[-rw-r--r--] | phc-intel.sh | 133 | ||||
-rwxr-xr-x[-rw-r--r--] | phc-intel.sleep.pm-utils | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | phc-intel.sleep.systemd | 0 | ||||
-rw-r--r-- | phc-intel.systemd | 16 | ||||
-rwxr-xr-x | phc-intel.sysvinit | 61 |
8 files changed, 332 insertions, 84 deletions
@@ -1,26 +1,62 @@ pkgbase = phc-intel-scripts - pkgdesc = Helper scripts for phc-intel, a frequency driver for Intel CPUs with undervolting feature. + pkgdesc = Helper and init scripts for phc-intel, a frequency driver for Intel CPUs with undervolting feature. pkgver = 0.2 - pkgrel = 5 + pkgrel = 6 url = https://gitlab.com/linux-phc/phc-intel - install = phc-intel-scripts.install arch = any groups = linux-phc groups = phc-intel license = GPL2 - depends = bash - depends = PHC-INTEL-MODULE - replaces = phc-intel<=0.3.2.rev44 - backup = etc/default/phc-intel source = phc-intel.conf.default source = phc-intel.sh source = phc-intel.sleep.pm-utils source = phc-intel.sleep.systemd + source = phc-intel.openrc + source = phc-intel.sysvinit + source = phc-intel.systemd source = phc-intel-scripts.install sha256sums = ce08a5a4107be1d5723f1f169d515e67b6c77893f3994fc2d0d2ccf611307ed3 - sha256sums = b526f3e8e66f6495531f13f2e6867d3a07b2ec7a7c3b8aa061f22be1cd6e770f + sha256sums = 7450e00dbac86560dca37c494de40a9c79250958df0795b89668b494c18855ed sha256sums = 569b85988cb38380fec85c25688b76abc24a46601aa8f58eb24eaebf863eebef sha256sums = 2e17c90d7bfae8f5070e46388e95d443188eaa7beb5ffdd418a0da090f2e7557 + sha256sums = 66be32665dd8e3c153ce512678d3af3cbf24f36829556590736e0c21baf82d28 + sha256sums = a18474513c628877d117bd3b096f085b95e5ec4f3618bb6eb59a1db1dd67de1b + sha256sums = 2998dea86b1c69a2f0668afd025de154bf3b9b6d0803bf3e3f46eab26d2df13f sha256sums = 3d7b7bd26e3bbd93eac8098fe8d688eecd7697fec345ef829b957680e0b4a360 pkgname = phc-intel-scripts + pkgdesc = Helper scripts for phc-intel, a frequency driver for Intel CPUs with undervolting feature. + install = phc-intel-scripts.install + depends = bash + depends = PHC-INTEL-MODULE + optdepends = + provides = + conflicts = + replaces = phc-intel<=0.3.2.rev44 + backup = etc/default/phc-intel + +pkgname = phc-intel-openrc + pkgdesc = OpenRC init scripts for phc-intel, a frequency driver for Intel CPUs with undervolting feature. + depends = bash + depends = phc-intel-scripts + optdepends = openrc: To use this initscript. + provides = + conflicts = + replaces = + +pkgname = phc-intel-sysvinit + pkgdesc = System V init scripts for phc-intel, a frequency driver for Intel CPUs with undervolting feature. + depends = bash + depends = phc-intel-scripts + optdepends = sysvinit: To use this initscript. + provides = + conflicts = + replaces = + +pkgname = phc-intel-systemd + pkgdesc = systemd init scripts for phc-intel, a frequency driver for Intel CPUs with undervolting feature. + depends = phc-intel-scripts + optdepends = systemd: To use this initscript. + provides = + conflicts = + replaces = @@ -6,50 +6,58 @@ _pkgbase=phc-intel-scripts pkgbase="${_pkgbase}" -_pkgname="${_pkgbase}" -pkgname="${pkgbase}" +pkgname=("${pkgbase}" "phc-intel-openrc" "phc-intel-sysvinit" "phc-intel-systemd") groups=( 'linux-phc' 'phc-intel' ) pkgver=0.2 -# _phcver="$(pacman -Q phc-intel | awk '{print $2}')" # Version of the installed package `phc-intel`. -pkgrel=5 -pkgdesc="Helper scripts for phc-intel, a frequency driver for Intel CPUs with undervolting feature." +pkgrel=6 +pkgdesc="Helper and init scripts for phc-intel, a frequency driver for Intel CPUs with undervolting feature." url="https://gitlab.com/linux-phc/phc-intel" arch=('any') license=('GPL2') -depends=( - 'bash' - 'PHC-INTEL-MODULE' # This means kernel-side support; packages providing kernel module, but also kernel packages which have that builtin, can set this. -) makedepends=() -optdepends=() -provides=() -conflicts=() -replaces=( - "phc-intel<=0.3.2.rev44" -) -backup=( - 'etc/default/phc-intel' -) -install='phc-intel-scripts.install' source=( 'phc-intel.conf.default' 'phc-intel.sh' 'phc-intel.sleep.pm-utils' 'phc-intel.sleep.systemd' - "${install}" + 'phc-intel.openrc' + 'phc-intel.sysvinit' + 'phc-intel.systemd' + 'phc-intel-scripts.install' ) sha256sums=( - 'ce08a5a4107be1d5723f1f169d515e67b6c77893f3994fc2d0d2ccf611307ed3' # 'phc-intel.conf.default' - 'b526f3e8e66f6495531f13f2e6867d3a07b2ec7a7c3b8aa061f22be1cd6e770f' # 'phc-intel.sh' - '569b85988cb38380fec85c25688b76abc24a46601aa8f58eb24eaebf863eebef' # 'phc-intel.sleep.pm-utils' - '2e17c90d7bfae8f5070e46388e95d443188eaa7beb5ffdd418a0da090f2e7557' # 'phc-intel.sleep.systemd' - '3d7b7bd26e3bbd93eac8098fe8d688eecd7697fec345ef829b957680e0b4a360' # ${install} + 'ce08a5a4107be1d5723f1f169d515e67b6c77893f3994fc2d0d2ccf611307ed3' # phc-intel.conf.default + '7450e00dbac86560dca37c494de40a9c79250958df0795b89668b494c18855ed' # phc-intel.sh + '569b85988cb38380fec85c25688b76abc24a46601aa8f58eb24eaebf863eebef' # phc-intel.sleep.pm-utils + '2e17c90d7bfae8f5070e46388e95d443188eaa7beb5ffdd418a0da090f2e7557' # phc-intel.sleep.systemd + '66be32665dd8e3c153ce512678d3af3cbf24f36829556590736e0c21baf82d28' # phc-intel.openrc + 'a18474513c628877d117bd3b096f085b95e5ec4f3618bb6eb59a1db1dd67de1b' # phc-intel.sysvinit + '2998dea86b1c69a2f0668afd025de154bf3b9b6d0803bf3e3f46eab26d2df13f' # phc-intel.systemd + '3d7b7bd26e3bbd93eac8098fe8d688eecd7697fec345ef829b957680e0b4a360' # phc-intel-scripts.install ) -package() { +package_phc-intel-scripts() { + pkgdesc="Helper scripts for phc-intel, a frequency driver for Intel CPUs with undervolting feature." + install='phc-intel-scripts.install' + depends=( + 'bash' + 'PHC-INTEL-MODULE' # This means kernel-side support; packages providing kernel module, but also kernel packages which have that builtin, can set this. + ) + optdepends=() + provides=() + conflicts=() + replaces=( + "phc-intel<=0.3.2.rev44" + ) + + backup=( + 'etc/default/phc-intel' + ) + + cd "${srcdir}" install -Dvm644 phc-intel.conf.default "${pkgdir}/etc/default/phc-intel" @@ -57,3 +65,56 @@ package() { install -Dvm755 phc-intel.sleep.pm-utils "${pkgdir}/usr/lib/pm-utils/sleep.d/00phc-intel" install -Dvm755 phc-intel.sleep.systemd "${pkgdir}/usr/lib/systemd/system-sleep/phc-intel" } + +package_phc-intel-openrc() { + pkgdesc="OpenRC init scripts for phc-intel, a frequency driver for Intel CPUs with undervolting feature." + depends=( + 'bash' + 'phc-intel-scripts' + ) + optdepends=( + 'openrc: To use this initscript.' + ) + provides=() + conflicts=() + replaces=() + + cd "${srcdir}" + + install -Dvm755 'phc-intel.openrc' "${pkgdir}/etc/init.d/phc-intel" +} + +package_phc-intel-sysvinit() { + pkgdesc="System V init scripts for phc-intel, a frequency driver for Intel CPUs with undervolting feature." + depends=( + 'bash' + 'phc-intel-scripts' + ) + optdepends=( + 'sysvinit: To use this initscript.' + ) + provides=() + conflicts=() + replaces=() + + cd "${srcdir}" + + install -Dvm755 'phc-intel.sysvinit' "${pkgdir}/etc/rc.d/phc-intel" +} + +package_phc-intel-systemd() { + pkgdesc="systemd init scripts for phc-intel, a frequency driver for Intel CPUs with undervolting feature." + depends=( + 'phc-intel-scripts' + ) + optdepends=( + 'systemd: To use this initscript.' + ) + provides=() + conflicts=() + replaces=() + + cd "${srcdir}" + + install -Dvm755 'phc-intel.systemd' "${pkgdir}/usr/lib/systemd/system/phc-intel.service" +}
\ No newline at end of file diff --git a/phc-intel.openrc b/phc-intel.openrc new file mode 100755 index 000000000000..58a98dbf79a7 --- /dev/null +++ b/phc-intel.openrc @@ -0,0 +1,41 @@ +#!/usr/bin/openrc-run +# OpenRC phc-intel init script + +_NAME=phc-intel +_DESCRIPTION='Intel CPU undervolting' +_SCRIPT=/usr/bin/phc-intel + +extra_started_commands="status set" + +depend() { + want modules +} + +start() { + ebegin "${_NAME}: Setting ${_DESCRIPTION} parameters." + "${_SCRIPT}" start + eend "$?" +} + +stop() { + ebegin "${_NAME}: Unsetting ${_DESCRIPTION} parameters." + "${_SCRIPT}" stop + eend "$?" +} + +reload() { + "$0" stop + "$0" start +} + +status() { + ebegin "${_NAME}: Querying status of ${_DESCRIPTION} parameters." + "${_SCRIPT}" status + eend "$?" +} + +set() { + ebegin "${_NAME}: Setting ${_DESCRIPTION} parameters." + "${_SCRIPT}" set + eend "$?" +} diff --git a/phc-intel.sh b/phc-intel.sh index cce4bf96ad91..7bc228130aba 100644..100755 --- a/phc-intel.sh +++ b/phc-intel.sh @@ -1,55 +1,88 @@ #!/bin/bash -e + +## This file is licensed under the GNU General Public License, version 2. + +_conf='/etc/default/phc-intel' + +msg() { + printf '%s\n' "$@" +} + +errmsg() { + msg "$@" > /dev/stderr +} + +check_conf_and_set() { + if [ -r "${_conf}" ]; then + . "${_conf}" + if [ -z "$VIDS" ]; then + errmsg "=> Please edit '${_conf}'." + exit 1 + fi + msg ':: Setting PHC VIDs' + for i in /sys/devices/system/cpu/cpu*/cpufreq/phc_vids; do + echo $VIDS > "$i" + done + else + errmsg "$0: Error: Config file '${_conf}' not present." + exit 2 + fi +} + +check_kernel_cmdline() { + for i in $(< /proc/cmdline); do + if [ $i = nophc ]; then + errmsg "=> 'nophc' kernel option set, not setting PHC VIDs." + errmsg " Use '$0 set' to override." + return 1 + fi + done +} + shopt -s nullglob case "$1" in -start) - . /etc/default/phc-intel - if [ -z "$VIDS" ]; then - echo '=> Please edit /etc/default/phc-intel' - exit 1 - fi - echo ':: Setting PHC VIDs' - for i in /sys/devices/system/cpu/cpu*/cpufreq/phc_vids; do - echo $VIDS > "$i" - done - ;; -stop) - echo ':: Resetting default PHC VIDs' - for i in /sys/devices/system/cpu/cpu*/cpufreq/phc_vids; do - cp "${i%vids}default_vids" "$i" - done - ;; -status) - check_off () { - for i in /sys/devices/system/cpu/cpu*/cpufreq/phc_vids; do - [ "$(< "$i")" = "$(< "${i%vids}default_vids")" ] || return; - done - } - check_on () { - for i in /sys/devices/system/cpu/cpu*/cpufreq/phc_vids; do - [[ "$(< "$i")" =~ "$VIDS" ]] || return; - done - } - echo -n 'PHC status: ' - . /etc/default/phc-intel - if check_off; then - echo 'inactive' - elif check_on; then - echo 'active' - else - echo 'unknown' - fi - ;; -set) - . /etc/default/phc-intel - [ -z "$VIDS" ] && exit - for i in $(< /proc/cmdline); do - [ $i = nophc ] && exit - done - for i in /sys/devices/system/cpu/cpu*/cpufreq/phc_vids; do - echo $VIDS > "$i" - done - ;; -*) - echo "usage: $0 {start|stop|status|set}" + + start) + check_kernel_cmdline "$@" || exit 0 + check_conf_and_set "$@" + ;; + + stop|reset) + msg ':: Resetting default PHC VIDs' + for i in /sys/devices/system/cpu/cpu*/cpufreq/phc_vids; do + cp "${i%vids}default_vids" "$i" + done + ;; + + status) + check_off () { + for i in /sys/devices/system/cpu/cpu*/cpufreq/phc_vids; do + [ "$(< "$i")" = "$(< "${i%vids}default_vids")" ] || return; + done + } + check_on () { + for i in /sys/devices/system/cpu/cpu*/cpufreq/phc_vids; do + [[ "$(< "$i")" =~ "$VIDS" ]] || return; + done + } + printf '%s' 'PHC status: ' + . "${_conf}" + if check_off; then + msg 'inactive' + elif check_on; then + msg 'active' + else + msg 'unknown' + fi + ;; + + set) + check_conf_and_set "$@" + ;; + + *) + echo "usage: $0 {start|stop|status|set|reset}" + ;; + esac diff --git a/phc-intel.sleep.pm-utils b/phc-intel.sleep.pm-utils index 342b81acf831..342b81acf831 100644..100755 --- a/phc-intel.sleep.pm-utils +++ b/phc-intel.sleep.pm-utils diff --git a/phc-intel.sleep.systemd b/phc-intel.sleep.systemd index c76ea6aafda0..c76ea6aafda0 100644..100755 --- a/phc-intel.sleep.systemd +++ b/phc-intel.sleep.systemd diff --git a/phc-intel.systemd b/phc-intel.systemd new file mode 100644 index 000000000000..5267c4b88cc3 --- /dev/null +++ b/phc-intel.systemd @@ -0,0 +1,16 @@ +# phc-intel init script for systemd. + +[Unit] +Description=Intel CPU undervolting + +[Service] +Type=oneshot +RemainAfterExit=yes +User=root +ExecStart=/usr/bin/phc-intel start +ExecStop=/usr/bin/phc-intel stop +ExecReload=/usr/bin/phc-intel stop; /usr/bin/phc-intel start +ExecStatus=/usr/bin/phc-intel status + +[Install] +# WantedBy=multi-user.target diff --git a/phc-intel.sysvinit b/phc-intel.sysvinit new file mode 100755 index 000000000000..245c760766fd --- /dev/null +++ b/phc-intel.sysvinit @@ -0,0 +1,61 @@ +#!/bin/bash + +# phc-intel System-V-init script + +_NAME=phc-intel +_DESCRIPTION='Intel CPU undervolting' +_SCRIPT=/usr/bin/phc-intel + +. /etc/rc.conf +. /etc/rc.d/functions + +case "$1" in + start) + stat_busy "${_NAME}: Setting ${_DESCRIPTION} parameters." + "${_SCRIPT}" start + if [ $? -gt 0 ]; then + stat_fail + else + add_daemon "${_NAME}" + stat_done + fi + ;; + stop) + stat_busy "${_NAME}: Unsetting ${_DESCRIPTION} parameters." + "${_SCRIPT}" stop + if [ $? -gt 0 ]; then + stat_fail + else + rm_daemon "${_NAME}" + stat_done + fi + ;; + restart) + "$0" stop + "$0" start + ;; + reload) + "$0" restart + ;; + status) + stat_busy "${_NAME}: Querying status of ${_DESCRIPTION} parameters." + "${_SCRIPT}" status + if [ $? -gt 0 ]; then + stat_fail + else + stat_done + fi + ;; + set) + stat_busy "${_NAME}: Setting ${_DESCRIPTION} parameters." + "${_SCRIPT}" set + if [ $? -gt 0 ]; then + stat_fail + else + stat_done + fi + ;; + *) + echo "usage: $0 {start|stop|restart|reload|status|set}" + ;; +esac |