Some of the available packages containing software which start services at boot time. For that we provide simple startup scripts, which are installed into the directory /etc/init.d. See following example for the package dnsmasq, a combined dns and dhcp server daemon:
[label=\file{/etc/init.d/S50dnsmasq}]
#!/bin/sh
. /etc/rc.conf
case $1 in
autostart)
test x"${dns_dhcp:-NO}" = x"NO" && exit 0
exec $0 start
;;
start)
[ -f /etc/dnsmasq.conf ] || exit
/usr/sbin/dnsmasq
;;
stop)
killall dnsmasq
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start | stop | restart}"
;;
esac
exit 0
After installation the package postinst script will add all needed changes to the /etc/ directory. For example packages can add new user and groups, add new variables to /etc/rc.conf or just add new values to existing files as /etc/services. It is FreeWRT policy not to start any services after installation or in case of a new boot. To start services on bootup you need to set $servicename=YES in /etc/rc.conf and commit your changes via fwcf commit. For every policy exists an exception, we start all essential services by default, like ssh daemon, syslog and network initialisation.
For some services you can control the startup behaviour by modifying the $servicename_flags variable in /etc/rc.conf.
For example the variable $ssh_opts is provided as an argument to the dropbear ssh daemon to control its behaviour.
Having this policy helps you to configure your FreeWRT embedded system without shooting yourself in the foot. For example if you try to realize a firewall system and trying to set the rules in /etc/firewall.conf, which is read by /etc/init.d/S45firewall, if the iptables package is installed. You can just reload the changed ruleset via /etc/init.d/S45firewall restart. If you managed to kick you out of the system, you can just reboot the system and you gain access again. As soon as your are ready with the firewall configuration and you decide to activate the firewall rules on bootup, you set firewall=YES in /etc/rc.conf, commit your changes via fwcf commit and reboot. Now the firewall rules will be activated on bootup.