#! /bin/sh is_modem_available() { if [ -z "$(lsusb | grep "2c7c:0125")" ]; then return 1 fi return 0 } TRY=0 while :; do if ! is_modem_available ; then TRY=$((TRY + 1)) echo $(date) Restarting modem, $TRY try systemctl restart eg25-manager systemd-inhibit --what=sleep --why="Modem reset" sleep 60 elif [ $TRY -ne 0 ]; then echo $(date): Modem restarted successfully TRY=0 fi sleep 30 done