If you need to run a script at startup on OpenWrt, creating a custom init script is a simple solution. By following a few steps, you can ensure that your script is automatically executed every time the system boots up.
To create and enable the init script, start by creating a new file in the
/etc/init.d/ directory with a name that starts with “S”. For example, you can name it
/etc/init.d/S99myscript. Then, add the necessary lines to the script to stop the
gl_fan service and set the cooling device state to 255. Save and close the file, and make the script executable by running
chmod +x /etc/init.d/S99myscript. Finally, enable the script to run at startup by running
/etc/init.d/S99myscript enable, and reboot the system to test the script.
It’s important to note that this script will be run at startup only once. If you need to run it multiple times, you can adjust the
STOP variables in the script or remove them altogether. The
START value determines the order in which the script is executed during startup, and the
STOP value determines the order in which the script is executed during shutdown. With these steps, you can easily set up a custom init script and automate tasks or configure system settings on your OpenWrt device.