# HG changeset patch # User Rohit Joshi # Date 1269426812 14400 # Node ID 612580c572508ad7fd59608a642b48a935a86319 # Parent 0d8f225b01858e4957f32ce2888ab7aeaf2c2503 netbox:split networking, server, gui and tab engine diff -r 0d8f225b0185 -r 612580c57250 lib/gui_functions --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/gui_functions Wed Mar 24 06:33:32 2010 -0400 @@ -0,0 +1,211 @@ +#!/bin/sh +# +# +# Tab display engine +# +###################################################### + +use_tab() +{ +local tmp='' +case "$2" in +header|body) + $1 | while read exe name call; do + case "$exe" in + \#*) continue;; + /*) [ -e $exe ] || continue;; + *) which $exe > /dev/null || continue + esac + if [ "$2" == "header" ]; then + echo -n "$tmp$name" + tmp='|' + else + $call + fi + done + ;; +*) + tmp=$(use_tab $1 header) + echo "$tmp" | grep -q \| && cat < +EOT + [ -n "$tmp" ] && cat < +EOT + ;; +esac +} + +# +# GUI functions +# +############################################################ + +xterm="xterm -fa MiscFixed -fs 11" +helpbutton() +{ + local label; + label="" + [ -n "$3" ] || label="" + cat << EOT + +EOT +} + +editbutton() +{ + cat << EOT + +EOT +} + +manbutton() +{ + cat << EOT + +EOT +} + +helpdaemon() +{ + cat << EOT + + + + + +EOT + eval tmp=\$$3 + [ -n "$tmp" ] && cat << EOT + $tmp +EOT + cat << EOT + $4 + +EOT + [ -n "$6" ] || cat << EOT +$(helpbutton $1 $2) +EOT + [ -n "$5" ] && cat << EOT +$(manbutton $5 $1) +EOT + cat << EOT +$(editbutton /etc/daemons.conf) + +EOT +} + +datafile() +{ + cat << EOT + + + + + +EOT + [ -n "$1" ] && cat << EOT + $1 +EOT + cat << EOT + $2 + +EOT + [ -n "$4" ] && cat << EOT +$(manbutton $4) +EOT + cat << EOT +$(editbutton \$$2) + +EOT +} + +configfile() +{ + datafile "$1" $2 'Configuration:' "$3" +} + +BROWSER='' +for i in firefox opera dillo midori netsurf links ; do + which $i > /dev/null && BROWSER="$i" && break +done +case "$BROWSER" in +links) BROWSER="links -g ";; +esac + +webbutton() +{ + [ -f "/var/lib/tazpkg/installed/$1/receipt" ] && + [ -n "$BROWSER" ] && cat << EOT + +EOT +} + +wikibutton() +{ +[ -n "$BROWSER" ] && cat < + + + $BROWSER $1 & + +EOT +} + +startstopdaemon() +{ + local pkg + pkg=$1 + [ -n "$2" ] && pkg=$2 + if [ ! -d /var/lib/tazpkg/installed/${pkg} ]; then + installbox $pkg + fi + webbutton $pkg + cat << EOT + + +EOT +} + +installbox() +{ + cat << EOT + + + + +EOT +} diff -r 0d8f225b0185 -r 612580c57250 tinyutils/netbox --- a/tinyutils/netbox Wed Mar 24 05:15:28 2010 -0400 +++ b/tinyutils/netbox Wed Mar 24 06:33:32 2010 -0400 @@ -5,7 +5,9 @@ # # (c) - SliTaz GNU/Linux 2009. # -VERSION=20090812 +VERSION=20100315 + +. /usr/lib/slitaz/gui_functions # Check if user is root. check_root() @@ -18,6 +20,7 @@ fi } + # # Functions called by the connection tab to list interfaces. # @@ -66,176 +69,6 @@ continue ;; esac -# -# GUI functions -# -############################################################ - -xterm="xterm -fa MiscFixed -fs 11 -bg gray93 -fg black" -helpbutton() -{ - local label; - label="" - [ -n "$3" ] || label="" - cat << EOT - -EOT -} - -editbutton() -{ - cat << EOT - -EOT -} - -manbutton() -{ - cat << EOT - -EOT -} - -helpdaemon() -{ - cat << EOT - - - - - -EOT - eval tmp=\$$3 - [ -n "$tmp" ] && cat << EOT - $tmp -EOT - cat << EOT - $4 - -EOT - [ -n "$6" ] || cat << EOT -$(helpbutton $1 $2) -EOT - [ -n "$5" ] && cat << EOT -$(manbutton $5 $1) -EOT - cat << EOT -$(editbutton /etc/daemons.conf) - -EOT -} - -datafile() -{ - cat << EOT - - - - - -EOT - [ -n "$1" ] && cat << EOT - $1 -EOT - cat << EOT - $2 - -EOT - [ -n "$4" ] && cat << EOT -$(manbutton $4) -EOT - cat << EOT -$(editbutton \$$2) - -EOT -} - -configfile() -{ - datafile "$1" $2 'Configuration:' "$3" -} - -BROWSER='' -for i in firefox opera dillo midori netsurf links ; do - which $i > /dev/null && BROWSER="$i" && break -done -case "$BROWSER" in -links) BROWSER="links -g ";; -esac - -webbutton() -{ - [ -f "/var/lib/tazpkg/installed/$1/receipt" ] && - [ -n "$BROWSER" ] && cat << EOT - -EOT -} - -wikibutton() -{ -[ -n "$BROWSER" ] && cat < - - - $BROWSER $1 & - -EOT -} - -startstopdaemon() -{ - local pkg - pkg=$1 - [ -n "$2" ] && pkg=$2 - webbutton $pkg - cat << EOT - - -EOT -} - -installbox() -{ - cat << EOT - - - - - - -EOT -} - set_ipup() { [ -f /etc/ppp/ip-up ] && return @@ -330,44 +163,7 @@ exit 1 fi -# -# Tab display engine -# -###################################################### -use_tab() -{ -local tmp='' -case "$2" in -header|body) - $1 | while read exe name call; do - case "$exe" in - \#*) continue;; - /*) [ -e $exe ] || continue;; - *) which $exe > /dev/null || continue - esac - if [ "$2" == "header" ]; then - echo -n "$tmp$name" - tmp='|' - else - $call - fi - done - ;; -*) - tmp=$(use_tab $1 header) - echo "$tmp" | grep -q \| && cat < -EOT - [ -n "$tmp" ] && cat < -EOT - ;; -esac -} # # Status wire interfaces @@ -460,22 +256,6 @@ EOT } -# -# Status servers -# -tab_status_servers() -{ -local servers -servers="dropbear sshd inetd dhcpd dnsd named rsync httpd mbd vnc pppd knock" -cat < - - for i in $servers; do ps ww | grep \$i | grep -v grep | fold -s; done - - -EOT -} - data_status() { cat < - - - - - $2 - user@elsewhere - - - - -EOT -} - -# -# Dropbear client & server -# -tab_dropbear() -{ -. /etc/daemons.conf -set -- $DROPBEAR_OPTIONS -while [ -n "$2" ]; do - [ "$1" = "-b" ] && DROPBEAR_BANNER="$2" && break - shift -done - -cat < -$(helpdaemon dropbear 80x30 DROPBEAR_OPTIONS DROPBEAR_OPTS) -$(datafile /etc/dropbear/banner DROPBEAR_BANNER 'Banner :') -$(sshremote DROPBEAR_PEER 'dbclient -i /etc/dropbear/dropbear_rsa_host_key') - - $(startstopdaemon dropbear) - - -EOT -} - -# -# OpenSSH client & server -# -tab_openssh() -{ -cat < -$(helpdaemon sshd 80x30 OPENSSH_OPTIONS OPENSSH_OPTS 8 nohelp) -$(configfile /etc/ssh/sshd_config OPENSSH_CONF '5 sshd_config') -$(sshremote OPENSSH_PEER 'ssh -i /etc/ssh/ssh_host_rsa_key') - - $(startstopdaemon openssh) - - -EOT -} - -data_sshd() -{ -cat < -$(helpdaemon inetd 60x14 INETD_OPTIONS INETD_OPTS) -$(configfile /etc/inetd.conf INETD_CONF) - -EOT -for i in $(grep bin /etc/inetd.conf | awk '{ print $6}'); do - i=$(basename $i) - helpbutton $i 60x19 $i -done -cat < - -EOT -} - -# -# ZeroConf -# -tab_zcip() -{ -if [ -x /sbin/zcip -a -z "$ZCIP_OPTIONS" ]; then - ZCIP_OPTIONS="eth0 /etc/zcip.script" - cat >> /etc/daemons.conf < -$(helpdaemon zcip 60x14 ZCIP_OPTIONS ZCIP_OPTS) -$(datafile /etc/zcip.script CZIP_SCRIPT 'Script :') - - $(startstopdaemon zcip) - - -EOT -} - -# -# Dhcpd ISC -# -tab_isc_dhcpd() -{ -cat < -$(helpdaemon dhcpd 60x14 DHCPD_OPTIONS DHCPD_OPTS) -$(configfile /etc/dhcpd.conf DHCPD_CONF) - - $(startstopdaemon dhcpd dhcp) - - -EOT -} - -# -# Dhcpd Busybox -# -tab_udhcpd() -{ -cat < -$(helpdaemon udhcpd 60x14 UDHCPD_OPTIONS UDHCPD_OPTS) -$(configfile /etc/udhcpd.conf UDHCPD_CONF) - - $(startstopdaemon udhcpd busybox) - - -EOT -} - -data_dhcpd() -{ -cat < - - - - - - - - -"$(dd bs=1 skip=5 count=255 if=/usr/share/boot/gpxe.pxe 2> /dev/null | strings)" - - WEB_PXE - - - -$(wikibutton http://wiki.slitaz.org/doku.php?id=quickstart:pxe) - - - -EOT -} - -# -# PXE server -# -tab_pxelinux() -{ -cat < - - - - - - - - - - - -$(grep bin/tftpd /etc/inetd.conf | awk '{ print $NF }')/pxelinux.cfg/default - - PXE_CONF - - - - -$(wikibutton http://wiki.slitaz.org/doku.php?id=quickstart:pxe) - - - -EOT -} - -data_pxe() -{ -[ -f /usr/share/boot/pxelinux.0.lzma ] && cat < -$(helpdaemon dnsd 80x15 DNSD_OPTIONS DNSD_OPTS) -$(configfile /etc/dnsd.conf DNSD_CONF) - - $(startstopdaemon dnsd busybox) - - -EOT -} - -# -# ISC Bind -# -tab_named() -{ -cat < -$(helpdaemon named 80x10 NAMED_OPTIONS NAMED_OPTS) -$(configfile /etc/bind/named.conf.local NAMED_CONF) - - $(startstopdaemon named bind) - - -EOT -} - -# -# DNSmasq -# -tab_dnsmasq() -{ -cat < -$(helpdaemon dnsmasq 100x34 DNSMASQ_OPTIONS DNSMASQ_OPTS) -$(configfile /etc/dnsmasq.conf DNSMASQ_CONF) - - $(startstopdaemon dnsmasq) - - -EOT -} - -data_dns() -{ -cat < -$(helpdaemon rsync 80x30 RSYNCD_OPTIONS RSYNCD_OPTS 1) -$(configfile /etc/rsyncd.conf RSYNCD_CONF) -$(datafile /etc/rsyncd.secrets RSYNCD_SECRETS 'Secrets file :') - - $(startstopdaemon rsyncd rsync) - - -EOT -} - -php_ini() -{ -[ -f /etc/php.ini ] && cat < -$(configfile /etc/php.ini PHP_CONF) - -EOT -} - -# -# Apache server -# -tab_apache() -{ -cat < -$(configfile /etc/apache/httpd.conf HTTPD_CONF) -$(php_ini) - - $(startstopdaemon apache) - - -EOT -} - -# -# Lighttpd server -# -tab_lighttpd() -{ -cat < -$(helpdaemon lighttpd 80x15 LIGHTTPD_OPTIONS LIGHTTPD_OPTS) -$(configfile /etc/lighttpd/lighttpd.conf LIGHTTPD_CONF) -$(php_ini) - - $(startstopdaemon lighttpd) - - -EOT -} - -# -# Busybox httpd server -# -tab_httpd() -{ -cat < -$(helpdaemon httpd 80x30 HTTPD_OPTIONS HTTPD_OPTS) -$(configfile /etc/httpd.conf HTTPD_CONF) -$(php_ini) - - $(startstopdaemon httpd busybox) - - -EOT -} - -data_http() -{ -cat < -$(configfile /etc/samba/smb.conf SMBD_CONF) - - - $(startstopdaemon samba) - - -EOT -} - -# -# x11vnc -# -tab_vnc() -{ -cat < -$(helpdaemon x11vnc 80x30 X11VNC_OPTIONS X11VNC_OPTS) - - - - - - X11VNC_PASSWD - - - - - $(startstopdaemon x11vnc) - - -EOT -} - -# -# knock server -# -tab_knockd() -{ -cat < -$(helpdaemon knockd 80x15 KNOCK_OPTIONS KNOCK_OPTS) -$(configfile /etc/knockd.conf KNOCKD_CONF) - - $(startstopdaemon knockd knock) - - -EOT -} - -data_servers() -{ -local $pxe -pxe="#" -[ -x /usr/bin/tftpd -a -x /usr/sbin/udhcpd ] && pxe="inetd" -[ -x /usr/sbin/dnsmasq ] && pxe="true" -[ -f /usr/share/boot/pxelinux.0.lzma -o /usr/share/boot/gpxe.pxe ] || pxe="#" -cat < -$(configfile /etc/iptables.conf IPTABLES_CONF) - -$(helpbutton iptables 80x30) -$(manbutton 8 iptables) -$(webbutton iptables) - - - - -EOT -} - -# -# knock client -# -tab_knock() -{ -cat < - - - - - - KNOCK_OPTS - myserver.example.com 123:tcp 456:udp 789:tcp - - - -$(helpbutton knock 80x12) - - - -EOT -} - # # ether-wake # @@ -1773,12 +947,9 @@ ifconfig Static\ IP tab_fixed_ip pppoe PPPoE tab_pppoe pppd PPP tab_ppp -true System\ wide tab_system true VPN tab_vpn -true Servers tab_servers -iptables Firewall tab_firewall -knock Knock tab_knock ether-wake Etherwake tab_etherwake +true Configuration tab_system EOT } @@ -1851,7 +1022,7 @@ - + /usr/share/pixmaps/netbox.png