SliTaz GNU/Linux official and community documentation wiki.
Translations of this page:

This is an old revision of the document!

Secrets of /etc/init.d/ (cooking)

(By linea)


SliTaz launches the /etc/init.d/ at startup to initialize the network. It configures the hostname, loopback interface, and internet connection.

It's also possible to call the script when SliTaz is started, and use it to open or close internet connections. For example netbox and any software linking get-wifi-firmware (get-ipw2100-firmware, get-b43-firmware…) use it.


By default, /etc/init.d/ uses /etc/network.conf as the conf file. Parameters written in that file are made for the default network connection.

To start the default connection, as when booting:

# /etc/init.d/ start

The start arg should be used only at boot. To stop the connection:

# /etc/init.d/ stop

To stop and restart:

# /etc/init.d/ restart

But, most interestingly, is that /etc/init.d/ may also use another config file. It's useful if you're using a latptop, as you can configure multiple connections for multiple access points.

For example, we can create a directory /etc/network, containing some config files, named:

  • Home, for home, using an ethernet connection and a static ip.
  • Desktop, for the desktop, with a wep encryption, and a static ip.
  • Univ, wifi without encryption, and with dhcp.

Now to get connected at Home, later at a Desktop and finally at Univ, before stopping connection, we only have to:

# /etc/init.d/ restart /etc/network/Home
# /etc/init.d/ restart /etc/network/Desktop
# /etc/init.d/ restart /etc/network/Univ
# /etc/init.d/ stop


Since /etc/init.d/ can only be used by root, if you want a normal user to use it, you should install sudo:

# tazpkg get-install sudo

And then configure it:

# visudo

For user tux, which must use from every host; without a password you should add:

tux  ALL=NOPASSWD: /etc/init.d/,

For user tortux, which may only get connected from localhost, and which should use a password each time, you should add:

tortux my_hostname=PASSWD: /etc/init.d/,

If you forgot your hostname, just run:

$ cat /etc/hostname

Here is some help to use visudo:

  • i insertion mode (to write).
  • Escape exit insertion mode.
  • :wq record and quit.
  • :q! quit without recording.

With Openbox

All this is not that really user friendly…

That's why I'll give you a perfect treat: A way to integrate all this in an openbox menu! Create a script /usr/lib/openbox/, and add this to it:

# openbox pipe menu to start network connections
# (This script is only useful if sudo is installed, and correctly configured)
echo ''
# for default file:
echo ''
echo ''
echo 'sudo /etc/init.d/ restart'
echo ''
# for others files:
for file in $(ls /etc/network/)
	echo -e ""
	echo ''
	echo "sudo /etc/init.d/ restart /etc/network/$file"
	echo ''
# To stop connections:
echo ''
echo ''
echo 'sudo /etc/init.d/ stop'
echo ''
echo ''

Make it executable:

# chmod +x /usr/lib/openbox/

And now you only have to add these lines in ~/.config/openbox/menu.xml:

 menu id="network-menu" label="Network" 
	execute="/usr/lib/openbox/" />

Then reconfigure openbox:

$ openbox --reconfigure


en/guides/network-script.1264445664.txt.gz · Last modified: 2010/07/08 17:17 (external edit)