slitaz-doc-wiki-data view pages/fr/guides/network-script.txt @ rev 4

Add pages/fr folder.
author Christopher Rogers <slaxemulator@gmail.com>
date Sat Feb 26 12:13:35 2011 +0000 (2011-02-26)
parents
children b8e0b134ba24
line source
1 ====== Les secrets du script /etc/init.d/network.sh ======
3 ===== Introduction =====
5 Au démarrage du système SliTaz exécute le fichier ///etc/init.d/network.sh // pour initialiser le réseau.
6 Ce script configure le nom d'ôte, l'interface de boclage (loopback) et la connexion Internet.
8 Il est également possible de lancer ce script pendant l'éxecution du système pour ouvrir ou fermer les connexions réseaux.
9 Par exemple **netbox** et les scripts get-wifi-firmware (get-ipw2100-firmware, get-b43-firmware...) l'utilise.
12 ===== Utilisation =====
14 Par défaut le script ///etc/init.d/network.sh// utilise ///etc/network.conf// comme fichier de configuration.
15 Les informations contenu dans ce fichier, sont utilisées comme valeurs initiales pour la connexion réseau.
17 Pour démarrer la connexion réseau entrez:
19 <code>
20 # /etc/init.d/network.sh start
21 </code>
23 The start arg should be used only at boot. Pour arrêter la connexion:
25 <code>
26 # /etc/init.d/network.sh stop
27 </code>
29 Pour arrêter et redémarrer:
31 <code>
32 # /etc/init.d/network.sh restart
33 </code>
35 Mais le plus intéressant est que ///etc/init.d/network.sh// peut utiliser plusieurs fichiers de configuration.
36 C'est très pratique si vous utilisez un PC portable avec plusieurs connections.
38 For example, we can create a directory /etc/network, containing some config files, named:
40 * Home, for home, using an ethernet connection and a static ip.
41 * Desktop, for the desktop, with a wep encryption, and a static ip.
42 * Univ, wifi without encryption, and with dhcp.
44 Now to get connected at Home, later at a Desktop and finally at Univ, before stopping connection, we only have to:
46 <code>
47 # /etc/init.d/network.sh restart /etc/network/Home
48 # /etc/init.d/network.sh restart /etc/network/Desktop
49 # /etc/init.d/network.sh restart /etc/network/Univ
50 # /etc/init.d/network.sh stop
51 </code>
53 ===== Sudo =====
55 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:
57 <code>
58 # tazpkg get-install sudo
59 </code>
61 And then configure it:
63 <code>
64 # visudo
65 </code>
67 For user tux, which must use network.sh from every host; without a password you should add:
69 <code bash>
70 tux ALL=NOPASSWD: /etc/init.d/network.sh,
71 </code>
73 For user tortux, which may only get connected from localhost, and which should use a password each time, you should add:
75 <code bash>
76 tortux my_hostname=PASSWD: /etc/init.d/network.sh,
77 </code>
79 If you forgot your hostname, just run:
81 <code>
82 $ cat /etc/hostname
83 </code>
85 Here is some help to use visudo:
87 * i insertion mode (to write).
88 * Escape exit insertion mode.
89 * :wq record and quit.
90 * :q! quit without recording.
92 ===== With Openbox =====
94 All this is not that really user friendly...
96 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:
98 <code bash>
99 #!/bin/sh
100 #
101 # openbox pipe menu to start network connections
102 # (This script is only useful if sudo is installed, and correctly configured)
104 echo ''
106 # for default file:
107 echo ''
108 echo ''
109 echo 'sudo /etc/init.d/network.sh restart'
110 echo ''
112 # for others files:
113 for file in $(ls /etc/network/)
114 do
115 echo -e ""
116 echo ''
117 echo "sudo /etc/init.d/network.sh restart /etc/network/$file"
118 echo ''
119 done
121 # To stop connections:
122 echo ''
123 echo ''
124 echo 'sudo /etc/init.d/network.sh stop'
125 echo ''
127 echo ''
128 </code>
130 Make it executable:
132 <code sh>
133 # chmod +x /usr/lib/openbox/network-menu.sh
134 </code>
136 And now you only have to add these lines in //~/.config/openbox/menu.xml//:
138 <code bash>
139 menu id="network-menu" label="Network"
140 execute="/usr/lib/openbox/network-menu.sh" />
141 </code>
143 Then reconfigure openbox:
145 <code>
146 $ openbox --reconfigure
147 </code>
149 Enjoy!