Last active
April 25, 2025 11:27
-
-
Save tuki0918/f081eb43d1aa1a8bde30a75521724040 to your computer and use it in GitHub Desktop.
ルータ FGN-R2 / 自動復帰 再起動スクリプト
This file contains hidden or 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
#!/bin/bash | |
set -eu | |
# FGN-R2 | |
# https://www.fg-products.com/downloads/fgn-r2_manual.pdf | |
# ------------------------------- | |
# Router settings | |
# ------------------------------- | |
ip_router='192.168.150.1' | |
# ------------------------------- | |
# Reboot (60sec) | |
# ------------------------------- | |
# 現在時刻の取得用 | |
now() { | |
date "+%Y-%m-%d %H:%M:%S" | |
} | |
# pingで応答があるかチェック(応答なし=ストールと判断) | |
if ! ping -c 2 $ip_router > /dev/null; then | |
echo "$(now) Router not responding. Rebooting..." | |
curl -X POST http://$ip_router/boafrm/formReboot \ | |
--data "reboot=Apply" | |
else | |
echo "$(now) Router is alive." | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
背景:
停電後など、ルータの再起動をしないとネットワークが復旧しないケースがあった
crontab: