====== Secrets of /etc/init.d/network.sh ====== ===== Introduction ===== SliTaz launches the /etc/init.d/network.sh 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. ===== Usage ===== By default, /etc/init.d/network.sh 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/network.sh start The start arg should be used only at boot. To stop the connection: # /etc/init.d/network.sh stop To stop and restart: # /etc/init.d/network.sh restart But, most interestingly, is that ///etc/init.d/network.sh// 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/network.sh restart /etc/network/Home # /etc/init.d/network.sh restart /etc/network/Desktop # /etc/init.d/network.sh restart /etc/network/Univ # /etc/init.d/network.sh stop ===== Sudo ===== Since /etc/init.d/network.sh/ 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 network.sh from every host; without a password you should add: tux ALL=NOPASSWD: /etc/init.d/network.sh, 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/network.sh, 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. ===== 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/network-menu.sh, and add this to it: #!/bin/sh # # 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 -n '' echo -n "sudo /etc/init.d/network.sh restart" echo '' echo '' # 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 '' echo -n '' echo -n "sudo /etc/init.d/network.sh restart '/etc/network/${REPLY}'" echo '' echo '' done # To stop connections: echo '' echo -n '' echo -n "sudo /etc/init.d/network.sh stop" echo '' echo '' echo '' Make it executable: # chmod +x /usr/lib/openbox/network-menu.sh And now you only have to add these lines in //~/.config/openbox/menu.xml//: Then reconfigure openbox: $ openbox --reconfigure Enjoy! ---- \\ ^ Page Review Section ^^ |Quality| Good | |Review| Minor Updates | |Priority| Medium | |Problems| add a [[http://forum.slitaz.org|forum post link]]| |::: | OR add a [[http://labs.slitaz.org/issues |lab issue tracker link ]]| |How to Improve| Suggest briefly| |::: | | \\ ----