create standalone script(s) and service files for hdparm

This commit is contained in:
Daniel Sommer 2025-03-20 17:02:13 +01:00
parent 6ee602d0b9
commit 2860c9d7c3
3 changed files with 34 additions and 0 deletions

18
scripts/hdparm/hdparm.sh Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env zsh
# author: Daniel Sommer <daniel.sommer@velvettear.de>
# 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"

7
scripts/hdparm/j5040.sh Executable file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env zsh
# author: Daniel Sommer <daniel.sommer@velvettear.de>
# license: MIT
hdparm -S 1 -y /dev/sdc
hdparm -S 1 -y /dev/sdd

9
systemd/hdparm.service Normal file
View file

@ -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