From 07ed3bfbea9d37bf5254deff5e000cf036dffe15 Mon Sep 17 00:00:00 2001 From: Lukas Plevac Date: Sun, 8 Dec 2024 18:00:07 +0100 Subject: [PATCH] Inital --- PKGBUILD | 11 +++++++++++ slurmResume | 10 ++++++++++ slurmSuspend | 9 +++++++++ 3 files changed, 30 insertions(+) create mode 100644 PKGBUILD create mode 100755 slurmResume create mode 100755 slurmSuspend 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