err() { echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: $pre: $*" >&2; }
## begin check on syncthing
-if ! systemctl show --no-page syncthing@ziva | sed -n 's/^MainPID=//p' | egrep '^[0-9]+$' &>/dev/null; then
+if ! systemctl show --no-page syncthing@ziva | sed -n 's/^MainPID=//p' | grep -E '^[0-9]+$' &>/dev/null; then
err no pid for syncthing@ziva. systemctl status:
systemctl status syncthing@ziva
fi
break
fi
- read last_snap_sec last_snap < <(
+ read -r last_snap_sec last_snap < <(
for s in ${snaps[@]}; do
f=${s##*/}
- unix_time=$(date -d $(sed -r 's/(.{4})(..)(.{5})(..)(.*)/\1-\2-\3:\4:\5/' <<<${f#$vol.}) +%s)
+ unix_time=$(date -d "$(sed -r 's/(.{4})(..)(.{5})(..)(.*)/\1-\2-\3:\4:\5/' <<<${f#"$vol".})" +%s)
printf "%s %s\n" $unix_time $s # part of the pipeline
done | sort -r | head -n 1 ||:
)
if [[ ! $last_snap ]]; then
# should not happen.
- err "could not find latest snapshot for $svp among ${snaps[*]}"
+ err "could not find latest snapshot for $vol among ${snaps[*]}"
exit 1
fi
if (( last_snap_sec < EPOCHSECONDS - age_limit_sec )); then