-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
debian/lib/systemd/system/trigger-reboot-all-nodes.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
Description=Trigger reboot all nodes every night on dev environment | ||
Wants=network-online.target cke.service sabakan.service neco-rebooter.service | ||
After=network-online.target cke.service sabakan.service neco-rebooter.service | ||
StartLimitIntervalSec=600s | ||
|
||
[Service] | ||
Type=simple | ||
Restart=on-failure | ||
RestartForceExitStatus=SIGPIPE | ||
RestartSec=30s | ||
ExecStart=/usr/bin/trigger-reboot-all-nodes | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[Unit] | ||
Description=Trigger reboot all nodes every night on dev environment | ||
After=network-online.target cke.service sabakan.service neco-rebooter.service | ||
|
||
[Timer] | ||
# Every day at 18:00:00 (JST) | ||
OnCalendar=*-*-* 09:00:00 | ||
Persistent=true | ||
|
||
[Install] | ||
WantedBy=timers.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/sh | ||
CKECLI_COMMAND="/usr/bin/ckecli" | ||
NECO_COMMAND="/usr/bin/neco" | ||
UNAME_COMMAND="/usr/bin/uname" | ||
YES_COMMAND="/usr/bin/yes" | ||
|
||
ENVIROMENT=$(${NECO_COMMAND} config get env) | ||
if [ "$ENVIROMENT" != "dev" ]; then | ||
echo "This script is only for dev environment" | ||
exit 0 | ||
fi | ||
|
||
# Confirm that host is a learder | ||
HOSTNAME=$(${UNAME_COMMAND} -n) | ||
LEADER=$(${NECO_COMMAND} rebooter leader) | ||
if [ "$HOSTNAME" != "$LEADER" ]; then | ||
echo "This host is not a leader. Skipping reboot all nodes" | ||
exit 0 | ||
fi | ||
|
||
REBOOT_LIST=$(${NECO_COMMAND} rebooter list) | ||
REBOOT_QUEUE=$(${CKECLI_COMMAND} rq list) | ||
# Confirm that the reboot list and reboot queue are empty | ||
if [ "$REBOOT_LIST" != "null" ] || [ "$REBOOT_QUEUE" != "null" ]; then | ||
echo "The reboot list or reboot queueu is not empty. Skipping reboot all nodes" | ||
exit 0 | ||
fi | ||
|
||
$NECO_COMMAND rebooter disable | ||
sh -c $YES_COMMAND | $NECO_COMMAND rebooter reboot-worker --without-state retiring,retired | ||
$NECO_COMMAND rebooter enable |