diff --git a/scripts/hdparm/hdparm.sh b/scripts/hdparm/hdparm.sh new file mode 100755 index 0000000..55a9114 --- /dev/null +++ b/scripts/hdparm/hdparm.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env zsh + +# author: Daniel Sommer +# license: MIT + +# exit on error +set -e + +# check permissions +[[ "$EUID" != 0 ]] && printf "error: permission denied!\n" >&2 && exit 1 + +# check if script exists +script="$(dirname $(realpath "$0"))/$(hostname).sh" +[[ ! -x "$script" ]] && printf "error: script '"$script"' does not exist or is not executable!\n" >&2 && exit 1 + +# execute script +printf ">> executing script '"$script"'...\n" +. "$script" diff --git a/scripts/hdparm/j5040.sh b/scripts/hdparm/j5040.sh new file mode 100755 index 0000000..74245bf --- /dev/null +++ b/scripts/hdparm/j5040.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env zsh + +# author: Daniel Sommer +# license: MIT + +hdparm -S 1 -y /dev/sdc +hdparm -S 1 -y /dev/sdd diff --git a/systemd/hdparm.service b/systemd/hdparm.service new file mode 100644 index 0000000..af64f16 --- /dev/null +++ b/systemd/hdparm.service @@ -0,0 +1,9 @@ +[Unit] +Description=put various drives in standby mode and set their spin-down timer + +[Service] +Type=oneshot +ExecStart=/home/velvettear/.dots/scripts/hdparm/hdparm.sh + +[Install] +WantedBy=multi-user.target