commit 07ed3bfbea9d37bf5254deff5e000cf036dffe15 Author: Lukas Plevac Date: Sun Dec 8 18:00:07 2024 +0100 Inital diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..6c83571 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,11 @@ +pkgname=saturn-power +pkgver=1.1 +pkgrel=1 +arch=('any') +source=('slurmResume' 'slurmSuspend') +md5sums=('SKIP' 'SKIP') + +package() { + install -D -t "${pkgdir}/usr/bin" "$srcdir/slurmResume" + install -D -t "${pkgdir}/usr/bin" "$srcdir/slurmSuspend" +} \ No newline at end of file diff --git a/slurmResume b/slurmResume new file mode 100755 index 0000000..86e2c4d --- /dev/null +++ b/slurmResume @@ -0,0 +1,10 @@ +#!/bin/bash +hosts=$(scontrol show hostnames "$1") +logfile=/var/log/power_save.log +echo "$(date) Resume invoked $0 $*" >>$logfile +for host in $hosts +do + hostMac=$(saturnDiscover lookup hostmac $host) + sudo wol $hostMac +done +exit 0 diff --git a/slurmSuspend b/slurmSuspend new file mode 100755 index 0000000..c15217c --- /dev/null +++ b/slurmSuspend @@ -0,0 +1,9 @@ +#!/bin/bash +hosts=$(scontrol show hostnames "$1") +logfile=/var/log/power_save.log +echo "$(date) Suspend invoked $0 $*" >>$logfile +for host in $hosts +do + sudo ssh -i /root/.ssh/maintenance -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -t maintenance@$host "sudo /sbin/shutdown" +done +exit 0 \ No newline at end of file