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

Secrets of /etc/init.d/


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 laptop, 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.


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 '<openbox_pipe_menu>'
# for default file:
echo '<item label="Load Default network.conf">'
echo -n '<action name="Execute"><execute>'
echo -n "sudo /etc/init.d/ restart"
echo '</execute></action>'
echo '</item>'
# for other configuration files (you may state a different directory here
# depending on your setup):
# e.g nice for frugal installs:
# ls /home/tux/network/ | while read; do
ls /etc/network/ | while read; do
echo '<item label="'"${REPLY}"'">'
echo -n '<action name="Execute"><execute>'
echo -n "sudo /etc/init.d/ restart '/etc/network/${REPLY}'"
echo '</execute></action>'
echo '</item>'
# To stop connections:
echo '<item label="stop Connection">'
echo -n '<action name="Execute"><execute>'
echo -n "sudo /etc/init.d/ stop"
echo '</execute></action>'
echo '</item>'
echo '</openbox_pipe_menu>' 

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


Page Review Section
Quality Good
Review Minor Updates
Priority Medium
Problems add a forum post link
OR add a lab issue tracker link
How to Improve Suggest briefly

en/guides/network-script.txt · Last modified: 2014/11/15 21:00 by linea