Compare commits
No commits in common. "706c4028f850c8b2858ac2b021fb8203de706b1c" and "116697af9f5d30cb9fa0ba0c54f9335d4c4e3a78" have entirely different histories.
706c4028f8
...
116697af9f
7 changed files with 19 additions and 65 deletions
|
@ -44,19 +44,6 @@ fi
|
|||
|
||||
if [[ "$?" == "0" ]]
|
||||
then
|
||||
|
||||
# delete old local bookmarks
|
||||
for destroyable_bookmark in $(zfs list -t bookmark -H -o name "$dataset" | grep "^$dataset#$bookmark_prefix")
|
||||
do
|
||||
zfs destroy "$destroyable_bookmark"
|
||||
done
|
||||
|
||||
# delete snapshots from bookmarks (except newest, even of not necessary; maybe for resuming tho)
|
||||
for destroyable_snapshot in $($ssh sudo zfs list -t snapshot -H -o name "$dataset" | grep "^$dataset@$bookmark_prefix" | grep -v "$new_bookmark")
|
||||
do
|
||||
$ssh sudo zfs destroy "$destroyable_snapshot"
|
||||
done
|
||||
|
||||
zfs bookmark "$source_dataset@$new_bookmark" "$source_dataset#$new_bookmark"
|
||||
zfs destroy "$source_dataset@$new_bookmark" # keep snapshots?
|
||||
echo "SUCCESS"
|
||||
|
|
|
@ -4,6 +4,3 @@ Host *
|
|||
GSSAPIAuthentication yes
|
||||
StrictHostKeyChecking yes
|
||||
GlobalKnownHostsFile /etc/ssh/ssh_known_hosts
|
||||
ControlMaster auto
|
||||
ControlPath ~/.ssh/multiplex-%C
|
||||
ControlPersist 5m
|
||||
|
|
|
@ -37,8 +37,6 @@ def systemd(metadata):
|
|||
})
|
||||
if config.get('working_dir'):
|
||||
units[f'{name}.service']['Service']['WorkingDirectory'] = config['working_dir']
|
||||
if config.get('success_exit_status'):
|
||||
units[f'{name}.service']['Service']['SuccessExitStatus'] = config['success_exit_status']
|
||||
|
||||
services[f'{name}.timer'] = {}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ MIN_UPTIME=$(expr 60 \* 15)
|
|||
if [[ "$UPTIME" -lt "$MIN_UPTIME" ]]
|
||||
then
|
||||
echo "ABORT: uptime of ${UPTIME}s is lower than minimum of ${MIN_UPTIME}s"
|
||||
exit 75
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# CHECK FOR RUNNING TIMERS
|
||||
|
@ -30,7 +30,7 @@ do
|
|||
elif systemctl is-active "$SERVICE" --quiet
|
||||
then
|
||||
echo "ABORT: service $SERVICE is running by timer"
|
||||
exit 75
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -40,7 +40,7 @@ LOGINS=$(netstat -tnpa | grep 'ESTABLISHED.*sshd' | tr -s ' ' | cut -d' ' -f5,7-
|
|||
if ! [[ -z "$LOGINS" ]]
|
||||
then
|
||||
echo "ABORT: users logged in: $LOGINS"
|
||||
exit 75
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# SUSPEND!
|
||||
|
@ -48,26 +48,8 @@ fi
|
|||
if [[ "$1" = check ]]
|
||||
then
|
||||
echo "WOULD SESPEND"
|
||||
exit 0
|
||||
else
|
||||
echo "SESPENDING AFTER TIMEOUT"
|
||||
|
||||
for i in 1 2 3 4 5 6
|
||||
do
|
||||
echo "TIMEOUT ${i} success"
|
||||
sleep 10
|
||||
|
||||
# check if condition is still met
|
||||
if "$0" check
|
||||
then
|
||||
continue
|
||||
else
|
||||
echo "SESPENSION ABORTED"
|
||||
exit 75
|
||||
fi
|
||||
done
|
||||
|
||||
echo "SESPENDING"
|
||||
sleep 60
|
||||
systemctl suspend
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
@ -6,7 +6,6 @@ defaults = {
|
|||
'packages': {
|
||||
'jq': {},
|
||||
'ethtool': {},
|
||||
'net-tools': {},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -21,7 +20,6 @@ def timer(metadata):
|
|||
'suspend-if-idle': {
|
||||
'command': f'suspend_if_idle',
|
||||
'when': 'minutely',
|
||||
'success_exit_status': '75',
|
||||
'env': {
|
||||
'THIS_SERVICE': 'suspend-if-idle.service',
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
set -exu
|
||||
|
||||
ssh="ssh -o ConnectTimeout=5 root@${server_ip}"
|
||||
ssh="ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 root@${server_ip}"
|
||||
bookmark_prefix="auto-mirror_"
|
||||
new_bookmark="$bookmark_prefix$(date +"%Y-%m-%d_%H:%M:%S")"
|
||||
|
||||
|
@ -32,19 +32,6 @@ do
|
|||
|
||||
if [[ "$?" == "0" ]]
|
||||
then
|
||||
|
||||
# delete old local bookmarks
|
||||
for destroyable_bookmark in $(zfs list -t bookmark -H -o name "$dataset" | grep "^$dataset#$bookmark_prefix")
|
||||
do
|
||||
zfs destroy "$destroyable_bookmark"
|
||||
done
|
||||
|
||||
# delete snapshots from bookmarks (except newest, even of not necessary; maybe for resuming tho)
|
||||
for destroyable_snapshot in $($ssh sudo zfs list -t snapshot -H -o name "$dataset" | grep "^$dataset@$bookmark_prefix" | grep -v "$new_bookmark")
|
||||
do
|
||||
$ssh sudo zfs destroy "$destroyable_snapshot"
|
||||
done
|
||||
|
||||
zfs bookmark "$dataset@$new_bookmark" "$dataset#$new_bookmark"
|
||||
zfs destroy "$dataset@$new_bookmark"
|
||||
echo "SUCCESS $dataset"
|
||||
|
|
|
@ -54,6 +54,11 @@
|
|||
'device': '/dev/disk/by-id/ata-TOSHIBA_MG06ACA10TE_61C0A1B1FKQE',
|
||||
},
|
||||
},
|
||||
'smartctl': {
|
||||
'/dev/disk/by-id/ata-TOSHIBA_MG06ACA10TE_61C0A1B1FKQE': {
|
||||
'apm': 1,
|
||||
},
|
||||
},
|
||||
'zfs': {
|
||||
'pools': {
|
||||
'tank': {
|
||||
|
|
Loading…
Reference in a new issue