slitaz-doc-wiki-data diff pages/en/guides/network-script.txt @ rev 7
Add pages/en folder.
author | Christopher Rogers <slaxemulator@gmail.com> |
---|---|
date | Sat Feb 26 12:17:18 2011 +0000 (2011-02-26) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/pages/en/guides/network-script.txt Sat Feb 26 12:17:18 2011 +0000 1.3 @@ -0,0 +1,158 @@ 1.4 +====== Secrets of /etc/init.d/network.sh ====== 1.5 + 1.6 +===== Introduction ===== 1.7 + 1.8 +SliTaz launches the /etc/init.d/network.sh at startup to initialize the network. It configures the hostname, loopback interface, and internet connection. 1.9 + 1.10 +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. 1.11 + 1.12 +===== Usage ===== 1.13 + 1.14 +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. 1.15 + 1.16 +To start the default connection, as when booting: 1.17 + 1.18 +<code> 1.19 +# /etc/init.d/network.sh start 1.20 +</code> 1.21 + 1.22 +The start arg should be used only at boot. To stop the connection: 1.23 + 1.24 +<code> 1.25 +# /etc/init.d/network.sh stop 1.26 +</code> 1.27 + 1.28 +To stop and restart: 1.29 + 1.30 +<code> 1.31 +# /etc/init.d/network.sh restart 1.32 +</code> 1.33 + 1.34 +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. 1.35 + 1.36 +For example, we can create a directory /etc/network, containing some config files, named: 1.37 + 1.38 + * Home, for home, using an ethernet connection and a static ip. 1.39 + * Desktop, for the desktop, with a wep encryption, and a static ip. 1.40 + * Univ, wifi without encryption, and with dhcp. 1.41 + 1.42 +Now to get connected at Home, later at a Desktop and finally at Univ, before stopping connection, we only have to: 1.43 + 1.44 +<code> 1.45 +# /etc/init.d/network.sh restart /etc/network/Home 1.46 +# /etc/init.d/network.sh restart /etc/network/Desktop 1.47 +# /etc/init.d/network.sh restart /etc/network/Univ 1.48 +# /etc/init.d/network.sh stop 1.49 +</code> 1.50 + 1.51 +===== Sudo ===== 1.52 + 1.53 +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: 1.54 + 1.55 +<code> 1.56 +# tazpkg get-install sudo 1.57 +</code> 1.58 + 1.59 +And then configure it: 1.60 + 1.61 +<code> 1.62 +# visudo 1.63 +</code> 1.64 + 1.65 +For user tux, which must use network.sh from every host; without a password you should add: 1.66 + 1.67 +<file> 1.68 +tux ALL=NOPASSWD: /etc/init.d/network.sh, 1.69 +</file> 1.70 + 1.71 +For user tortux, which may only get connected from localhost, and which should use a password each time, you should add: 1.72 + 1.73 +<file> 1.74 +tortux my_hostname=PASSWD: /etc/init.d/network.sh, 1.75 +</file> 1.76 + 1.77 +If you forgot your hostname, just run: 1.78 + 1.79 +<code> 1.80 +$ cat /etc/hostname 1.81 +</code> 1.82 + 1.83 +Here is some help to use visudo: 1.84 + 1.85 + * i insertion mode (to write). 1.86 + * Escape exit insertion mode. 1.87 + * :wq record and quit. 1.88 + * :q! quit without recording. 1.89 + 1.90 +===== Openbox ===== 1.91 + 1.92 +All this is not that really user friendly... 1.93 + 1.94 +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: 1.95 + 1.96 +<code bash> 1.97 +#!/bin/sh 1.98 +# 1.99 +# openbox pipe menu to start network connections 1.100 +# (This script is only useful if sudo is installed, and correctly configured) 1.101 + 1.102 +echo '' 1.103 + 1.104 +# for default file: 1.105 +echo '' 1.106 +echo '' 1.107 +echo 'sudo /etc/init.d/network.sh restart' 1.108 +echo '' 1.109 + 1.110 +# for others files: 1.111 +for file in $(ls /etc/network/) 1.112 + do 1.113 + echo -e "" 1.114 + echo '' 1.115 + echo "sudo /etc/init.d/network.sh restart /etc/network/$file" 1.116 + echo '' 1.117 + done 1.118 + 1.119 +# To stop connections: 1.120 +echo '' 1.121 +echo '' 1.122 +echo 'sudo /etc/init.d/network.sh stop' 1.123 +echo '' 1.124 + 1.125 +echo '' 1.126 +</code> 1.127 + 1.128 +Make it executable: 1.129 + 1.130 +<code sh> 1.131 +# chmod +x /usr/lib/openbox/network-menu.sh 1.132 +</code> 1.133 + 1.134 +And now you only have to add these lines in //~/.config/openbox/menu.xml//: 1.135 + 1.136 +<file> 1.137 + menu id="network-menu" label="Network" 1.138 + execute="/usr/lib/openbox/network-menu.sh" /> 1.139 +</file> 1.140 + 1.141 +Then reconfigure openbox: 1.142 + 1.143 +<code> 1.144 +$ openbox --reconfigure 1.145 +</code> 1.146 + 1.147 +Enjoy! 1.148 + 1.149 +---- 1.150 +\\ 1.151 +^ Page Review Section ^^ 1.152 +|Quality| Good | 1.153 +|Review| Minor Updates | 1.154 +|Priority| Medium | 1.155 +|Problems| add a [[http://forum.slitaz.org|forum post link]]| 1.156 +|::: | OR add a [[http://labs.slitaz.org/issues |lab issue tracker link ]]| 1.157 +|How to Improve| Suggest briefly| 1.158 +|::: | | 1.159 + 1.160 +\\ 1.161 +----