Amishkaz
Cadet
- Joined
- Jul 26, 2023
- Messages
- 5
!!Warning this could leed to boot looping if not set properly!!
I just want to post this so that someone might find it usefull i am a noobie so this is simple and easy to understand
Login or switch to shell
First create a bash script file using a command editor like nano
then insert the bash code
Then using the chmod command give excution permission to the script
chmod 777 /bin/script/network.sh
or
chmod +x /bin/script/network.sh
you can check the script by runing it using the command
bash /bin/script/network.sh
Then login to the webUI and go to Tasks > Init/Shutdown Scripts and click ADD
Change the settings as shown below
Use the command
NOTE
if you are planning to use other commands remeber to use the full path for the command
ex: instead of using "ping" use "/sbin/ping"
the full path to a command can be obtained by using "where"
ex:
I just want to post this so that someone might find it usefull i am a noobie so this is simple and easy to understand
Login or switch to shell
First create a bash script file using a command editor like nano
nano /bin/script/reboot.sh
then insert the bash code
#!/usr/bin/env bash
# Function to check network connectivity
check_network() {
if /sbin/ping -q -c 1 192.168.1.1 &> /dev/null; then
return 0 # Network is available
else
return 1 # Network is not available
fi
}
# Main script logic
if check_network; then
echo "Network is available"
else
echo "Network is not available"
shutdown -r now
fi
Then using the chmod command give excution permission to the script
chmod 777 /bin/script/network.sh
or
chmod +x /bin/script/network.sh
you can check the script by runing it using the command
bash /bin/script/network.sh
Then login to the webUI and go to Tasks > Init/Shutdown Scripts and click ADD
Change the settings as shown below
Use the command
bash /bin/script/network.sh
NOTE
if you are planning to use other commands remeber to use the full path for the command
ex: instead of using "ping" use "/sbin/ping"
the full path to a command can be obtained by using "where"
ex:
where ping