Adding batt check and fixed MC to use full path

This commit is contained in:
Henry Corse
2022-12-25 15:05:36 -05:00
parent 169dd47aeb
commit 2d04a5bbf6
4 changed files with 18 additions and 1 deletions

2
batt_check/batt_check Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
BATTINFO=$(acpi -b | grep Discharging || echo 100\%) && [[ $( echo "$BATTINFO" | grep -Eo '[[:digit:]]+%' | tr -d "\%") -lt 80 ]] && systemctl poweroff

View File

@ -0,0 +1,7 @@
[Unit]
Description=Battery Check Service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/batt_check

View File

@ -0,0 +1,8 @@
[Unit]
Description=Check the battery status and shutdown if discharging and low
[Timer]
OnActiveSec=120
[Install]
WantedBy=timers.target

View File

@ -19,7 +19,7 @@ start() {
echo "Server already running with pid: $(cat $PID)"
status
exit 0
fi
fi
screen -S minecraft -dm java -Xms1G -Xmx5G -jar /opt/minecraft/server.jar nogui
pgrep -P "$(screen -list | sed -E -n 's/\s*([0-9]+).minecraft.*/\1/p')" > $PID
}