rev |
line source |
slaxemulator@7
|
1 ====== Secrets of /etc/init.d/network.sh ======
|
slaxemulator@7
|
2
|
slaxemulator@7
|
3 ===== Introduction =====
|
slaxemulator@7
|
4
|
slaxemulator@7
|
5 SliTaz launches the /etc/init.d/network.sh at startup to initialize the network. It configures the hostname, loopback interface, and internet connection.
|
slaxemulator@7
|
6
|
slaxemulator@7
|
7 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.
|
slaxemulator@7
|
8
|
slaxemulator@7
|
9 ===== Usage =====
|
slaxemulator@7
|
10
|
slaxemulator@7
|
11 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.
|
slaxemulator@7
|
12
|
slaxemulator@7
|
13 To start the default connection, as when booting:
|
slaxemulator@7
|
14
|
slaxemulator@7
|
15 <code>
|
slaxemulator@7
|
16 # /etc/init.d/network.sh start
|
slaxemulator@7
|
17 </code>
|
slaxemulator@7
|
18
|
slaxemulator@7
|
19 The start arg should be used only at boot. To stop the connection:
|
slaxemulator@7
|
20
|
slaxemulator@7
|
21 <code>
|
slaxemulator@7
|
22 # /etc/init.d/network.sh stop
|
slaxemulator@7
|
23 </code>
|
slaxemulator@7
|
24
|
slaxemulator@7
|
25 To stop and restart:
|
slaxemulator@7
|
26
|
slaxemulator@7
|
27 <code>
|
slaxemulator@7
|
28 # /etc/init.d/network.sh restart
|
slaxemulator@7
|
29 </code>
|
slaxemulator@7
|
30
|
slaxemulator@7
|
31 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.
|
slaxemulator@7
|
32
|
slaxemulator@7
|
33 For example, we can create a directory /etc/network, containing some config files, named:
|
slaxemulator@7
|
34
|
slaxemulator@7
|
35 * Home, for home, using an ethernet connection and a static ip.
|
slaxemulator@7
|
36 * Desktop, for the desktop, with a wep encryption, and a static ip.
|
slaxemulator@7
|
37 * Univ, wifi without encryption, and with dhcp.
|
slaxemulator@7
|
38
|
slaxemulator@7
|
39 Now to get connected at Home, later at a Desktop and finally at Univ, before stopping connection, we only have to:
|
slaxemulator@7
|
40
|
slaxemulator@7
|
41 <code>
|
slaxemulator@7
|
42 # /etc/init.d/network.sh restart /etc/network/Home
|
slaxemulator@7
|
43 # /etc/init.d/network.sh restart /etc/network/Desktop
|
slaxemulator@7
|
44 # /etc/init.d/network.sh restart /etc/network/Univ
|
slaxemulator@7
|
45 # /etc/init.d/network.sh stop
|
slaxemulator@7
|
46 </code>
|
slaxemulator@7
|
47
|
slaxemulator@7
|
48 ===== Sudo =====
|
slaxemulator@7
|
49
|
slaxemulator@7
|
50 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:
|
slaxemulator@7
|
51
|
slaxemulator@7
|
52 <code>
|
slaxemulator@7
|
53 # tazpkg get-install sudo
|
slaxemulator@7
|
54 </code>
|
slaxemulator@7
|
55
|
slaxemulator@7
|
56 And then configure it:
|
slaxemulator@7
|
57
|
slaxemulator@7
|
58 <code>
|
slaxemulator@7
|
59 # visudo
|
slaxemulator@7
|
60 </code>
|
slaxemulator@7
|
61
|
slaxemulator@7
|
62 For user tux, which must use network.sh from every host; without a password you should add:
|
slaxemulator@7
|
63
|
slaxemulator@7
|
64 <file>
|
slaxemulator@7
|
65 tux ALL=NOPASSWD: /etc/init.d/network.sh,
|
slaxemulator@7
|
66 </file>
|
slaxemulator@7
|
67
|
slaxemulator@7
|
68 For user tortux, which may only get connected from localhost, and which should use a password each time, you should add:
|
slaxemulator@7
|
69
|
slaxemulator@7
|
70 <file>
|
slaxemulator@7
|
71 tortux my_hostname=PASSWD: /etc/init.d/network.sh,
|
slaxemulator@7
|
72 </file>
|
slaxemulator@7
|
73
|
slaxemulator@7
|
74 If you forgot your hostname, just run:
|
slaxemulator@7
|
75
|
slaxemulator@7
|
76 <code>
|
slaxemulator@7
|
77 $ cat /etc/hostname
|
slaxemulator@7
|
78 </code>
|
slaxemulator@7
|
79
|
slaxemulator@7
|
80 Here is some help to use visudo:
|
slaxemulator@7
|
81
|
slaxemulator@7
|
82 * i insertion mode (to write).
|
slaxemulator@7
|
83 * Escape exit insertion mode.
|
slaxemulator@7
|
84 * :wq record and quit.
|
slaxemulator@7
|
85 * :q! quit without recording.
|
slaxemulator@7
|
86
|
slaxemulator@7
|
87 ===== Openbox =====
|
slaxemulator@7
|
88
|
slaxemulator@7
|
89 All this is not that really user friendly...
|
slaxemulator@7
|
90
|
slaxemulator@7
|
91 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:
|
slaxemulator@7
|
92
|
slaxemulator@7
|
93 <code bash>
|
slaxemulator@7
|
94 #!/bin/sh
|
slaxemulator@7
|
95 #
|
slaxemulator@7
|
96 # openbox pipe menu to start network connections
|
slaxemulator@7
|
97 # (This script is only useful if sudo is installed, and correctly configured)
|
slaxemulator@7
|
98
|
slaxemulator@7
|
99 echo ''
|
slaxemulator@7
|
100
|
slaxemulator@7
|
101 # for default file:
|
slaxemulator@7
|
102 echo ''
|
slaxemulator@7
|
103 echo ''
|
slaxemulator@7
|
104 echo 'sudo /etc/init.d/network.sh restart'
|
slaxemulator@7
|
105 echo ''
|
slaxemulator@7
|
106
|
slaxemulator@7
|
107 # for others files:
|
slaxemulator@7
|
108 for file in $(ls /etc/network/)
|
slaxemulator@7
|
109 do
|
slaxemulator@7
|
110 echo -e ""
|
slaxemulator@7
|
111 echo ''
|
slaxemulator@7
|
112 echo "sudo /etc/init.d/network.sh restart /etc/network/$file"
|
slaxemulator@7
|
113 echo ''
|
slaxemulator@7
|
114 done
|
slaxemulator@7
|
115
|
slaxemulator@7
|
116 # To stop connections:
|
slaxemulator@7
|
117 echo ''
|
slaxemulator@7
|
118 echo ''
|
slaxemulator@7
|
119 echo 'sudo /etc/init.d/network.sh stop'
|
slaxemulator@7
|
120 echo ''
|
slaxemulator@7
|
121
|
slaxemulator@7
|
122 echo ''
|
slaxemulator@7
|
123 </code>
|
slaxemulator@7
|
124
|
slaxemulator@7
|
125 Make it executable:
|
slaxemulator@7
|
126
|
slaxemulator@7
|
127 <code sh>
|
slaxemulator@7
|
128 # chmod +x /usr/lib/openbox/network-menu.sh
|
slaxemulator@7
|
129 </code>
|
slaxemulator@7
|
130
|
slaxemulator@7
|
131 And now you only have to add these lines in //~/.config/openbox/menu.xml//:
|
slaxemulator@7
|
132
|
slaxemulator@7
|
133 <file>
|
slaxemulator@7
|
134 menu id="network-menu" label="Network"
|
slaxemulator@7
|
135 execute="/usr/lib/openbox/network-menu.sh" />
|
slaxemulator@7
|
136 </file>
|
slaxemulator@7
|
137
|
slaxemulator@7
|
138 Then reconfigure openbox:
|
slaxemulator@7
|
139
|
slaxemulator@7
|
140 <code>
|
slaxemulator@7
|
141 $ openbox --reconfigure
|
slaxemulator@7
|
142 </code>
|
slaxemulator@7
|
143
|
slaxemulator@7
|
144 Enjoy!
|
slaxemulator@7
|
145
|
slaxemulator@7
|
146 ----
|
slaxemulator@7
|
147 \\
|
slaxemulator@7
|
148 ^ Page Review Section ^^
|
slaxemulator@7
|
149 |Quality| Good |
|
slaxemulator@7
|
150 |Review| Minor Updates |
|
slaxemulator@7
|
151 |Priority| Medium |
|
slaxemulator@7
|
152 |Problems| add a [[http://forum.slitaz.org|forum post link]]|
|
slaxemulator@7
|
153 |::: | OR add a [[http://labs.slitaz.org/issues |lab issue tracker link ]]|
|
slaxemulator@7
|
154 |How to Improve| Suggest briefly|
|
slaxemulator@7
|
155 |::: | |
|
slaxemulator@7
|
156
|
slaxemulator@7
|
157 \\
|
slaxemulator@7
|
158 ----
|