Mirakurun のチューナーが使用されていないことを確認して再起動する
code:reboot.sh
# Mirakurun のチューナーが使用されていないことを確認する
while :
do
ACTIVE_TUNERS=curl http://localhost:40772/api/tuners | jq "[.[].users[] | select(.priority >= 0)] | length"
if $ACTIVE_TUNERS = "0" ; then
break
fi
echo "One of the tuners is in use; sleep for 5 seconds."
sleep 5
done
systemctl reboot
systemd タイマーを使うと、こういう風に書けます
code:scheduled-reboot.timer
Unit=maintenance-reboot.service
OnCalendar=Mon *-*-* 04:00:00
WantedBy=timers.target
code:scheduled-reboot.service
Type=oneshot
ExecStart=/usr/bin/bash /path/to/reboot.sh
これらのユニットをどこかに保存して enable
code:console
$ systemctl enable --now scheduled-reboot.timer