slitaz-tools rev 462

add serverbox (separated from netbox)
author Rohit Joshi <jozee@slitaz.org>
date Wed Mar 24 06:36:22 2010 -0400 (2010-03-24)
parents 612580c57250
children aa61397a4475
files tinyutils/serverbox
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tinyutils/serverbox	Wed Mar 24 06:36:22 2010 -0400
     1.3 @@ -0,0 +1,748 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# Gtkdialog box to manage servers.
     1.7 +# Please use tab to indent.
     1.8 +
     1.9 +VERSION=20100315
    1.10 +
    1.11 +. /usr/lib/slitaz/gui_functions
    1.12 +
    1.13 +# Check if user is root.
    1.14 +check_root()
    1.15 +{
    1.16 +	if test $(id -u) != 0 ; then
    1.17 +		echo -e "
    1.18 +You must be root to run `basename $0`. Please type 'su' and
    1.19 +root password to become super-user.\n"
    1.20 +		exit 0
    1.21 +	fi
    1.22 +}
    1.23 +#
    1.24 +# Status servers
    1.25 +#
    1.26 +tab_status_servers()
    1.27 +{
    1.28 +local servers
    1.29 +servers="dropbear sshd inetd dhcpd dnsd named rsync httpd mbd vnc pppd knock"
    1.30 +cat <<EOT
    1.31 +<frame Servers>
    1.32 +	<text wrap="false" width-chars="58">
    1.33 +		<input>for i in $servers; do ps ww | grep \$i | grep -v grep | fold -s; done</input>
    1.34 +	</text>
    1.35 +</frame>
    1.36 +EOT
    1.37 +}
    1.38 +
    1.39 +data_status()
    1.40 +{
    1.41 +cat <<EOT
    1.42 +ps          Servers               tab_status_servers
    1.43 +EOT
    1.44 +}
    1.45 +
    1.46 +#
    1.47 +# Status
    1.48 +#
    1.49 +tab_status()
    1.50 +{
    1.51 +use_tab data_status
    1.52 +}
    1.53 +
    1.54 +sshremote()
    1.55 +{
    1.56 +	cat << EOT
    1.57 +      <hbox>
    1.58 +        <text use-markup="true">
    1.59 +          <label>"<b>Remote  :</b>"</label>
    1.60 +        </text>
    1.61 +        <entry>
    1.62 +          <variable>$2</variable>
    1.63 +	  <default>user@elsewhere</default>
    1.64 +        </entry>
    1.65 +        <button>
    1.66 +          <input file icon="utilities-terminal"></input>
    1.67 +	  <label>Connect</label>
    1.68 +	  <action>xterm -fa MiscFixed -fs 11 -bg black -fg white -geometry 80x25 -title "$1" -e "$1 \$$2 ; echo -e \"----\nENTER to continue...\" && read close" &</action>
    1.69 +        </button>
    1.70 +        <button>
    1.71 +          <input file icon="go-up"></input>
    1.72 +	  <label>Send key</label>
    1.73 +	  <action>$xterm -geometry 80x10 -title "send ssh key" -e "$0 call sendsshkey \$$2; echo -e \"----\nENTER to continue...\" && read close"</action>
    1.74 +        </button>
    1.75 +      </hbox>
    1.76 +EOT
    1.77 +}
    1.78 +#
    1.79 +# Dropbear client & server
    1.80 +#
    1.81 +tab_dropbear()
    1.82 +{
    1.83 +. /etc/daemons.conf
    1.84 +set -- $DROPBEAR_OPTIONS
    1.85 +while [ -n "$2" ]; do
    1.86 +  [ "$1" = "-b" ] && DROPBEAR_BANNER="$2" && break
    1.87 +  shift
    1.88 +done
    1.89 +
    1.90 +cat <<EOT
    1.91 +     <frame Dropbear>
    1.92 +$(helpdaemon dropbear 80x30 DROPBEAR_OPTIONS DROPBEAR_OPTS)
    1.93 +$(datafile /etc/dropbear/banner DROPBEAR_BANNER 'Banner   :')
    1.94 +$(sshremote DROPBEAR_PEER 'dbclient -i /etc/dropbear/dropbear_rsa_host_key')
    1.95 +      <hbox>
    1.96 +	$(startstopdaemon dropbear)
    1.97 +      </hbox>
    1.98 +     </frame>
    1.99 +EOT
   1.100 +}
   1.101 +
   1.102 +#
   1.103 +# OpenSSH client & server
   1.104 +#
   1.105 +tab_openssh()
   1.106 +{
   1.107 +cat <<EOT
   1.108 +    <frame OpenSSH>
   1.109 +$(helpdaemon sshd 80x30 OPENSSH_OPTIONS OPENSSH_OPTS 8 nohelp)
   1.110 +$(configfile /etc/ssh/sshd_config OPENSSH_CONF '5 sshd_config')
   1.111 +$(sshremote OPENSSH_PEER 'ssh -i /etc/ssh/ssh_host_rsa_key')
   1.112 +      <hbox>
   1.113 +	$(startstopdaemon openssh)
   1.114 +      </hbox>
   1.115 +     </frame>
   1.116 +EOT
   1.117 +}
   1.118 +
   1.119 +data_sshd()
   1.120 +{
   1.121 +cat <<EOT
   1.122 +dropbear    Dropbear      tab_dropbear
   1.123 +sshd        OpenSSH       tab_openssh
   1.124 +EOT
   1.125 +}
   1.126 +
   1.127 +#
   1.128 +# SSH tab
   1.129 +#
   1.130 +tab_sshd()
   1.131 +{
   1.132 +use_tab data_sshd
   1.133 +}
   1.134 +
   1.135 +#
   1.136 +# Busybox Inetd
   1.137 +#
   1.138 +tab_inetd()
   1.139 +{
   1.140 +cat <<EOT
   1.141 +<frame Inetd (busybox)>
   1.142 +$(helpdaemon inetd 60x14 INETD_OPTIONS INETD_OPTS)
   1.143 +$(configfile /etc/inetd.conf INETD_CONF)
   1.144 +      <hbox>
   1.145 +EOT
   1.146 +for i in $(grep bin /etc/inetd.conf | awk '{ print $6}'); do
   1.147 +  i=$(basename $i)
   1.148 +  helpbutton $i 60x19 $i
   1.149 +done
   1.150 +cat <<EOT
   1.151 +	$(startstopdaemon inetd)
   1.152 +      </hbox>
   1.153 +     </frame>
   1.154 +EOT
   1.155 +}
   1.156 +
   1.157 +#
   1.158 +# ZeroConf
   1.159 +#
   1.160 +tab_zcip()
   1.161 +{
   1.162 +	
   1.163 +	. /etc/daemons.conf
   1.164 +if [ -x /sbin/zcip -a -z "$ZCIP_OPTIONS" ]; then
   1.165 +	ZCIP_OPTIONS="eth0 /etc/zcip.script"
   1.166 +	cat >> /etc/daemons.conf <<EOT
   1.167 +# ZeroConf options
   1.168 +ZCIP_OPTIONS="$ZCIP_OPTIONS"
   1.169 +
   1.170 +EOT
   1.171 +fi
   1.172 +cat <<EOT
   1.173 +     <frame Zcip (busybox)>
   1.174 +$(helpdaemon zcip 60x14 ZCIP_OPTIONS ZCIP_OPTS)
   1.175 +$(datafile /etc/zcip.script CZIP_SCRIPT 'Script :')
   1.176 +      <hbox>
   1.177 +	$(startstopdaemon zcip)
   1.178 +      </hbox>
   1.179 +     </frame>
   1.180 +EOT
   1.181 +}
   1.182 +
   1.183 +#
   1.184 +# Dhcpd ISC
   1.185 +#
   1.186 +tab_isc_dhcpd()
   1.187 +{
   1.188 +cat <<EOT
   1.189 +    <frame Dhcpd (ISC)>
   1.190 +$(helpdaemon dhcpd 60x14 DHCPD_OPTIONS DHCPD_OPTS)
   1.191 +$(configfile /etc/dhcpd.conf DHCPD_CONF)
   1.192 +      <hbox>
   1.193 +	$(startstopdaemon dhcpd dhcp)
   1.194 +      </hbox>
   1.195 +     </frame>
   1.196 +EOT
   1.197 +}
   1.198 +
   1.199 +#
   1.200 +# Dhcpd Busybox
   1.201 +#
   1.202 +tab_udhcpd()
   1.203 +{
   1.204 +cat <<EOT
   1.205 +    <frame Udhcpd (busybox)>
   1.206 +$(helpdaemon udhcpd 60x14 UDHCPD_OPTIONS UDHCPD_OPTS)
   1.207 +$(configfile /etc/udhcpd.conf UDHCPD_CONF)
   1.208 +      <hbox>
   1.209 +	$(startstopdaemon udhcpd busybox)
   1.210 +      </hbox>
   1.211 +     </frame>
   1.212 +EOT
   1.213 +}
   1.214 +
   1.215 +data_dhcpd()
   1.216 +{
   1.217 +cat <<EOT
   1.218 +udhcpd      Udhcpd        tab_udhcpd
   1.219 +dhcpd       Dhcpd         tab_isc_dhcpd
   1.220 +dnsmasq     DNSmasq       tab_dnsmasq
   1.221 +EOT
   1.222 +}
   1.223 +
   1.224 +#
   1.225 +# dhcpd tab
   1.226 +#
   1.227 +tab_dhcpd()
   1.228 +{
   1.229 +use_tab data_dhcpd
   1.230 +}
   1.231 +
   1.232 +#
   1.233 +# PXE forwarder
   1.234 +#
   1.235 +tab_gpxe()
   1.236 +{
   1.237 +cat <<EOT
   1.238 +<frame PXE forwarder>
   1.239 +      <hbox>
   1.240 +        <text use-markup="true">
   1.241 +          <label>"<b>WEB boot URL(s) :</b>"</label>
   1.242 +        </text>
   1.243 +      </hbox>
   1.244 +      <hbox>
   1.245 +        <entry editable="true">
   1.246 +          <default>
   1.247 +"$(dd bs=1 skip=5 count=255 if=/usr/share/boot/gpxe.pxe 2> /dev/null | strings)"
   1.248 +          </default>
   1.249 +          <variable>WEB_PXE</variable>
   1.250 +        </entry>
   1.251 +      </hbox>
   1.252 +      <hbox>
   1.253 +$(wikibutton http://wiki.slitaz.org/doku.php?id=quickstart:pxe)
   1.254 +        <button>
   1.255 +          <input file icon="go-jump"></input>
   1.256 +	  <label>Install</label>
   1.257 +	  <action>
   1.258 +	echo -n "\$WEB_PXE" | cat - /dev/zero | \
   1.259 +	dd conv=notrunc bs=1 seek=5 count=255 of=/usr/share/boot/gpxe.pxe
   1.260 +	  </action>
   1.261 +	  <action>
   1.262 +	sed -i "s|tftpd -r .*\$|tftpd -r /usr/share/boot|" /etc/inetd.conf
   1.263 +	  </action>
   1.264 +	  <action> sed -i "/^boot_file/d" \$UDHCPD_CONF </action>
   1.265 +	  <action> echo "boot_file gpxe.pxe" >> \$UDHCPD_CONF </action>
   1.266 +	  <action> /etc/init.d/inetd restart </action>
   1.267 +	  <action> /etc/init.d/udhcpd restart </action>
   1.268 +	<action>sed -i "s/RUN_DAEMONS=\\"\\(.*\\)inetd \?\\(.*\\)\\"/RUN_DAEMONS=\\"\1\2\\"/" /etc/rcS.conf</action>
   1.269 +	<action>sed -i "s/RUN_DAEMONS=\\"\\(.*\\)udhcpd \?\\(.*\\)\\"/RUN_DAEMONS=\\"\1\2\\"/" /etc/rcS.conf</action>
   1.270 +	<action>sed -i "s/RUN_DAEMONS=\\"\\(.*\\)\\"/RUN_DAEMONS=\\"udhcpd inetd \1\\"/" /etc/rcS.conf</action>
   1.271 +        </button>
   1.272 +      </hbox>
   1.273 +</frame>
   1.274 +EOT
   1.275 +}
   1.276 +
   1.277 +#
   1.278 +# PXE server
   1.279 +#
   1.280 +tab_pxelinux()
   1.281 +{
   1.282 +cat <<EOT
   1.283 +<frame PXElinux>
   1.284 +      <hbox>
   1.285 +        <text wrap="true">
   1.286 +          <label>
   1.287 +"Launch Dhcpd and Inetd with Tftpd to start the PXE service."
   1.288 +          </label>
   1.289 +        </text>
   1.290 +      </hbox>
   1.291 +      <hbox>
   1.292 +        <text use-markup="true">
   1.293 +          <label>"<b>Configuration :</b>"</label>
   1.294 +        </text>
   1.295 +        <entry editable="false">
   1.296 +          <default>
   1.297 +$(grep bin/tftpd /etc/inetd.conf | awk '{ print $NF }')/pxelinux.cfg/default
   1.298 +          </default>
   1.299 +          <variable>PXE_CONF</variable>
   1.300 +        </entry>
   1.301 +        <button>
   1.302 +          <input file icon="accessories-text-editor"></input>
   1.303 +	  <action>dir=\$(dirname \$PXE_CONF); [ -d \$dir ] || mkdir -p \$dir</action>
   1.304 +	  <action>lzma d /usr/share/boot/pxelinux.0.lzma \$(dirname \$PXE_CONF)/../pxelinux.0</action>
   1.305 +	  <action>sed -i "/^boot_file/d" \$UDHCPD_CONF</action>
   1.306 +	  <action>echo "boot_file pxelinux.0" >> \$UDHCPD_CONF</action>
   1.307 +	  <action>grep -q "^siaddr" \$UDHCPD_CONF || echo "siaddr \$(ifconfig \$INTERFACE | grep inet.ad | cut -d: -f2 | cut -d\  -f1)" >> \$UDHCPD_CONF</action>
   1.308 +	  <action>[ -f \$PXE_CONF ] || echo -e "label linux\n\tkernel bzImage\n\tappend initrd=rootfs.gz rw root=/dev/null vga=normal" > \$PXE_CONF</action>
   1.309 +          <action type="lauch">leafpad \$PXE_CONF</action>
   1.310 +        </button>
   1.311 +      </hbox>
   1.312 +      <hbox>
   1.313 +$(wikibutton http://wiki.slitaz.org/doku.php?id=quickstart:pxe)
   1.314 +        <button>
   1.315 +          <input file icon="system-file-manager"></input>
   1.316 +	  <label>Network boot files</label>
   1.317 +	  <action>$xterm -geometry 100x25 -title "Network boot files (q to quit)" -e "find \$(dirname \$(dirname \$PXE_CONF)) -exec ls -ld {} \; | less"</action>
   1.318 +        </button>
   1.319 +      </hbox>
   1.320 +     </frame>
   1.321 +EOT
   1.322 +}
   1.323 +
   1.324 +data_pxe()
   1.325 +{
   1.326 +[ -f /usr/share/boot/pxelinux.0.lzma ] && cat <<EOT
   1.327 +true        PXElinux          tab_pxelinux
   1.328 +EOT
   1.329 +[ -f /usr/share/boot/gpxe.pxe ] && cat <<EOT
   1.330 +true        PXE\ forwarder    tab_gpxe
   1.331 +EOT
   1.332 +}
   1.333 +
   1.334 +#
   1.335 +# PXE
   1.336 +#
   1.337 +tab_pxe()
   1.338 +{
   1.339 +use_tab data_pxe
   1.340 +}
   1.341 +
   1.342 +#
   1.343 +# Busybox dnsd
   1.344 +#
   1.345 +tab_dnsd()
   1.346 +{
   1.347 +cat <<EOT
   1.348 +    <frame Dnsd (busybox master dns)>
   1.349 +$(helpdaemon dnsd 80x15 DNSD_OPTIONS DNSD_OPTS)
   1.350 +$(configfile /etc/dnsd.conf DNSD_CONF)
   1.351 +      <hbox>
   1.352 +	$(startstopdaemon dnsd busybox)
   1.353 +      </hbox>
   1.354 +     </frame>
   1.355 +EOT
   1.356 +}
   1.357 +
   1.358 +#
   1.359 +# ISC Bind
   1.360 +#
   1.361 +tab_named()
   1.362 +{
   1.363 +cat <<EOT
   1.364 +    <frame Named (ISC bind)>
   1.365 +$(helpdaemon named 80x10 NAMED_OPTIONS NAMED_OPTS)
   1.366 +$(configfile /etc/bind/named.conf.local NAMED_CONF)
   1.367 +      <hbox>
   1.368 +	$(startstopdaemon named bind)
   1.369 +      </hbox>
   1.370 +     </frame>
   1.371 +EOT
   1.372 +}
   1.373 +
   1.374 +#
   1.375 +# DNSmasq 
   1.376 +#
   1.377 +tab_dnsmasq()
   1.378 +{
   1.379 +cat <<EOT
   1.380 +    <frame DNSmasq (DNS/DHCP/TFTP)>
   1.381 +$(helpdaemon dnsmasq 100x34 DNSMASQ_OPTIONS DNSMASQ_OPTS)
   1.382 +$(configfile /etc/dnsmasq.conf DNSMASQ_CONF)
   1.383 +      <hbox>
   1.384 +	$(startstopdaemon dnsmasq)
   1.385 +      </hbox>
   1.386 +     </frame>
   1.387 +EOT
   1.388 +}
   1.389 +
   1.390 +data_dns()
   1.391 +{
   1.392 +cat <<EOT
   1.393 +dnsd        Dnsd          tab_dnsd
   1.394 +named       Named         tab_named
   1.395 +dnsmasq     DNSmasq       tab_dnsmasq
   1.396 +#TODO sheerdns    Sheerdns      tab_sheerdns
   1.397 +EOT
   1.398 +}
   1.399 +
   1.400 +#
   1.401 +# dns tab
   1.402 +#
   1.403 +tab_dns()
   1.404 +{
   1.405 +use_tab data_dns
   1.406 +}
   1.407 +
   1.408 +#
   1.409 +# rsync server
   1.410 +#
   1.411 +tab_rsync()
   1.412 +{
   1.413 +cat <<EOT
   1.414 +     <frame Rsync>
   1.415 +$(helpdaemon rsync 80x30 RSYNCD_OPTIONS RSYNCD_OPTS 1)
   1.416 +$(configfile /etc/rsyncd.conf RSYNCD_CONF)
   1.417 +$(datafile /etc/rsyncd.secrets RSYNCD_SECRETS 'Secrets file     :')
   1.418 +      <hbox>
   1.419 +	$(startstopdaemon rsyncd rsync)
   1.420 +      </hbox>
   1.421 +     </frame>
   1.422 +EOT
   1.423 +}
   1.424 +
   1.425 +php_ini()
   1.426 +{
   1.427 +[ -f /etc/php.ini ] && cat <<EOT
   1.428 +      <frame PHP>
   1.429 +$(configfile /etc/php.ini PHP_CONF)
   1.430 +      </frame>
   1.431 +EOT
   1.432 +}
   1.433 +
   1.434 +#
   1.435 +# Apache server
   1.436 +#
   1.437 +tab_apache()
   1.438 +{
   1.439 +cat <<EOT
   1.440 +     <frame Apache>
   1.441 +$(configfile /etc/apache/httpd.conf HTTPD_CONF)
   1.442 +$(php_ini)
   1.443 +      <hbox>
   1.444 +	$(startstopdaemon apache)
   1.445 +      </hbox>
   1.446 +     </frame>
   1.447 +EOT
   1.448 +}
   1.449 +
   1.450 +#
   1.451 +# Lighttpd server
   1.452 +#
   1.453 +tab_lighttpd()
   1.454 +{
   1.455 +cat <<EOT
   1.456 +     <frame Lighttpd>
   1.457 +$(helpdaemon lighttpd 80x15 LIGHTTPD_OPTIONS LIGHTTPD_OPTS)
   1.458 +$(configfile /etc/lighttpd/lighttpd.conf LIGHTTPD_CONF)
   1.459 +$(php_ini)
   1.460 +      <hbox>
   1.461 +	$(startstopdaemon lighttpd)
   1.462 +      </hbox>
   1.463 +     </frame>
   1.464 +EOT
   1.465 +}
   1.466 +
   1.467 +#
   1.468 +# Busybox httpd server
   1.469 +#
   1.470 +tab_httpd()
   1.471 +{
   1.472 +cat <<EOT
   1.473 +     <frame httpd (busybox)>
   1.474 +$(helpdaemon httpd 80x30 HTTPD_OPTIONS HTTPD_OPTS)
   1.475 +$(configfile /etc/httpd.conf HTTPD_CONF)
   1.476 +$(php_ini)
   1.477 +      <hbox>
   1.478 +	$(startstopdaemon httpd busybox)
   1.479 +      </hbox>
   1.480 +     </frame>
   1.481 +EOT
   1.482 +}
   1.483 +
   1.484 +data_http()
   1.485 +{
   1.486 +cat <<EOT
   1.487 +/etc/apache/httpd.conf  Apache          tab_apache
   1.488 +lighttpd                Lighttpd        tab_lighttpd
   1.489 +/etc/httpd.conf         Busybox\ httpd  tab_httpd
   1.490 +EOT
   1.491 +}
   1.492 +
   1.493 +#
   1.494 +# http tab
   1.495 +#
   1.496 +tab_http()
   1.497 +{
   1.498 +use_tab data_http
   1.499 +}
   1.500 +
   1.501 +#
   1.502 +# Samba servers
   1.503 +#
   1.504 +tab_wins()
   1.505 +{
   1.506 +cat <<EOT
   1.507 +     <frame Samba: smbd & nmbd>
   1.508 +$(configfile /etc/samba/smb.conf SMBD_CONF)
   1.509 +      <hbox>
   1.510 +        <button>
   1.511 +          <label>Reload</label>
   1.512 +          <input file icon="reload"></input>
   1.513 +          <action>/etc/init.d/samba reload</action>
   1.514 +        </button>
   1.515 +	$(startstopdaemon samba)
   1.516 +      </hbox>
   1.517 +     </frame>
   1.518 +EOT
   1.519 +}
   1.520 +
   1.521 +#
   1.522 +# x11vnc
   1.523 +#
   1.524 +tab_vnc()
   1.525 +{
   1.526 +cat <<EOT
   1.527 +     <frame x11vnc>
   1.528 +$(helpdaemon x11vnc 80x30 X11VNC_OPTIONS X11VNC_OPTS)
   1.529 +      <hbox>
   1.530 +        <text use-markup="true">
   1.531 +          <label>"<b>New password</b>"</label>
   1.532 +        </text>
   1.533 +        <entry>
   1.534 +          <variable>X11VNC_PASSWD</variable>
   1.535 +        </entry>
   1.536 +        <button>
   1.537 +          <input file icon="reload"></input>
   1.538 +          <label>Update</label>
   1.539 +          <action>x11vnc -storepasswd \$X11VNC_PASSWD /etc/vnc.secret</action>
   1.540 +        </button>
   1.541 +      </hbox>
   1.542 +      <hbox>
   1.543 +	$(startstopdaemon x11vnc)
   1.544 +      </hbox>
   1.545 +     </frame>
   1.546 +EOT
   1.547 +}
   1.548 +
   1.549 +#
   1.550 +# knock server
   1.551 +#
   1.552 +tab_knockd()
   1.553 +{
   1.554 +cat <<EOT
   1.555 +    <frame Knockd: trigger backdoors>
   1.556 +$(helpdaemon knockd 80x15 KNOCK_OPTIONS KNOCK_OPTS)
   1.557 +$(configfile /etc/knockd.conf KNOCKD_CONF)
   1.558 +      <hbox>
   1.559 +	$(startstopdaemon knockd knock)
   1.560 +      </hbox>
   1.561 +     </frame>
   1.562 +EOT
   1.563 +}
   1.564 +
   1.565 +data_servers()
   1.566 +{
   1.567 +local $pxe
   1.568 +pxe="#"
   1.569 +[ -x /usr/bin/tftpd -a -x /usr/sbin/udhcpd ] && pxe="inetd"
   1.570 +[ -x /usr/sbin/dnsmasq ] && pxe="true"
   1.571 +[ -f /usr/share/boot/pxelinux.0.lzma -o /usr/share/boot/gpxe.pxe ] || pxe="#"
   1.572 +cat <<EOT
   1.573 +$([ -x /usr/sbin/dropbear -o -x /usr/sbin/sshd ] && echo "true" ||
   1.574 +echo "#")   SSH           tab_sshd
   1.575 +$([ -x /usr/sbin/lighttpd -o -x /usr/bin/httpd ] && echo "true" || 
   1.576 +echo "#")   HTTP          tab_http
   1.577 +rsync       Rsync         tab_rsync
   1.578 +smbd        SAMBA          tab_wins
   1.579 +inetd       Inetd         tab_inetd
   1.580 +zcip        ZeroConf      tab_zcip
   1.581 +$([ -x /usr/sbin/udhcpd -o -x /usr/sbin/dhcpd -o -x /usr/sbin/dnsmasq ] && 
   1.582 +echo "true" ||
   1.583 +echo "#")   DHCP          tab_dhcpd
   1.584 +$pxe        PXE           tab_pxe
   1.585 +dnsmasq     tftpd         tab_dnsmasq
   1.586 +$([ -x /usr/sbin/dnsd -o -x /usr/sbin/named -o -x /usr/sbin/dnsmasq ] && 
   1.587 +echo "true" ||
   1.588 +echo "#")   DNS           tab_dns
   1.589 +x11vnc      VNC           tab_vnc 
   1.590 +knockd      Knock         tab_knockd
   1.591 +#TODO+callback pppd        Pppd          tab_pppd
   1.592 +#TODO pptpd       PoPToP        tab_poptop
   1.593 +#TODO squid *sql openldap 
   1.594 +EOT
   1.595 +}
   1.596 +
   1.597 +#
   1.598 +# Servers tab
   1.599 +#
   1.600 +tab_servers()
   1.601 +{
   1.602 +use_tab data_servers
   1.603 +}
   1.604 +
   1.605 +#
   1.606 +# Firewall tab
   1.607 +#
   1.608 +tab_firewall()
   1.609 +{
   1.610 +cat <<EOT
   1.611 +    <frame Iptables>
   1.612 +$(configfile /etc/firewall.conf IPTABLES_CONF)
   1.613 +      <hbox>
   1.614 +$(helpbutton iptables 80x30)
   1.615 +$(manbutton 8 iptables)
   1.616 +$(webbutton iptables)
   1.617 +        <button>
   1.618 +          <label>Load</label>
   1.619 +          <input file icon="reload"></input>
   1.620 +          <action>cat \$IPTABLES_CONF | /sbin/iptables-restore</action>
   1.621 +        </button>
   1.622 +        <button>
   1.623 +          <label>Save</label>
   1.624 +          <input file icon="go-jump"></input>
   1.625 +          <action>/sbin/iptables-save > \$IPTABLES_CONF</action>
   1.626 +        </button>
   1.627 +      </hbox>
   1.628 +     </frame>
   1.629 +EOT
   1.630 +}
   1.631 +
   1.632 +#
   1.633 +# knock client
   1.634 +#
   1.635 +tab_knock()
   1.636 +{
   1.637 +cat <<EOT
   1.638 +    <frame Knock>
   1.639 +    <hbox>
   1.640 +      <text use-markup="true">
   1.641 +        <label>"<b>Options : </b>"</label>
   1.642 +      </text>
   1.643 +      <entry editable="true">
   1.644 +        <variable>KNOCK_OPTS</variable>
   1.645 +	<default>myserver.example.com 123:tcp 456:udp 789:tcp</default>
   1.646 +      </entry>
   1.647 +    </hbox>
   1.648 +    <hbox>
   1.649 +$(helpbutton knock 80x12)
   1.650 +      <button>
   1.651 +        <label>Start</label>
   1.652 +        <input file icon="forward"></input>
   1.653 +        <action>knock \$KNOCK_OPTS</action>
   1.654 +      </button>
   1.655 +    </hbox>
   1.656 +    </frame>
   1.657 +EOT
   1.658 +}
   1.659 +
   1.660 +data_main()
   1.661 +{
   1.662 +cat <<EOT
   1.663 +#program    tab name      function
   1.664 +true        Servers       tab_servers
   1.665 +iptables    Firewall      tab_firewall
   1.666 +knock       Knock         tab_knock
   1.667 +EOT
   1.668 +}
   1.669 +
   1.670 +tab_main()
   1.671 +{
   1.672 +use_tab data_main
   1.673 +}
   1.674 +
   1.675 +######################################################
   1.676 +#
   1.677 +# Serverbox GUI
   1.678 +#
   1.679 +######################################################
   1.680 +
   1.681 +# Only root can configure server.
   1.682 +check_root
   1.683 +
   1.684 +# English/French help dialog.
   1.685 +export HELP='
   1.686 +<window title="Network status" icon-name="network-wire">
   1.687 +<vbox>
   1.688 +	<text use-markup="true">
   1.689 +		<label>
   1.690 +"
   1.691 +<b>SliTaz - Serverbox</b>"
   1.692 +		</label>
   1.693 +	</text>
   1.694 +	<frame English>
   1.695 +		<text wrap="true" width-chars="58">
   1.696 +			<label>
   1.697 +"Serverbox lets you manage and setup servers. First, install and 
   1.698 +edit configuration files. Then, start or stop servers."
   1.699 +			</label>
   1.700 +		</text>
   1.701 +	</frame>
   1.702 +	<frame Francais>
   1.703 +		<text wrap="true" width-chars="58">
   1.704 +			<label>
   1.705 +"Serverbox peut demarrer ou arreter le reseau, configurer
   1.706 +les interfaces reseau ou editer directement les fichiers."
   1.707 +			</label>
   1.708 +		</text>
   1.709 +	</frame>
   1.710 +</vbox>
   1.711 +</window>
   1.712 +'
   1.713 +
   1.714 +# The main dialog with notebook, start/stop buttons and all options.
   1.715 +# Note that /etc/network.conf is seded when an interface is activated.
   1.716 +#
   1.717 +head='
   1.718 +<window title="SliTaz Server Manager" icon-name="network-wired">
   1.719 +	<vbox>
   1.720 +
   1.721 +		<hbox>
   1.722 +			<text use-markup="true">
   1.723 +				<label>"<b>Server Manager</b>"</label>
   1.724 +			</text>
   1.725 +			<pixmap>
   1.726 +				<input file>/usr/share/pixmaps/netbox.png</input>
   1.727 +			</pixmap>
   1.728 +		</hbox>
   1.729 +'
   1.730 +bottom='
   1.731 +		<hbox>
   1.732 +			<button help>
   1.733 +				<label>Help</label>
   1.734 +				<action type="launch">HELP</action>
   1.735 +			</button>
   1.736 +			<button>
   1.737 +				<label>Quit</label>
   1.738 +				<input file icon="exit"></input>
   1.739 +				<action type="exit">Exit</action>
   1.740 +			</button>
   1.741 +		</hbox>
   1.742 +
   1.743 +	</vbox>
   1.744 +</window>
   1.745 +'
   1.746 +
   1.747 +SERVER_BOX="${head}$(tab_main)${bottom}"
   1.748 +
   1.749 +export SERVER_BOX
   1.750 +
   1.751 +gtkdialog --center --program=SERVER_BOX >/dev/null