[{"url":"https://pic-lrc-bed.haf208.cc/img/extra/nas-auto-shutdown/01.webp","alt":"10.2RMB 的 USB 串口继电器模块","title":""},{"url":"https://pic-lrc-bed.haf208.cc/img/extra/nas-auto-shutdown/02.webp","alt":"模块控制参数","title":""},{"url":"https://pic-lrc-bed.haf208.cc/img/extra/nas-auto-shutdown/03.webp","alt":"USB 串口继电器模块","title":""}]
main_func() { # gateway test ping -c 2 $gateway &> /dev/null if [ $? -ne 0 ]; then sleep 120 ping -c 5 $gateway &> /dev/null if [ $? -ne 0 ]; then log_w "网关无法连接,退出进程" exit fi fi
if ! ping_server; then sleep 20 # 防止误判
if ! ping_server; then # wakeonlan -i 192.168.1.255 $server_mac open_server retry_count=1 log_w "Waking up server..." send_mail "启动服务器中""正在启动服务器..." sleep 60 fi
# Retry while ! ping_server; do if ((retry_count >= 3)); then log_w "Server maybe down..." (echo -e "服务器无法连接,请联系管理员处理!!!\n时间:`date_time`" | mail -s '服务器无法连接' -r $post_mail$post_mail[email protected])& exit 1 fi
if ((retry_count == 2)); then sleep 60 log_w "Server maybe stuck, try force shutdown..." echo -ne '\xa0\x01\x01\xa2' > /dev/ttyUSB0 # 开启继电器 sleep 5 echo -ne '\xa0\x01\x00\xa1' > /dev/ttyUSB0 # 关闭继电器 sleep 10 fi