slitaz-tools rev 126

netbox: add servers tab
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Apr 08 08:27:19 2008 +0000 (2008-04-08)
parents a47fbf5ad584
children 36695da47702
files tinyutils/netbox
line diff
     1.1 --- a/tinyutils/netbox	Fri Mar 21 14:36:23 2008 +0100
     1.2 +++ b/tinyutils/netbox	Tue Apr 08 08:27:19 2008 +0000
     1.3 @@ -48,7 +48,7 @@
     1.4  # The main dialog with notebook, start/stop buttons and all options.
     1.5  # Note than /etc/network.conf is seded wehwn an interafce is activate
     1.6  #
     1.7 -export NET_BOX='
     1.8 +NET_BOX='
     1.9  <window title="Netbox" icon-name="network-wired">
    1.10    <vbox>
    1.11      <text use-markup="true">
    1.12 @@ -60,9 +60,10 @@
    1.13      <text wrap="true" width-chars="44">
    1.14        <label>
    1.15  "
    1.16 -Manage network connections getting dynamic IP by
    1.17 -DHCP or static IP. Netbox can start or stop networking,
    1.18 -configure network interfaces or directly edit files.
    1.19 +Manage network connections getting dynamic IP
    1.20 +by DHCP or static IP, and setup servers.
    1.21 +Netbox can start or stop networking, configure 
    1.22 +network interfaces or directly edit files.
    1.23  "
    1.24        </label>
    1.25      </text>
    1.26 @@ -79,25 +80,21 @@
    1.27        </hbox>
    1.28      </frame>
    1.29    
    1.30 -    <notebook labels="DHCP|Static IP|System wide">
    1.31 +    <notebook labels="DHCP|Static IP|System wide|Servers">
    1.32    
    1.33      <frame Udhcpc>
    1.34 -            <hbox>
    1.35 -        <text wrap="true">
    1.36 -          <label>
    1.37 -"The -b options make DHCP client run in background 
    1.38 -if lease cannot be immediatly negociated."
    1.39 -          </label>
    1.40 -        </text>
    1.41 -      </hbox>
    1.42        <hbox>
    1.43          <text use-markup="true">
    1.44 -          <label>"<b>Options     :</b>"</label>
    1.45 +          <label>"<b>Options :</b>"</label>
    1.46          </text>
    1.47          <entry>
    1.48            <default>-b</default>
    1.49            <variable>UDHCPC_OPTS</variable>
    1.50          </entry>
    1.51 +        <button>
    1.52 +          <input file icon="help"></input>
    1.53 +	  <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x27 -title "udhcpc help" -e "udhcpc --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
    1.54 +        </button>
    1.55        </hbox>
    1.56        <hbox>
    1.57          <button>
    1.58 @@ -231,6 +228,337 @@
    1.59          </button>
    1.60        </hbox>
    1.61      </frame>
    1.62 +    <notebook labels="'
    1.63 +tmp=''
    1.64 +[ -x /usr/sbin/dropbear ] && NET_BOX="${NET_BOX}${tmp}SSH"   && tmp='|'
    1.65 +[ -x /usr/bin/tftpd     ] && NET_BOX="${NET_BOX}${tmp}TFTP"  && tmp='|' 
    1.66 +[ -x /usr/sbin/udhcpd   ] && NET_BOX="${NET_BOX}${tmp}DHCP"  && tmp='|' 
    1.67 +[ -f /usr/share/boot/pxelinux.0.lzma -a -x /usr/bin/tftpd -a \
    1.68 +  -x /usr/sbin/udhcpd   ] && NET_BOX="${NET_BOX}${tmp}PXE"   && tmp='|'
    1.69 +[ -x /usr/sbin/dnsd     ] && NET_BOX="${NET_BOX}${tmp}DNS"   && tmp='|' 
    1.70 +[ -x /usr/bin/rsync     ] && NET_BOX="${NET_BOX}${tmp}RSYNC" && tmp='|' 
    1.71 +[ -x /usr/sbin/lighttpd ] && NET_BOX="${NET_BOX}${tmp}HTTP"  && tmp='|' 
    1.72 +. /etc/daemons.conf
    1.73 +set -- $DROPBEAR_OPTIONS
    1.74 +while [ -n "$2" ]; do
    1.75 +  [ "$1" = "-b" ] && DROPBEAR_BANNER="$2" && break
    1.76 +  shift
    1.77 +done
    1.78 +NET_BOX="${NET_BOX}\">"
    1.79 +tmp='<frame Dropbear>
    1.80 +      <hbox>
    1.81 +        <text use-markup="true">
    1.82 +          <label>"<b>DROPBEAR_OPTIONS</b>"</label>
    1.83 +        </text>
    1.84 +        <entry editable="false">'
    1.85 +[ -n "$DROPBEAR_OPTIONS" ] && tmp="$tmp<default>$DROPBEAR_OPTIONS</default>"
    1.86 +tmp2='
    1.87 +          <variable>DROPBEAR_OPTS</variable>
    1.88 +        </entry>
    1.89 +        <button>
    1.90 +          <input file icon="help"></input>
    1.91 +	  <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x30 -title "dropbear help" -e "dropbear --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
    1.92 +        </button>
    1.93 +        <button>
    1.94 +          <input file icon="accessories-text-editor"></input>
    1.95 +          <action type="lauch">leafpad /etc/daemons.conf</action>
    1.96 +        </button>
    1.97 +      </hbox>
    1.98 +      <hbox>
    1.99 +        <text use-markup="true">
   1.100 +          <label>"<b>Banner   :</b>"</label>
   1.101 +        </text>
   1.102 +        <entry editable="false">'
   1.103 +[ -n "$DROPBEAR_BANNER" ] && tmp="$tmp$tmp2<default>$DROPBEAR_BANNER</default>"
   1.104 +tmp2='
   1.105 +          <variable>DROPBEAR_BANNER</variable>
   1.106 +        </entry>
   1.107 +        <button>
   1.108 +          <input file icon="accessories-text-editor"></input>
   1.109 +          <action type="lauch">leafpad $DROPBEAR_BANNER</action>
   1.110 +        </button>
   1.111 +      </hbox>
   1.112 +      <hbox>
   1.113 +        <button>
   1.114 +          <label>Start</label>
   1.115 +          <input file icon="forward"></input>
   1.116 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dropbear \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
   1.117 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dropbear \1\"/" /etc/rcS.conf</action>
   1.118 +          <action>/etc/init.d/dropbear start</action>
   1.119 +        </button>
   1.120 +        <button>
   1.121 +          <label>Stop</label>
   1.122 +          <input file icon="stop"></input>
   1.123 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dropbear \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
   1.124 +          <action>/etc/init.d/dropbear stop</action>
   1.125 +        </button>
   1.126 +      </hbox>
   1.127 +     </frame>
   1.128 +'
   1.129 +[ -x /usr/sbin/dropbear ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
   1.130 +set -- $TFTPD_OPTIONS
   1.131 +TFTPD_OPTS=""
   1.132 +while [ -n "$2" ]; do
   1.133 +  TFTPD_OPTS="$TFTPD_OPTS $1"
   1.134 +  shift
   1.135 +done
   1.136 +TFTPD_ROOT="$1"
   1.137 +tmp='<frame Tftpd>
   1.138 +      <hbox>
   1.139 +        <text use-markup="true">
   1.140 +          <label>"<b>TFTPD_OPTIONS</b>"</label>
   1.141 +        </text>
   1.142 +        <entry editable="false">'
   1.143 +[ -n "$TFTPD_OPTS" ] && tmp="$tmp<default>$TFTPD_OPTS</default>"
   1.144 +tmp2='
   1.145 +          <variable>TFTPD_OPTS</variable>
   1.146 +        </entry>
   1.147 +        <button>
   1.148 +          <input file icon="help"></input>
   1.149 +	  <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x13 -title "tftpd help" -e "tftpd --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
   1.150 +        </button>
   1.151 +        <button>
   1.152 +          <input file icon="accessories-text-editor"></input>
   1.153 +          <action type="lauch">leafpad /etc/daemons.conf</action>
   1.154 +        </button>
   1.155 +      </hbox>
   1.156 +      <hbox>
   1.157 +        <text use-markup="true">
   1.158 +          <label>"<b>Root path :</b>"</label>
   1.159 +        </text>
   1.160 +        <entry editable="false">'
   1.161 +tmp="$tmp$tmp2"
   1.162 +[ -n "$TFTPD_ROOT" ] && tmp="$tmp<default>$TFTPD_ROOT</default>"
   1.163 +tmp2='
   1.164 +          <variable>TFTPD_ROOT</variable>
   1.165 +        </entry>
   1.166 +      </hbox>
   1.167 +      <hbox>
   1.168 +        <button>
   1.169 +          <label>Start</label>
   1.170 +          <input file icon="forward"></input>
   1.171 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)tftpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
   1.172 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"tftpd \1\"/" /etc/rcS.conf</action>
   1.173 +          <action>/etc/init.d/tftpd start</action>
   1.174 +        </button>
   1.175 +        <button>
   1.176 +          <label>Stop</label>
   1.177 +          <input file icon="stop"></input>
   1.178 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)tftpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
   1.179 +          <action>/etc/init.d/tftpd start</action>
   1.180 +        </button>
   1.181 +      </hbox>
   1.182 +     </frame>
   1.183 +'
   1.184 +[ -x /usr/bin/tftpd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}" 
   1.185 +tmp='<frame Dhcpd>
   1.186 +      <hbox>
   1.187 +        <text use-markup="true">
   1.188 +          <label>"<b>Configuration :</b>"</label>
   1.189 +        </text>
   1.190 +        <entry editable="false">
   1.191 +          <default>/etc/udhcpd.conf</default>
   1.192 +          <variable>UDHCPD_CONF</variable>
   1.193 +        </entry>
   1.194 +        <button>
   1.195 +          <input file icon="accessories-text-editor"></input>
   1.196 +          <action type="lauch">leafpad $UDHCPD_CONF</action>
   1.197 +        </button>
   1.198 +      </hbox>
   1.199 +      <hbox>
   1.200 +        <button>
   1.201 +          <label>Start</label>
   1.202 +          <input file icon="forward"></input>
   1.203 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
   1.204 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"udhcpd \1\"/" /etc/rcS.conf</action>
   1.205 +          <action>/etc/init.d/udhcpd start</action>
   1.206 +        </button>
   1.207 +        <button>
   1.208 +          <label>Stop</label>
   1.209 +          <input file icon="stop"></input>
   1.210 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
   1.211 +          <action>/etc/init.d/udhcpd stop</action>
   1.212 +        </button>
   1.213 +      </hbox>
   1.214 +     </frame>
   1.215 +'
   1.216 +[ -x /usr/sbin/udhcpd   ] && NET_BOX="${NET_BOX}${tmp}" 
   1.217 +tmp='<frame Pxelinux>
   1.218 +      <hbox>
   1.219 +        <text wrap="true">
   1.220 +          <label>
   1.221 +"Tftpd and Dhcpd must be lauched to start the PXE service."
   1.222 +          </label>
   1.223 +        </text>
   1.224 +      </hbox>
   1.225 +      <hbox>
   1.226 +        <text use-markup="true">
   1.227 +          <label>"<b>Configuration :</b>"</label>
   1.228 +        </text>
   1.229 +        <entry editable="false">
   1.230 +          <default>pxelinux.cfg/default</default>
   1.231 +          <variable>PXE_CONF</variable>
   1.232 +        </entry>
   1.233 +        <button>
   1.234 +          <input file icon="accessories-text-editor"></input>
   1.235 +	  <action>dir=$(dirname $TFTPD_ROOT/$PXE_CONF); [ -d $dir ] || mkdir -p $dir</action>
   1.236 +	  <action>lzma d /usr/share/boot/pxelinux.0.lzma $TFTPD_ROOT/pxelinux.0</action>
   1.237 +	  <action>grep "^option bootfile=pxelinux.0" $UDHCPD_CONF || echo "option bootfile=pxelinux.0" >> $UDHCPD_CONF</action>
   1.238 +	  <action>[ -f $TFTPD_ROOT/$PXE_CONF ] || echo -e "label slitaz\n\tkernel bzImage\n\tappend initrd=rootfs.gz rw root=/dev/null vga=normal" > $TFTPD_ROOT/$PXE_CONF</action>
   1.239 +          <action type="lauch">leafpad $TFTPD_ROOT/$PXE_CONF</action>
   1.240 +        </button>
   1.241 +      </hbox>
   1.242 +     </frame>
   1.243 +'
   1.244 +[ -f /usr/share/syslinux/pxelinux.0 -a -x /usr/bin/tftpd -a \
   1.245 +  -x /usr/sbin/udhcpd   ] && NET_BOX="${NET_BOX}${tmp}"
   1.246 +tmp='<frame Dnsd>
   1.247 +      <hbox>
   1.248 +        <text use-markup="true">
   1.249 +          <label>"<b>DNSD_OPTIONS</b>"</label>
   1.250 +        </text>
   1.251 +        <entry editable="false">'
   1.252 +[ -n "$DNSD_OPTIONS" ] && tmp="$tmp<default>$DNSD_OPTIONS</default>"
   1.253 +tmp2='
   1.254 +          <variable>DNSD_OPTS</variable>
   1.255 +        </entry>
   1.256 +        <button>
   1.257 +          <input file icon="help"></input>
   1.258 +	  <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x15 -title "dnsd help" -e "dnsd --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
   1.259 +        </button>
   1.260 +        <button>
   1.261 +          <input file icon="accessories-text-editor"></input>
   1.262 +          <action type="lauch">leafpad /etc/daemons.conf</action>
   1.263 +        </button>
   1.264 +      </hbox>
   1.265 +      <hbox>
   1.266 +        <text use-markup="true">
   1.267 +          <label>"<b>Configuration :</b>"</label>
   1.268 +        </text>
   1.269 +        <entry editable="false">
   1.270 +          <default>/etc/dnsd.conf</default>
   1.271 +          <variable>DNSD_CONF</variable>
   1.272 +        </entry>
   1.273 +        <button>
   1.274 +          <input file icon="accessories-text-editor"></input>
   1.275 +          <action type="lauch">leafpad $DNSD_CONF</action>
   1.276 +        </button>
   1.277 +      </hbox>
   1.278 +      <hbox>
   1.279 +        <button>
   1.280 +          <label>Start</label>
   1.281 +          <input file icon="forward"></input>
   1.282 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
   1.283 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dnsd \1\"/" /etc/rcS.conf</action>
   1.284 +          <action>/etc/init.d/dnsd start</action>
   1.285 +        </button>
   1.286 +        <button>
   1.287 +          <label>Stop</label>
   1.288 +          <input file icon="stop"></input>
   1.289 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
   1.290 +          <action>/etc/init.d/dnsd stop</action>
   1.291 +        </button>
   1.292 +      </hbox>
   1.293 +     </frame>
   1.294 +'
   1.295 +[ -x /usr/sbin/dnsd     ] && NET_BOX="${NET_BOX}${tmp}${tmp2}" 
   1.296 +tmp='<frame Rsync>
   1.297 +      <hbox>
   1.298 +        <text use-markup="true">
   1.299 +          <label>"<b>RSYNCD_OPTIONS</b>"</label>
   1.300 +        </text>
   1.301 +        <entry editable="false">'
   1.302 +[ -n "${RSYNCD_OPTIONS#* }" ] && tmp="$tmp<default>${RSYNCD_OPTIONS#* }</default>"
   1.303 +tmp2='
   1.304 +          <variable>RSYNC_OPTS</variable>
   1.305 +        </entry>
   1.306 +        <button>
   1.307 +          <input file icon="help"></input>
   1.308 +	  <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x30 -title "rsync daemon help" -e "rsync --daemon --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
   1.309 +        </button>
   1.310 +        <button>
   1.311 +          <input file icon="accessories-text-editor"></input>
   1.312 +          <action type="lauch">leafpad /etc/daemons.conf</action>
   1.313 +        </button>
   1.314 +      </hbox>
   1.315 +      <hbox>
   1.316 +        <text use-markup="true">
   1.317 +          <label>"<b>Configuration :</b>"</label>
   1.318 +        </text>
   1.319 +        <entry editable="false">
   1.320 +          <default>/etc/rsyncd.conf</default>
   1.321 +          <variable>RSYNCD_CONF</variable>
   1.322 +        </entry>
   1.323 +        <button>
   1.324 +          <input file icon="accessories-text-editor"></input>
   1.325 +          <action type="lauch">leafpad $RSYNCD_CONF</action>
   1.326 +        </button>
   1.327 +      </hbox>
   1.328 +      <hbox>
   1.329 +        <text use-markup="true">
   1.330 +          <label>"<b>Secrets file     :</b>"</label>
   1.331 +        </text>
   1.332 +        <entry editable="true">
   1.333 +          <default>/etc/rsyncd.secrets</default>
   1.334 +          <variable>RSYNCD_SECRETS</variable>
   1.335 +        </entry>
   1.336 +        <button>
   1.337 +          <input file icon="accessories-text-editor"></input>
   1.338 +          <action type="lauch">leafpad $RSYNCD_SECRETS</action>
   1.339 +        </button>
   1.340 +      </hbox>
   1.341 +      <hbox>
   1.342 +        <button>
   1.343 +          <label>Start</label>
   1.344 +          <input file icon="forward"></input>
   1.345 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
   1.346 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"rsyncd \1\"/" /etc/rcS.conf</action>
   1.347 +          <action>/etc/init.d/rsyncd start</action>
   1.348 +        </button>
   1.349 +        <button>
   1.350 +          <label>Stop</label>
   1.351 +          <input file icon="stop"></input>
   1.352 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
   1.353 +          <action>/etc/init.d/rsyncd stop</action>
   1.354 +        </button>
   1.355 +      </hbox>
   1.356 +     </frame>
   1.357 +'
   1.358 +[ -x /usr/bin/rsync    ] && NET_BOX="${NET_BOX}${tmp}${tmp2}" 
   1.359 +tmp='<frame Lighttpd>
   1.360 +      <hbox>
   1.361 +        <text use-markup="true">
   1.362 +          <label>"<b>Configuration :</b>"</label>
   1.363 +        </text>
   1.364 +        <entry editable="false">
   1.365 +          <default>/etc/lighttpd/lighttpd.conf</default>
   1.366 +          <variable>LIGHTTPD_CONF</variable>
   1.367 +        </entry>
   1.368 +        <button>
   1.369 +          <input file icon="accessories-text-editor"></input>
   1.370 +          <action type="lauch">leafpad $LIGHTTPD_CONF</action>
   1.371 +        </button>
   1.372 +      </hbox>
   1.373 +      <hbox>
   1.374 +        <button>
   1.375 +          <label>Start</label>
   1.376 +          <input file icon="forward"></input>
   1.377 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
   1.378 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"lighttpd \1\"/" /etc/rcS.conf</action>
   1.379 +          <action>/etc/init.d/lighttpd start</action>
   1.380 +        </button>
   1.381 +        <button>
   1.382 +          <label>Stop</label>
   1.383 +          <input file icon="stop"></input>
   1.384 +          <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
   1.385 +          <action>/etc/init.d/lighttpd stop</action>
   1.386 +        </button>
   1.387 +      </hbox>
   1.388 +     </frame>
   1.389 +'
   1.390 +[ -x /usr/sbin/lighttpd ] && NET_BOX="${NET_BOX}${tmp}" 
   1.391 +tmp='
   1.392 +    </notebook>
   1.393      
   1.394      </notebook>
   1.395  
   1.396 @@ -249,6 +577,13 @@
   1.397    </vbox>
   1.398  </window>
   1.399  '
   1.400 +NET_BOX="${NET_BOX}${tmp}" 
   1.401 +
   1.402 +export NET_BOX
   1.403 +
   1.404 +# TODO: Servers/VNC(X11vnc) Servers/SMB(Samba)
   1.405 +# Modules(Network kernel module) Firewall(Iptables) VPN(OpenVPN)
   1.406 +# TODO: Status: running servers
   1.407  
   1.408  # Only root can configure network.
   1.409  check_root