slitaz-tools annotate tinyutils/netbox @ rev 38
Set window title and icon for *box
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Mon Jan 14 16:28:04 2008 +0100 (2008-01-14) |
parents | 6766819798c7 |
children | bcdf06f0074a |
rev | line source |
---|---|
pankso@33 | 1 #!/bin/sh |
pankso@33 | 2 # |
pankso@33 | 3 # Gtkdialog box to manage network connexion. |
pankso@33 | 4 # - SliTaz GNU/Linux 2008. |
pankso@33 | 5 # |
pankso@33 | 6 VERSION=20080113 |
pankso@33 | 7 |
pankso@33 | 8 # Check if user is root. |
pankso@33 | 9 check_root() |
pankso@33 | 10 { |
pankso@33 | 11 if test $(id -u) != 0 ; then |
pankso@33 | 12 echo -e " |
pankso@33 | 13 You must be root to run `basename $0`. Please type 'su' and |
pankso@33 | 14 root password to become super-user.\n" |
pankso@33 | 15 exit 0 |
pankso@33 | 16 fi |
pankso@33 | 17 } |
pankso@33 | 18 |
pankso@33 | 19 # Interafce status with ifconfig without arguments to show all |
pankso@33 | 20 # active connections. |
pankso@33 | 21 # |
pankso@33 | 22 export IFCONFIG=' |
pankso@38 | 23 <window title="Ifconfig" icon-name="network-wired"> |
pankso@33 | 24 <vbox> |
pankso@33 | 25 <text use-markup="true"> |
pankso@33 | 26 <label>" |
pankso@33 | 27 <b>Active network interfaces</b>" |
pankso@33 | 28 </label> |
pankso@33 | 29 </text> |
pankso@33 | 30 <text wrap="false"> |
pankso@33 | 31 <input>date</input> |
pankso@33 | 32 </text> |
pankso@33 | 33 <frame Ifconfig> |
pankso@33 | 34 <text wrap="false" width-chars="58"> |
pankso@33 | 35 <input>ifconfig</input> |
pankso@33 | 36 </text> |
pankso@33 | 37 </frame> |
pankso@33 | 38 <hbox> |
pankso@33 | 39 <button> |
pankso@33 | 40 <input file icon="exit"></input> |
pankso@33 | 41 <action type="closewindow">IFCONFIG</action> |
pankso@33 | 42 </button> |
pankso@33 | 43 </hbox> |
pankso@33 | 44 </vbox> |
pankso@38 | 45 </window> |
pankso@33 | 46 ' |
pankso@33 | 47 |
pankso@34 | 48 # The main dialog with notebook, start/stop buttons and all options. |
pankso@34 | 49 # Note than /etc/network.conf is seded wehwn an interafce is activate |
pankso@33 | 50 # |
pankso@33 | 51 export NET_BOX=' |
pankso@38 | 52 <window title="Netbox" icon-name="network-wired"> |
pankso@33 | 53 <vbox> |
pankso@33 | 54 <text use-markup="true"> |
pankso@34 | 55 <label> |
pankso@34 | 56 " |
pankso@33 | 57 <b>SliTaz - Netbox</b>" |
pankso@33 | 58 </label> |
pankso@33 | 59 </text> |
pankso@33 | 60 <text wrap="true" width-chars="44"> |
pankso@33 | 61 <label> |
pankso@33 | 62 " |
pankso@33 | 63 Manage network connections getting dynamic IP by |
pankso@33 | 64 DHCP or static IP. Netbox can start or stop networking, |
pankso@33 | 65 configure network interfaces or directly edit files. |
pankso@33 | 66 " |
pankso@33 | 67 </label> |
pankso@33 | 68 </text> |
pankso@33 | 69 |
pankso@33 | 70 <frame General> |
pankso@33 | 71 <hbox> |
pankso@33 | 72 <text use-markup="true"> |
pankso@34 | 73 <label>"<b>Interface :</b>"</label> |
pankso@33 | 74 </text> |
pankso@33 | 75 <entry> |
pankso@33 | 76 <input>. /etc/network.conf; echo $INTERFACE</input> |
pankso@33 | 77 <variable>INTERFACE</variable> |
pankso@33 | 78 </entry> |
pankso@33 | 79 </hbox> |
pankso@33 | 80 </frame> |
pankso@33 | 81 |
pankso@33 | 82 <notebook labels="DHCP|Static IP|System wide"> |
pankso@33 | 83 |
pankso@33 | 84 <frame Udhcpc> |
pankso@33 | 85 <hbox> |
pankso@33 | 86 <text wrap="true"> |
pankso@33 | 87 <label> |
pankso@33 | 88 "The -b options make DHCP client run in background |
pankso@33 | 89 if lease cannot be immediatly negociated." |
pankso@33 | 90 </label> |
pankso@33 | 91 </text> |
pankso@33 | 92 </hbox> |
pankso@33 | 93 <hbox> |
pankso@33 | 94 <text use-markup="true"> |
pankso@34 | 95 <label>"<b>Options :</b>"</label> |
pankso@33 | 96 </text> |
pankso@33 | 97 <entry> |
pankso@33 | 98 <default>-b</default> |
pankso@33 | 99 <variable>UDHCPC_OPTS</variable> |
pankso@33 | 100 </entry> |
pankso@33 | 101 </hbox> |
pankso@33 | 102 <hbox> |
pankso@33 | 103 <button> |
pankso@33 | 104 <label>Start</label> |
pankso@33 | 105 <input file icon="forward"></input> |
pankso@33 | 106 <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE=\"$INTERFACE\"/ /etc/network.conf</action> |
pankso@33 | 107 <action>sed -i s/DHCP=\"no\"/DHCP=\"yes\"/ /etc/network.conf</action> |
pankso@33 | 108 <action>sed -i s/STATIC=\"yes\"/STATIC=\"no\"/ /etc/network.conf</action> |
pankso@33 | 109 <action>udhcpc $UDHCPC_OPTS -i $INTERFACE -p /var/run/udhcpc.$INTERFACE.pid</action> |
pankso@33 | 110 </button> |
pankso@33 | 111 <button> |
pankso@33 | 112 <label>Stop</label> |
pankso@33 | 113 <input file icon="stop"></input> |
pankso@33 | 114 <action>echo -n "Stopping interface : $INTERFACE... "</action> |
pankso@33 | 115 <action>ifconfig $INTERFACE down</action> |
pankso@33 | 116 <action>killall -q udhcpc; echo "done"</action> |
pankso@33 | 117 </button> |
pankso@33 | 118 </hbox> |
pankso@33 | 119 </frame> |
pankso@33 | 120 |
pankso@33 | 121 <frame Configuration> |
pankso@33 | 122 <hbox> |
pankso@33 | 123 <text use-markup="true"> |
pankso@34 | 124 <label>"<b>IP :</b>"</label> |
pankso@33 | 125 </text> |
pankso@33 | 126 <entry> |
pankso@33 | 127 <input>. /etc/network.conf; echo "$IP"</input> |
pankso@33 | 128 <variable>IP</variable> |
pankso@33 | 129 </entry> |
pankso@33 | 130 </hbox> |
pankso@33 | 131 <hbox> |
pankso@33 | 132 <text use-markup="true"> |
pankso@34 | 133 <label>"<b>Netmask :</b>"</label> |
pankso@33 | 134 </text> |
pankso@33 | 135 <entry> |
pankso@33 | 136 <input>. /etc/network.conf; echo "$NETMASK"</input> |
pankso@33 | 137 <variable>NETMASK</variable> |
pankso@33 | 138 </entry> |
pankso@33 | 139 </hbox> |
pankso@33 | 140 <hbox> |
pankso@33 | 141 <text use-markup="true"> |
pankso@34 | 142 <label>"<b>Gateway :</b>"</label> |
pankso@33 | 143 </text> |
pankso@33 | 144 <entry> |
pankso@33 | 145 <input>. /etc/network.conf; echo "$GATEWAY"</input> |
pankso@33 | 146 <variable>GATEWAY</variable> |
pankso@33 | 147 </entry> |
pankso@33 | 148 </hbox> |
pankso@33 | 149 <hbox> |
pankso@33 | 150 <text use-markup="true"> |
pankso@34 | 151 <label>"<b>DNS server :</b>"</label> |
pankso@33 | 152 </text> |
pankso@33 | 153 <entry> |
pankso@33 | 154 <input>. /etc/network.conf; echo "$DNS_SERVER"</input> |
pankso@33 | 155 <variable>DNS_SERVER</variable> |
pankso@33 | 156 </entry> |
pankso@33 | 157 </hbox> |
pankso@33 | 158 <hbox> |
pankso@33 | 159 <button> |
pankso@33 | 160 <label>Start</label> |
pankso@33 | 161 <input file icon="forward"></input> |
pankso@33 | 162 <action>ifconfig lo down</action> |
pankso@33 | 163 <action>ifconfig $INTERFACE down</action> |
pankso@33 | 164 <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE=\"$INTERFACE\"/ /etc/network.conf</action> |
pankso@33 | 165 <action>sed -i s/DHCP=\"yes\"/DHCP=\"no\"/ /etc/network.conf</action> |
pankso@33 | 166 <action>sed -i s/STATIC=\"no\"/STATIC=\"yes\"/ /etc/network.conf</action> |
pankso@33 | 167 <action>sed -i s/`cat /etc/network.conf | grep ^IP=`/IP=\"$IP\"/ /etc/network.conf</action> |
pankso@33 | 168 <action>sed -i s/`cat /etc/network.conf | grep ^NETMASK=`/NETMASK=\"$NETMASK\"/ /etc/network.conf</action> |
pankso@33 | 169 <action>sed -i s/`cat /etc/network.conf | grep ^GATEWAY=`/GATEWAY=\"$GATEWAY\"/ /etc/network.conf</action> |
pankso@33 | 170 <action>sed -i s/`cat /etc/network.conf | grep ^DNS_SERVER=`/DNS_SERVER=\"$DNS_SERVER\"/ /etc/network.conf</action> |
pankso@33 | 171 <action>/etc/init.d/network.sh</action> |
pankso@33 | 172 </button> |
pankso@33 | 173 <button> |
pankso@33 | 174 <label>Stop</label> |
pankso@33 | 175 <input file icon="stop"></input> |
pankso@33 | 176 <action>echo -n "Stopping interface : $INTERFACE... "</action> |
pankso@33 | 177 <action>ifconfig $INTERFACE down; echo "done"</action> |
pankso@33 | 178 </button> |
pankso@33 | 179 </hbox> |
pankso@33 | 180 </frame> |
pankso@33 | 181 |
pankso@33 | 182 <frame Configuration files> |
pankso@33 | 183 <hbox> |
pankso@33 | 184 <text use-markup="true"> |
pankso@34 | 185 <label>"<b>Hosts :</b>"</label> |
pankso@33 | 186 </text> |
pankso@33 | 187 <entry editable="false"> |
pankso@33 | 188 <default>/etc/hosts</default> |
pankso@33 | 189 <variable>HOSTS</variable> |
pankso@33 | 190 </entry> |
pankso@33 | 191 <button> |
pankso@33 | 192 <input file icon="accessories-text-editor"></input> |
pankso@33 | 193 <action type="lauch">leafpad $HOSTS</action> |
pankso@33 | 194 </button> |
pankso@33 | 195 </hbox> |
pankso@33 | 196 <hbox> |
pankso@33 | 197 <text use-markup="true"> |
pankso@34 | 198 <label>"<b>Host name :</b>"</label> |
pankso@33 | 199 </text> |
pankso@33 | 200 <entry editable="false"> |
pankso@33 | 201 <default>/etc/hostname</default> |
pankso@33 | 202 <variable>HOSTNAME</variable> |
pankso@33 | 203 </entry> |
pankso@33 | 204 <button> |
pankso@33 | 205 <input file icon="accessories-text-editor"></input> |
pankso@33 | 206 <action type="lauch">leafpad $HOSTNAME</action> |
pankso@33 | 207 </button> |
pankso@33 | 208 </hbox> |
pankso@33 | 209 <hbox> |
pankso@33 | 210 <text use-markup="true"> |
pankso@34 | 211 <label>"<b>Network :</b>"</label> |
pankso@33 | 212 </text> |
pankso@33 | 213 <entry editable="false"> |
pankso@33 | 214 <default>/etc/network.conf</default> |
pankso@33 | 215 <variable>CONFIG_FILE</variable> |
pankso@33 | 216 </entry> |
pankso@33 | 217 <button> |
pankso@33 | 218 <input file icon="accessories-text-editor"></input> |
pankso@33 | 219 <action type="lauch">leafpad $CONFIG_FILE</action> |
pankso@33 | 220 </button> |
pankso@33 | 221 </hbox> |
pankso@33 | 222 <hbox> |
pankso@33 | 223 <button> |
pankso@33 | 224 <label>Restart</label> |
pankso@33 | 225 <input file icon="reload"></input> |
pankso@33 | 226 <action>echo -n "Stopping interface : $INTERFACE... "</action> |
pankso@33 | 227 <action>ifconfig lo down</action> |
pankso@33 | 228 <action>ifconfig $INTERFACE down</action> |
pankso@33 | 229 <action>killall -q udhcpc; echo "done"</action> |
pankso@33 | 230 <action>/etc/init.d/network.sh</action> |
pankso@33 | 231 </button> |
pankso@33 | 232 </hbox> |
pankso@33 | 233 </frame> |
pankso@33 | 234 |
pankso@33 | 235 </notebook> |
pankso@33 | 236 |
pankso@33 | 237 <hbox> |
pankso@33 | 238 <button> |
pankso@33 | 239 <label>Status</label> |
pankso@33 | 240 <input file icon="network-wired"></input> |
pankso@33 | 241 <action type="launch">IFCONFIG</action> |
pankso@33 | 242 </button> |
pankso@33 | 243 <button> |
pankso@33 | 244 <input file icon="exit"></input> |
pankso@33 | 245 <action type="exit">Exit</action> |
pankso@33 | 246 </button> |
pankso@33 | 247 </hbox> |
pankso@33 | 248 |
pankso@33 | 249 </vbox> |
pankso@38 | 250 </window> |
pankso@33 | 251 ' |
pankso@33 | 252 |
pankso@33 | 253 # Only root can configure network. |
pankso@33 | 254 check_root |
pankso@33 | 255 gtkdialog --program=NET_BOX |
pankso@33 | 256 |
pankso@33 | 257 exit 0 |