-
Notifications
You must be signed in to change notification settings - Fork 48
Init Scripts
Init scripts are simple shell scripts that live in /etc/init.d
. There's no dependency management, they are just run in alphabetical order. Naming of these scripts is therefore, important.
The scripts have the following naming convention:
S<XY><service_name>
S
is a fixed letter, XY
is a number of two digits (from 00
to 99
) that dictates the order and service_name
is the name given to the service. For example, S35wifi
will start the WiFi service before S43firewall
will start the firewall.
Init scripts work with a command line argument, which represents the internal command supplied to the script. The following commands are supported by most scripts:
* `start` - mandatory for all init scripts, starts the corresponding service
* `stop` - supported by most init scripts, stops the corresponding service
* `restart` - supported by init scripts that have a `stop` command, internally runs a `stop` followed by a `start`
* `reload` - supported by some init scripts, tries to reload the service configuration without a full restart
Running an init script without arguments should simply print its usage, along with supported commands.
At startup, /etc/init.d/rcS
runs each of these scripts in order, with the start
command. At shutdown, /etc/init.d/rcK
runs each of these scripts in reverse order, with the stop
command. See Boot Process for more details.
Needles to say that init scripts must be executable.
Init scripts can be manually run using commands such as /etc.init.d/<script> restart
. There is however a more convenient way to control them, using the service
helper command. For example, restarting the WiFi service can be done running:
service wifi restart
Given the purpose of thingOS, users probably shouldn't manually disable scripts on their systems. If however one wants a script to be disabled on a particular setup, the presence of a simple, empty file called /data/etc/no_<script>
will prevent the automatic init script execution. For example, the presence of the following file will prevent the WiFi service from starting at boot:
/data/etc/no_S35wifi
- bluetooth.conf
- captive-portal.conf
- cpufreq.conf
- date.conf
- dnsmasq.conf
- docker-compose.yml
- dtoverlays
- dyndns-update.sh
- environment
- firewall.sh
- fstab.user
- hostapd.conf
- ifalias.conf
- localtime
- modprobe.conf
- modules
- mongodb.conf
- netwatch.conf
- ntp.conf
- os.conf
- proftpd.conf
- redis.conf
- smb.conf
- ssh/config
- ssh/sshd_config
- ssl/domain
- ssl/email
- static_ip.conf
- sysctl.conf
- toemmc.conf
- version
- watchdog.conf
- wpa_supplicant.conf