Compare commits

...

2 commits

Author SHA1 Message Date
mwiegand
b08fe2c749 no sleep when ssh 2022-02-12 20:55:17 +01:00
mwiegand
a581dbfee9 format 2022-02-12 20:55:08 +01:00
2 changed files with 5 additions and 5 deletions

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
UPTIME=$(cat /proc/uptime | cut -d. -f1) UPTIME=$(cat /proc/uptime | cut -d. -f1)
MIN_UPTIME=$(expr 60 \* 10) MIN_UPTIME=$(expr 60 \* 20)
if [[ "$UPTIME" -lt "$MIN_UPTIME" ]] if [[ "$UPTIME" -lt "$MIN_UPTIME" ]]
then then
echo "ABORT: uptime ($UPTIME) lower than min ($MIN_UPTIME)" echo "ABORT: uptime ($UPTIME) lower than min ($MIN_UPTIME)"
@ -21,7 +21,7 @@ do
fi fi
done done
LOGINS=$(who -u | grep pts\/ | wc -l) LOGINS=$(netstat -tnpa | grep 'ESTABLISHED.*sshd' | wc -l)
if [[ "$LOGINS" -gt 0 ]] if [[ "$LOGINS" -gt 0 ]]
then then
echo "ABORT: $LOGINS user logins" echo "ABORT: $LOGINS user logins"
@ -31,9 +31,7 @@ fi
if [[ "$1" = now ]] if [[ "$1" = now ]]
then then
echo "SESPENDING" echo "SESPENDING"
sleep 10
systemctl suspend systemctl suspend
else else
echo "WOULD SESPEND" echo "WOULD SESPEND"
sleep 300
fi fi

View file

@ -2,4 +2,6 @@ from bundlewrap.operations import run_local
def node_apply_start(repo, node, interactive=False, **kwargs): def node_apply_start(repo, node, interactive=False, **kwargs):
if node.has_bundle('wol-sleeper'): if node.has_bundle('wol-sleeper'):
repo.get_node(node.metadata.get('wol-sleeper/waker')).run(node.metadata.get('wol-sleeper/wake_command')) repo\
.get_node(node.metadata.get('wol-sleeper/waker'))\
.run(node.metadata.get('wol-sleeper/wake_command'))