#! /bin/sh
# siga - System Information gathering mlasars@suse.de (c) 2001-2005 SUSE LINUX GmbH 
#        modified by jsj@suse.de
#        hosted by henne :-)
#

#set -x

export LC_ALL=C

VER=10.002
VERDATE="2005 08 26"
CLI1="$1"
CLI2="$2"
CLI_NUM="$#"
CLI_ALL="$*"

# change this only if you need it for some reason ...
TMP_DIR="/tmp/siga/"
SIGA_OUT="$TMP_DIR"siga.html""
SIGA_OUT_TXT="$TMP_DIR"siga.txt""
SIGA_OUT_Y="$TMP_DIR"siga_yast.html""
SIGA_OUT_PC="$TMP_DIR"siga_pc.html""
SIGA_HEAD="$TMP_DIR.siga_head.html"

# if you want to write the data with the floppy option
# to another device, change it.
FLOPPY_DEV="/dev/fd0"

DATE="`date +"%Y%m%d-%H%M%S"`"

# here is the definition what to do (DOC2)
HW_ALL="hw_top hw_procinfo hw_cpu conf_cmdline hw_io hw_dma hw_dev hw_devdir hw_usb hw_pci hw_setserial hw_isa_pnp hd_part hd_mount hd_fstab hd_set hw_boot hw_scsi hw_links"
SOFT_ALL="soft_top soft_modules soft_rpm conf_y2log conf_messages"
CONF_ALL="conf_top conf_modules conf_modules_local conf_grub conf_device conf_grub_conf conf_lilo conf_lilo_test"
PRINT_ALL="print_top print_sysc_printer print_printcap print_lpdfilter print_par_auto print_apsfilterrc2 print_misc print_cups print_cups_ps net_inetd print_cups_ppd print_cups_cupsd print_cups_printers print_cups_error print_cups_prnlog print_cups_par print_cups_usb print_cups_types print_cups_convs print_cups_lpstat print_cups_lpc print_cups_net"
COMM_ALL="comm_top comm_rc_dialout comm_wvdial_conf comm_smpppd_conf comm_ppp_options comm_ppp_iooptions comm_pppoed_conf comm_peers_pppoe"
XF_ALL="xf_top xf_sysp xf_links xf_xf86_3 xf_xf86_4 xf_3ddiag xf_libgl xf_framebuffer xf_log xf_sax_log xf_xerr xf_xsession_errors xf_serverlog xf_startlog"
SYSC1_MAIN="3ddiag autofs backup clock console cron dhcpd displaymanager hotplug ispell java joystick kernel keyboard language"
SYSC2_MAIN="locate lvm mail mouse news nfs nfs-server onlineupdate personal-firewall pcmcia printer proxy security sendmail sound ssh suseconfig susehelp sysctl windowmanager xntp ypbind"
NET_ALL="net_top net_ifstatus net_ifcfg net_route net_routes net_config net_sysctl net_resolv net_dhcp net_proxy net_sendmail net_ssh net_filter net_security net_personalfirewall net_ipv4_forward"

MODEM_INF="hw_top hw_procinfo conf_cmdline hw_io hw_setserial hw_usb hw_pci hw_devdir hw_isa_pnp soft_top soft_modules conf_modules conf_modules_local conf_messages comm_top comm_providers comm_chkconfig_smpppd comm_smpppd_conf comm_hwinfo_modem $NET_ALL"
HW_INF="hw_top hw_procinfo conf_cmdline hw_pci hw_hwinfo hw_isa_pnp hw_devdir conf_top conf_grub conf_modules conf_modules_local conf_messages"
PCMCIA_INF="hw_top hw_procinfo conf_cmdline hw_pci hw_io hw_hotplug hw_pcmcia soft_top soft_modules conf_top conf_modules conf_modules_local conf_grub conf_messages xf_top xf_xf86_3 xf_xf86_4 xf_sysp xf_framebuffer"
NET_INF="hw_top hw_procinfo conf_cmdline hw_pci hw_isa_pnp hw_devdir hw_isa_pnp soft_modules hw_hwinfo_net conf_top conf_modules conf_modules_local conf_messages comm_top comm_providers $NET_ALL"
BOOT_INF="hw_top hw_procinfo conf_cmdline hd_part hd_mount hw_boot_dir hw_boot_initrd hd_fstab hw_hwinfo_disk hw_boot hw_scsi hw_links hw_hwinfo_storage conf_top conf_grub conf_device conf_grub_conf conf_lilo conf_lilo_test"
X11_INF="hw_top hw_procinfo conf_cmdline hw_pci soft_modules conf_top conf_grub conf_device conf_grub_conf conf_lilo conf_lilo_test conf_modules conf_modules_local conf_messages $XF_ALL xf_xdpyinfo"
INSTALL_INF="hw_top hw_procinfo hw_pci conf_cmdline hd_part hw_boot hw_hwinfo conf_top conf_grub conf_device conf_grub_conf conf_lilo conf_lilo_test conf_messages conf_y2log"
SOUND_INF="hw_top hw_procinfo conf_cmdline hw_io hw_pci hw_isa_pnp hw_hwinfo_sound soft_top soft_modules sound_alsa_modules hw_sound_misc conf_top conf_modules conf_modules_local hw_sound_modp hw_soundc conf_messages"
PRINT_INF="hw_top hw_procinfo conf_cmdline hw_io hw_dma hw_dev hw_usb hw_pci soft_top soft_modules conf_messages $PRINT_ALL print_hwinfo"
PRINT_DO_INF="print_top print_par_auto print_cups_par hw_usb print_cups_usb print_hwinfo"
CDR_INF="hw_top hw_procinfo conf_cmdline hw_cdr hw_hw_cdr hw_usb hw_pci hw_devdir hw_boot hw_scsi hw_links soft_top soft_modules conf_top hw_boot_initrd conf_grub conf_device conf_grub_conf conf_lilo conf_lilo_test conf_messages"
DSL_INF="hw_top hw_procinfo conf_cmdline hw_pci hw_boot hw_isa_pnp hw_devdir hw_isa_pnp soft_modules hw_hwinfo_net dsl_speedtouch conf_top conf_messages comm_top comm_chkconfig_smpppd comm_dsl_smpppd_log comm_dsl_smpppd_dsl comm_ifstatus_dhcp0 comm_ifstatus_dhcp1 comm_peers_pppoe comm_ppp_options comm_smpppd_conf comm_providers $NET_ALL"

ISDN_INF="hw_top hw_procinfo conf_cmdline hw_pci hw_usb hw_isa_pnp hw_devdir soft_modules conf_top conf_messages comm_top comm_ppp_iooptions comm_isdn_cfg comm_isdn_cfg_net comm_providers comm_smpppd_conf comm_isdn_ctrl comm_isdn_capi $NET_ALL"
ISDN_TEST_INF="hw_top hw_procinfo conf_cmdline hw_pci hw_usb hw_isa_pnp soft_modules conf_top isdn_test comm_top comm_ppp_iooptions comm_isdn_cfg comm_isdn_cfg_net comm_providers comm_smpppd_conf comm_isdn_ctrl comm_isdn_capi $NET_ALL"
USB_INF="hw_top hw_procinfo conf_cmdline hw_cpu hw_io hw_dma hw_dev hw_devdir hd_part hd_fstab hw_media hw_pci soft_top soft_modules hw_boot_initrd conf_messages conf_modules conf_modules_local hw_head_usb hw_usb hw_usb_lsusb hw_usb_hwinfo hw_usb_sys_hot"
MAIL_INF="mail_top mail_sendmail_v mail_postfix_v mail_amavis_sendmail mail_amavis_postfix mail_sysc_mail mail_aliases mail_sysc_sendmail mail_virtuser mail_gentable mail_postfix mail_postfix_main mail_postfix_virtual mail_postfix_canonical mail_poll"

YOU_INF="you_top you_config you_servers you_sysconf you_wgetrc you_y2log you_config soft_top soft_rpm conf_top conf_messages"

ALL_INF="$HW_ALL $SOFT_ALL $CONF_ALL $PRINT_ALL $COMM_ALL $XF_ALL sysc_do $NET_ALL"

#this is just for testing new stuff
TV_INF="hw_top hw_devdir"

# remote edit
# if you want to allow to edit configuration
# files on a remote display, set REMOTE_EDIT to YES
# you have to start siga with option ip:remoteip:0.0 eg:
# siga ip:192.168.0.2:0.0
# See 'man Xsecurity' on how to grant access to the X Server from a remote
# client. By default, remote clients are declined by the X Server.
#
# default is REMOTE_EDIT="no" to prevent undesignedly changes of
# configuration files

REMOTE_EDIT="no"

# changes
################################################################################
# 0.95 7.2 test beta 3
# 1.007 w3m now default, added netscape option
# 1.008 2002 01 21 started for 8.0, all new:
#       now for every check a function, this makes special
#       selections possible, like siga -modem
# 1.011 first working with new functions (-modem)
# 1.012 added -m option (messages)
# 1.013 the great sysconfig
# 1.015 sup_case and _INF works
#       -w (no wordwrap) for pico
# 1.018 make a reset before start the editor, fixes mouse bug
# 1.020 sup_case works
# 1.030 / for links
# 1.034 link_edit work, change LINK_EDIT=fstab to ~etc~fstab e.g.
# 1.038 options work
# 1.040 added boot.msg
# 1.050 new editor & browser choice
#       sysconfig single files added
# 1.069 $SIGA_OUT_PC died, now edit within main file
# 7.372 changed version number, now similar to release
# 7.374 fixed $USERHOMEDIR, added modules -net -pcmcia(laptop) -hw -boot -x11
# 7.380 first beta, most should work proper
# 7.383 removed apsfilerrc
# 7.385 new modem stuff, new head (now right numeric order)
# 7.386 auto save mode:
#	if siga crashes, on next start the modules that crashes will be skipped
# 7.393 -isdn (not ready)
# 7.394 added xdpyinfo, fixed pnpdump error
# 7.397 added xf_links, hw_links
# 7.400 fixed network stuff
# 7.410 fixed printer stuff, added basic cups configs
# 7.411 added cups files, fixed asciii convert - now uses w3m
# 7.413 ascii convert now with lynx or w3m, added isdn files
# 8.000 added manpage, fixed isdn & dsl files
# 8.003 fixed cups, disabled sysp -c server, fixed floppy copy
# 8.004 fixed kernel link, ifconfig instead of ifstatus
# 8.005 added messages to -net & -isdn
# 8.010 added main funktion
# 8.011 added -usb, dmesg output
# 8.015 write to floppy if /tmp is not writeable
# 8.021 added hwinfo --cdrom for -cdr, fixed cups stuff
# 8.022 test for lilo or grub as bootloader, fix iptables, fix SuSEfirewall2
# 8.023 added needed grub files, rccups restart only with -print option
# 8.100 fixed y2log location to /var/log/YaST2/, set version to 8.1
# 8.101 fixed wrong permissions in /etc/cups/cupsd.conf & /usr/lib/cups/filter/cupsomatic
#       fixed output for smpppd, filename was smppd instead of smpppd, 
#       changes in root restart, now su -c instead of su - -c, USERHOMEDIR works now
# 8.104 added cmdline in all, /proc/bus/usb/devices in -usb
#       /etc/sysconfig/personal-firewall & /proc/sys/net/ipv4/ip_forward in -net -isdn & -dsl
#       /etc/sysconfig/kernel in -cdr
#       typo fix "choose" instead of chose
#	new mail section
#	new print-detect-only section
# 8.105 fixed and added mail 
#       added option isdn-test
# 9.001 fixed --help dsl text
#       added providers to DSL
#       added dhcp to NET
#	added modules to X11
# 9.002 fixed cups permissions
# 9.100 cleaned up dsl & modem
#	added modprobe.conf & .local
# 9.201 UTF-8 changes
#	added debug to isdn-test
#	added lspci without -vvv to lspci output
#	using /proc/mounts instead of mount for mountpoints	
#	writing on external media or windows partition with siga write 
#	grepping firewall out of messages except for -net
# 9.202 small output changes
# 9.203 fix for write_external
# 9.301 included /dev in all, modem, hw, net, cdr, dsl, isdn, usb (#67064)
#10.001 prepare for 10.0, fixed xorg.conf, added modprobe.d/sound 
#  2do: check smpppd/ for sensitive data
#10.002 fixed security bug #106585


# check language for floppy stuff

# errors:
################################################################################
# netscape reload sometimes dont work, bus error

# future, 2do, changes:
################################################################################
# link_while uses 100% cpu
#
# kill link_edit, clean up

# option output (DOC3)

unknown_option () {
  echo -e "\n unknown option $1\n
  basic options : siga                  (use w3m & pico)
                  siga net              (use Netscape & `basename $WINDOWMANAGER` Editor in X)
                  siga kon              (use konqueror & `basename $WINDOWMANAGER` Editor in X)
                  siga lynx             (forces lynx & pico)
                  siga lynxvi           (forces lynx & vi)
                  siga w3m              (forces w3m & pico)
                  siga w3mvi            (forces w3m & vi)
                  siga no               (no browser output, only gathering)
                  siga floppy           (no output, copy data to floppy (with format)
                  siga write            (no output, copy data to directory)  
                  siga ip:www.wheretodisplay.com:0.0 (for netscape remote display)
                       ip:192.168.0.5:0.0            (or an IP address)\n"

  echo -e "  support options : \n
                  siga -m                 (same as tail -f /var/log/messages)
                  siga -modem             (shows all about modem)
                  siga -hw                (shows all about hardware)
                  siga -boot              (shows all about booting)
		  siga -net               (shows all about network)
		  siga -dsl               (shows all about dsl)
		  siga -mail              (shows all about mail)
		  siga -laptop            (shows all about laptop)
		  siga -install           (shows info about install)
		  siga -sound             (shows all about sound)
		  siga -x11               (shows all about x11)
		  siga -print             (shows all about printer, this restarts cups!)
	          siga -print-detect-only (shows info about printer, short version)
 		  siga -cdr               (shows all about cd-r burner)
		  siga -isdn              (shows all about isdn)
		  siga -isdn-test         (shows all about isdn & test dialin)
		  siga -usb		  (shows all about usb)
		  siga -you		  (shows all about you)"

  echo -e "\n it is possible to combine the options, e.g. \n
              siga floppy -modem"
  exit 1
}

basic_option_check () {
if [ "$CLI_NUM" != "0" ] &&
   [ "$CLI1" != "lynx" ] &&
   [ "$CLI1" != "lynxvi" ] &&
   [ "$CLI1" != "w3m" ] &&
   [ "$CLI1" != "w3mvi" ] &&
   [ "$CLI1" != "floppy" ] &&
   [ "$CLI1" != "write" ] &&
   [ "$CLI1" != "w" ] &&
   [ "$CLI1" != "no" ] &&
   [ "`echo $CLI1 | cut -c1-3`" != "ip:" ] &&
   [ "$CLI1" != "kon" ] &&
   [ "$CLI1" != "net" ] &&
   [ "$CLI1" != "cat" ] &&
   [ "$CLI1" != "vi" ] ; then

  if [ "`echo "$CLI2" | cut -b1`" = "-" ] ; then
    unknown_option
  fi
 UOPT=1
fi
}

basic_option_check

support_option_check () {
if [ "$CLI_NUM" != "0" ] || [ "$UOPT" != "1" ] ; then
 if [ "`echo "$CLI_ALL" | cut -b1`" = "-" ] || [ "$CLI_NUM" -gt "1" ] ; then
   if [ "`echo "$CLI2" | cut -b1`" = "-" ] ; then
     SUP_OPT="$CLI2"
   else
     SUP_OPT="$CLI1"
   fi
 else
  if [ "$UOPT" = "1" ] ; then
    unknown_option
  fi
 SUP_OPT="-all"

 fi
else
  SUP_OPT="-all"
fi

### add here a supportoption (DOC1)
case $SUP_OPT in
  -all|-full) 		INF=$ALL_INF ;;
  -modem)  		INF=$MODEM_INF ;;
  -tv)     		INF=$TV_INF ;;
  -dsl )   		INF=$DSL_INF ;;
  -hw)     		INF=$HW_INF ;;
  -pcmcia|-laptop) 	INF=$PCMCIA_INF ;;
  -net)    		INF=$NET_INF ;;
  -mail)		INF=$MAIL_INF ;;
  -boot)   		INF=$BOOT_INF ;;
  -x11)    		INF=$X11_INF ;;
  -inst|-install) 	INF=$INSTALL_INF ;;
  -sound)  		INF=$SOUND_INF ;;
  -print|-printer)  	INF=$PRINT_INF ;;
  -print-detect-only)	INF=$PRINT_DO_INF;;
  -cdr)  		INF=$CDR_INF ;;
  -isdn)                INF=$ISDN_INF ;;
  -isdn-test)           INF=$ISDN_TEST_INF ;;
  -usb)			INF=$USB_INF ;;
  -isdn+laptop)		INF=$ISDN_LAPTOP ;;
  -you)			INF=$YOU_INF ;;
  -m) 			true ;;
  *)
       unknown_option
       basic_option_check ;;
esac
}

echo -e "\n siga - System Information gathering $VER mlasars@suse.de & jsj@suse.de $VERDATE"

support_option_check

tmp_floppy () {
# write test, if /tmp is not usable, try to use /media/floppy
touch $SIGA_OUT
  case $? in
       1) if [ "$USERLANG" = "de" ] ; then
            echo -e "\n Fehler !!!, $TMP_DIR nicht kann nicht genutzt werden \n\n"
          else
            echo -e "\n Error !!!, $TMP_DIR is not usable \n\n"
          fi

   if [ "$USERLANG" = "de" ] ; then
     echo -e " \n Bitte legen Sie eine Diskette in das erste Diskettenlaufwerk $FLOPPY_DEV ein.
 ACHTUNG! Die Disktette wird überschrieben, alle Daten werden gelöscht
 Bitte schreiben Sie YES um die Disketten zu formatieren"
   else
   echo -e "\n Please insert a floppydisk in the first floppydrive $FLOPPY_DEV
 WARNING! All data on floppydisk will be overwritten, all files will be deleted
 Please type YES to format the floppydisk "
   fi

read FLOPPY
if [ "$FLOPPY" = "YES" ] ; then
  echo -e "\n please wait / bitte warten \n"
  umount /media/floppy 2> /dev/null
  sleep 2
  mkfs.msdos $FLOPPY_DEV
  case $? in
       0) echo -e "\n disk in $FLOPPY_DEV cleared ...\n" ;;

       1) if [ "$USERLANG" = "de" ] ; then
            echo -e "\n Fehler !!!, bitte benutzen Sie eine andere Diskette \n und starten Sie siga erneut \n\n"
          else
            echo -e "\n Error !!!, please try another Disk \n and start siga again\n\n"
          fi
          exit 1 ;;
  esac

  mount /media/floppy

  TMP_DIR="/media/floppy/"
  SIGA_OUT="$TMP_DIR"siga.html""
  SIGA_OUT_TXT="$TMP_DIR"siga.txt""
  SIGA_OUT_Y="$TMP_DIR"siga_yast.html""
  SIGA_OUT_PC="$TMP_DIR"siga_pc.html""
  SIGA_HEAD="$TMP_DIR.siga_head.html"
  MOUNT_FLOPPY=1
fi

esac
}

# roottest
if test "$UID" != "0" -a "$USER" != root -a -z "$ROOT" ; then

  export USERHOMEDIR="$HOME"

  export USERLANG=`echo $LANG|cut -c1-2`
  if [ "$USERLANG" = "de" ] ; then
    echo -e "\n *** Bitte schliessen Sie nicht dieses Fenster ***\n\n Sie müssen siga als root starten.\n Bitte geben Sie das rootpasswort ein:\n\n"
  else
    echo -e "\n *** please don't close this window ***\n\n You must be root to run siga.\n please enter the root password :\n\n"
  fi

      if [ "$DISPLAY" = "" ] ; then
 	su -c "$(basename $0) $*"
        exit
      else
        sux -c "$(basename $0) $*"
        exit
      fi
fi

echo "- root test done, making temporary directory..."

# if we are a subdirectory of /tmp, do not wipe /tmp...
if [ "`dirname $TMP_DIR`" = "/tmp" ]; then
  rm -rf $TMP_DIR
fi

# mode 700 since syslogs and packet filter rules (among other stuff) are
# involved.
mkdir -m 700 $TMP_DIR || {
  echo "could not create temporary directory, bailing out."
  echo "Please remove $TMP_DIR manually. Stop."
  exit 200
}

find `dirname $TMP_DIR` -maxdepth 1 -type l -user root -name '*siga*' -exec rm -f {} \;


if [ "$CLI1" = "-m" ] ; then
  echo -e " press CTRL c to exit - drücken Sie STRG c zum beenden \n"
  tail -f /var/log/messages
  exit
fi

USERLANG=`grep RC_LANG= /etc/sysconfig/language | cut -f 2 -d \" | cut -f1 -d _`

umask 077

# is X running?
if [ "$DISPLAY" = "" ] ; then
  X_RUN=0
  BROWSER_PUR="w3m"
  echo "- *** no X running"
fi

#export $DISPLAY if ip:option is set
if [ "`echo $CLI1 | cut -c1-3`" = "ip:" ]; then
  export DISPLAY=`echo $CLI1 | cut -c4-`
fi

echo "- X test done"

editorbrowser_check () {
case $EDITOR in
           vi )
		if [ -x /bin/vi ] ; then
                  EDITOR="vi"
                else
                 echo "- *** no editor found"
                 EDITOR="true"
                fi ;;

        kedit )
 	   	if [ -x /opt/kde3/bin/kedit ] ; then
                  EDITOR="kedit"
                else
                  EDITOR=""
                  editorbrowser_check
                fi ;;

	    * )
            	if [ -x /usr/bin/pico ] ; then
              	  EDITOR="pico -w"
            	else
                 if [ -x /usr/bin/vi ] ; then
                   EDITOR="vi"
                 else
                   echo "- *** no editor found"
                   EDITOR="true"
                 fi
                fi ;;

esac

case $BROWSER_PUR in

	lynx )
 		if [ -x /usr/bin/lynx ] ; then
                BROWSER="lynx $SIGA_OUT"
                BROWSER_PUR="lynx"
                else
                BROWSER="cat $SIGA_OUT_TXT"
                BROWSER_PUR="cat"
                fi ;;

       konqueror )
                if [ -x /opt/kde3/bin/konqueror ] ; then
                  BROWSER="/opt/kde3/bin/konqueror $SIGA_OUT"
                  BROWSER_PUR="konqueror"
                else
                  BROWSER_PUR=""
	          editorbrowser_check
                fi ;;

  	netscape )
          	NET_SC=`type -p netscape`
           	if [ -x $NET_SC ] && [ "$NET_SC" != "" ] ; then
            	  BROWSER="$NET_SC $SIGA_OUT"
           	  BROWSER_PUR="netscape"
          	else
  		  BROWSER_PUR=""
             	  editorbrowser_check
		fi ;;

	cat )
            	BROWSER="cat $SIGA_OUT_TXT"
             	BROWSER_PUR="cat"
             	EDITOR="true" ;;

	     * )
              	if [ -x /usr/bin/w3m ] ; then
                  BROWSER="w3m $SIGA_OUT"
                  BROWSER_PUR="w3m"
                else
                   if [ -x /usr/bin/lynx ] ; then
                     BROWSER="lynx $SIGA_OUT"
                     BROWSER_PUR="lynx"
                   else
                     BROWSER="cat $SIGA_OUT_TXT"
                     BROWSER_PUR="cat"
                   fi
               	fi ;;
esac
}

case $CLI1 in

	cat )
             BROWSER_PUR="cat"
	     editorbrowser_check ;;

       	lynx )
            BROWSER_PUR="lynx"
            EDITOR="pico"
            editorbrowser_check ;;

	lynxvi )
            BROWSER_PUR="lynx"
 	    EDITOR="vi"
            editorbrowser_check ;;

	 w3m )
            EDITOR="pico"
	    BROWSER_PUR="w3m"
            editorbrowser_check ;;

	w3mvi )
            EDITOR="vi"
            editorbrowser_check ;;

	kon )
    	     BROWSER_PUR="konqueror"
             EDITOR="kedit"
             editorbrowser_check ;;

       	net )
             BROWSER_PUR="netscape"
             EDITOR="kedit"
             editorbrowser_check ;;
	ip* )
             BROWSER_PUR="netscape"
             EDITOR="kedit"
             editorbrowser_check ;;


	* ) # enter here the default browser/editor
# 	     BROWSER_PUR="konqueror"
#            EDITOR="kedit"
	     editorbrowser_check ;;

esac

echo "- *** using $BROWSER_PUR"
echo "- *** using $EDITOR"

# make dummy file for editorstart
dummy_file () {
  echo "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 2.0//EN">
        <HTML><HEAD><TITLE>siga - edit</TITLE></HEAD><BODY>
        <H1> please wait - this could take a while ... </h1>
        <PRE>" > $TMP_DIR.siga_edit_$LINK_EDIT.html

  if [ "$USERLANG" = "de" ] ; then
    echo "<H1> Bitte warten </h1>
          <PRE>" >> $TMP_DIR.siga_edit_$LINK_EDIT.html
  fi

  if [ "$EDITOR" = "pico -w" ] || [ "$EDITOR" = "vi" ] ; then
    if [ "$USERLANG" = "de" ] ; then
      echo "

        $EDITOR startet im anderen Fenster, bitte klicken Sie es nach vorne.
         " >> $TMP_DIR.siga_edit_$LINK_EDIT.html
    else
      echo "

        $EDITOR starts in the other window, please click it to front.
         " >> $TMP_DIR.siga_edit_$LINK_EDIT.html
    fi
  fi

  if [ "$USERLANG" = "de" ] ; then
    echo "        Wenn nach beenden von $EDITOR nichts passiert,
        versuchen Sie bitte folgendes:

        -Schauen Sie im Terminal (Konsole) nach, ob eine Fehlermeldung ausgegeben
         wurde und folgen diesem Link <a href="$SIGA_OUT">back to siga data</a><BR>
          oder

        -Beenden Sie $BROWSER_PUR und starten Sie siga noch einmal

        </pre><BR>
        <a href="$SIGA_OUT">back to siga data</a><BR><BR>
        </BODY></HTML>" >> $TMP_DIR.siga_edit_$LINK_EDIT.html
  else
    echo "        If after editing and closing $EDITOR nothing happens,
        please try:

        -take a look to the terminal, if you got an error message just
         follow the link <a href="$SIGA_OUT">back to siga data</a><BR>
          or

        -close $BROWSER_PUR and start siga again

        </pre><BR>
        <a href="$SIGA_OUT">back to siga data</a><BR><BR>
        </BODY></HTML>" >> $TMP_DIR.siga_edit_$LINK_EDIT.html
  fi
}

# make link edit
link_edit () {
LINK_REAL=`echo $LINK_EDIT | sed s,~,/,g`
if [ "$CLI1" != "cat" ] ; then
    if  [ "`echo $CLI1 | cut -c1-3`" = "ip:" ] && [ "$REMOTE_EDIT" != "YES" ] ; then
       echo "     no edit on remote displays until you change REMOTE_EDIT=YES in /usr/bin/siga <br><br><hr>" >> $SIGA_OUT
    else

       if [ "$TMP_DIR" != "/tmp/siga/" ] ; then
         echo " <a href=#top>top</a><br>" >> $SIGA_OUT
       else
         echo "<a href=#top>top</a><br>     <a href="$TMP_DIR.siga_edit_$LINK_EDIT.html">edit $LINK_REAL</a><br><br>" >> $SIGA_OUT
       fi
    fi
fi
   dummy_file
}

link_edit_pc () {
LINK_REAL=`echo $LINK_EDIT | sed s,~,/,g`
if [ "$CLI1" != "cat" ] ; then
  echo "<a href=#top>top</a>
        <a href="$TMP_DIR.siga_edit_$LINK_EDIT.html">edit $LINK_REAL</a>
        <br><br><hr>" >> $SIGA_OUT_PC

fi
  dummy_file
  echo "- $LINK_REAL info done"
}

pre_edit_file () {
  if [ "$BROWSER_PUR" = "lynx" ] || [ "$BROWSER_PUR" = "w3m" ] || [ "$BROWSER_PUR" = "konqueror" ] ; then
    killall $BROWSER_PUR
  fi

if  [ "`echo $CLI1 | cut -c1-3`" = "ip:" ]; then
  post_edit_file
export EDITOR="/bin/true"
fi
}

link_top () {
  if [ "$CLI1" != "cat" ] ; then
    echo "</PRE><a href=#top>top</a><hr>" >> $SIGA_OUT
  else
    echo "</PRE><hr>" >> $SIGA_OUT
  fi
}

# reload & restart
post_edit_file () {
  echo "  editing $DUMMY
        - restarting siga"
  gather
  RUN="start"
}

#end , clean up & cu
fin () {
  echo "stop" > $TMP_DIR.sigawhile
  if [ "$USERLANG" = "de" ] ; then
    echo -e "\n Sie finden die Ausgabe hier:\n\n $SIGA_OUT\n $SIGA_OUT_TXT\n\n Sie können das Fenster jetzt schliessen\n"
  else
    echo -e "\n You will find the output here:\n\n $SIGA_OUT\n $SIGA_OUT_TXT\n\n you may now close the window.\n"
  fi

  if [ "$CLI1" = "write" ] ; then
     if [ "$USERLANG" = "de" ] ; then
      echo -e "\n Die Daten wurden zusätzlich geschrieben:"
    else
      echo -e "\n Data is also written to:\n"
    fi
      echo -e "\n "$WRITE_DIR""/siga/siga_""$DATE.html"" 
      echo -e " "$WRITE_DIR""/siga/siga_""$DATE.txt"\n"     
  fi

  if [ "$CLI1" = "floppy" ] ; then
     if [ "$USERLANG" = "de" ] ; then
      echo -e "\n Die Daten wurden zusätzlich auf diskette geschrieben\n"
    else
      echo -e "\n Data is also written on floppydisk\n"
    fi
  fi

  rm $TMP_DIR.siga*
  if [ "$MOUNT_FLOPPY" = "1" ] ; then
    sleep 2
    umount /media/floppy
  fi

  exit 0
}

html_head () {
# remove old files
  rm $SIGA_OUT $SIGA_HEAD $SIGA_OUT_TXT $SIGA_OUT_Y $SIGA_OUT_PC 2>/dev/null
  echo "- beginning gathering ... this may take a while"
  echo ""
}

echo "<TABLE><TR>
        <TD valign=top>" >> $SIGA_HEAD

hw_head_gen () {
if [ "$SUP_OPT" = "-all" ] ; then
  if [ "$COL_COUNT" = "99" ] || [ "$COL_COUNT" = "3" ] || [ "$COL_COUNT" = "4" ] || [ "$COL_COUNT" = "10" ] || [ "$COL_COUNT" = "11" ] ; then
    echo -e "<li>---</li>"  >> $SIGA_HEAD
  else
    echo "</TD><TD valign=top>" >> $SIGA_HEAD
  fi
else
  echo "</TD><TD valign=top>" >> $SIGA_HEAD
fi
echo "<li><a href=#"$1">$COL_COUNT. $1</a></li>" >> $SIGA_HEAD
}

################################################################################
hw_head_usb () {
  COL_COUNT=3
  TABLE_COUNT=0
  hw_head_gen USB
  echo "<a name=USB><H1>$COL_COUNT. USB</H1><hr>" >> $SIGA_OUT
}

hw_usb_lsusb () { SIGA_M_NAME="lsusb" SIGA_M_OUT="/sbin/lsusb" SIGA_M_TYPE="com" ; main ; }
hw_usb_hwinfo (){ SIGA_M_NAME="hwinfo --usb" SIGA_M_OUT="/usr/sbin/hwinfo --usb" SIGA_M_TYPE="com" ; main ; }
hw_usb_sys_hot () { SIGA_M_NAME="hotplug" SIGA_M_OUT="/etc/sysconfig/hotplug" ; main ; }



hw_top () {
  COL_COUNT=1
  TABLE_COUNT=0
  hw_head_gen Hardware
  echo "<a name=Hardware><H1>$COL_COUNT. Hardware</H1><hr>" >> $SIGA_OUT
}

hw_cpu () 	{ SIGA_M_NAME="CPU" SIGA_M_OUT="/proc/cpuinfo" ; main ; }
hw_io ()  	{ SIGA_M_NAME="IO-Ports" SIGA_M_OUT="/proc/ioports" ; main ; }
hw_dma () 	{ SIGA_M_NAME="DMA" SIGA_M_OUT="/proc/dma" ; main ; }
hw_dev () 	{ SIGA_M_NAME="devices" SIGA_M_OUT="/proc/devices" ; main ; }
hw_usb () 	{ SIGA_M_NAME="USB-devices" SIGA_M_OUT="/proc/bus/usb/devices" ; main ; }
hw_hw_cdr ()    { SIGA_M_NAME="hwinfo --cdrom" SIGA_M_OUT="/usr/sbin/hwinfo --cdrom" SIGA_M_TYPE="com" ; main ; }

hw_setserial () {
  echo "<a name=setserial><H2>$COL_COUNT.$TABLE_COUNT Setserial</H2><PRE>" >> $SIGA_OUT
  setserial -ag /dev/ttyS? >> $SIGA_OUT 2>&1
  link_top
  echo " <li><a href=#setserial>$COL_COUNT.$TABLE_COUNT Setserial</a></li>" >> $SIGA_HEAD
  echo "- setserial info done"
}


hw_isa_pnp ()   { SIGA_M_NAME="ISA-PNP" SIGA_M_OUT="/usr/sbin/hwinfo --isapnp" SIGA_M_TYPE="com" ; main ; }
hw_procinfo ()  { SIGA_M_NAME="procinfo" SIGA_M_OUT="/usr/bin/procinfo" SIGA_M_TYPE="com"; main ; }
hw_hwinfo ()    { SIGA_M_NAME="hwinfo" SIGA_M_OUT="/usr/sbin/hwinfo" SIGA_M_TYPE="com" ; main ; }
hw_scsi ()  	{ SIGA_M_NAME="scsi" SIGA_M_OUT="/usr/sbin/hwinfo --scsi" SIGA_M_TYPE="com" ; main ; }
hw_hwinfo_net (){ SIGA_M_NAME="hwinfo-net" SIGA_M_OUT="/usr/sbin/hwinfo --network_ctrl" SIGA_M_TYPE="com" ; main ; }

hw_boot_dir ()  { SIGA_M_NAME="boot_dir" SIGA_M_OUT="/bin/ls -la /boot" SIGA_M_TYPE="com" ; main ; }
hw_hotplug ()   { SIGA_M_NAME="hotplug" SIGA_M_OUT="/etc/sysconfig/hotplug" EDIT_FILE="yes" ; main ; }
hw_hwinfo_storage () 	{ SIGA_M_NAME="hwinfo-storage" SIGA_M_OUT="/usr/sbin/hwinfo --storage_ctrl" SIGA_M_TYPE="com" ; main ; }
hw_hwinfo_disk () 	{ SIGA_M_NAME="hwinfo-disk" SIGA_M_OUT="/usr/sbin/hwinfo --disk" SIGA_M_TYPE="com" ; main ; }
hw_boot_initrd () 	{ SIGA_M_NAME="Kernel" SIGA_M_OUT="/etc/sysconfig/kernel" EDIT_FILE="yes" ; main ; }

hw_boot ()  	{ SIGA_M_NAME="boot.msg" SIGA_M_OUT="/var/log/boot.msg" SIGA_M_MERGE="yes" ; main ; 
SIGA_M_TOP="no" SIGA_M_NAME="dmesg" SIGA_M_OUT="/bin/dmesg" ; SIGA_M_TYPE="com" ; main ;}
hw_cdr () 	{ SIGA_M_NAME="cdr" SIGA_M_OUT="/bin/rpm -q cdrecord" SIGA_M_TYPE="com" SIGA_M_MERGE="yes" ; main ; 
SIGA_M_TOP="no" SIGA_M_NAME="cdr" SIGA_M_OUT="/bin/rpm -q mkisofs" SIGA_M_TYPE="com" ; main ; }

hw_pci () { 
if [ "`lspci 2> /dev/null | grep Communication`" != "" ] ; then
  echo "*** maybe a winmodem found: `lspci 2> /dev/null | grep Communication`<br>" >> $SIGA_OUT ; 
fi

SIGA_M_NAME="lsPCI" SIGA_M_OUT="/sbin/lspci" SIGA_M_TYPE="com" SIGA_M_MERGE="yes" ; main ; 
SIGA_M_TOP="no" SIGA_M_NAME="lspci" SIGA_M_OUT="/sbin/lspci -vvv" SIGA_M_TYPE="com" ; main ; 
SIGA_M_TOP="no" SIGA_M_NAME="lspci" SIGA_M_OUT="/sbin/lspci -n" SIGA_M_TYPE="com" ; main ; }

hw_soundc () 	{ SIGA_M_NAME="sysconfig sound" SIGA_M_OUT="/etc/sysconfig/sound" EDIT_FILE="yes" ; main ; }

hw_sound_modp ()    { SIGA_M_NAME="modprobe.d sound" SIGA_M_OUT="/etc/modprobe.d/sound" EDIT_FILE="yes" ; main ; }
hw_hwinfo_sound () { SIGA_M_NAME="hwinfo-sound" SIGA_M_OUT="/usr/sbin/hwinfo --sound" SIGA_M_TYPE="com" ; main ; }
hw_sound_misc () {
SIGA_M_NAME="sound-misc" SIGA_M_OUT="/proc/asound/version" SIGA_M_MERGE="yes" ; main ; 
SIGA_M_TOP="no" SIGA_M_NAME="sound" SIGA_M_OUT="/proc/asound/cards" SIGA_M_MERGE="yes" ; main ;
link_top
}

sound_alsa_modules () { SIGA_M_NAME="alsa modules" SIGA_M_OUT="/proc/asound/modules" ; main ; }



hw_pcmcia () {
SIGA_M_NAME="pcmcia" SIGA_M_OUT="/etc/sysconfig/pcmcia" SIGA_M_EDIT="yes" SIGA_M_MERGE="yes" EDIT_FILE="yes" ; main ; 
SIGA_M_TOP="no" SIGA_M_NAME="pcmcia" SIGA_M_OUT="/sbin/cardctl ident" SIGA_M_TYPE="com" SIGA_M_MERGE="yes" ; main ;
SIGA_M_TOP="no" SIGA_M_NAME="pcmcia" SIGA_M_OUT="/sbin/probe -m" SIGA_M_TYPE="com" SIGA_M_MERGE="yes" ; main ;
SIGA_M_TOP="no" SIGA_M_NAME="pcmcia" SIGA_M_OUT="/bin/rpm -q pcmcia" SIGA_M_TYPE="com" SIGA_M_MERGE="yes" ; main ;
SIGA_M_TOP="no" SIGA_M_NAME="pcmcia" SIGA_M_OUT="/etc/pcmcia/config" SIGA_M_EDIT="yes" SIGA_M_MERGE="yes" ; main ; 
link_top
}


hw_devdir () {
SIGA_M_NAME="devdir" SIGA_M_TYPE="null" SIGA_M_MERGE="yes" ; main ; 
  ls -l /dev/* | grep -v tty >> $SIGA_OUT 2>&1
  link_top
  echo "- devdir done"
}



hw_links () {
SIGA_M_NAME="media links" SIGA_M_TYPE="null" SIGA_M_MERGE="yes" ; main ; 
  echo -e "\n --- /cd - /dvd --- " >> $SIGA_OUT
  ls -l / | grep 'cdr.*\|dvd.*' >> $SIGA_OUT 2>&1
  echo -e "\n --- /media/ --- " >> $SIGA_OUT
  ls -l /media/ >> $SIGA_OUT 2>&1
  echo -e "\n --- /dev/cdr* --- " >> $SIGA_OUT
  ls -l /dev/cdr* >> $SIGA_OUT 2>&1
  echo -e "\n --- /dev/dvd* --- " >> $SIGA_OUT
  ls -l /dev/dvd* >> $SIGA_OUT 2>&1
  echo -e "\n --- /dev/cdrecorder* --- " >> $SIGA_OUT
  ls -l /dev/cdrecorder* >> $SIGA_OUT 2>&1
  echo -e "\n --- /dev/fd? --- " >> $SIGA_OUT
  ls -l /dev/fd? >> $SIGA_OUT 2>&1
  link_top
  echo "- cd/dvd links done"
}

hw_media () {
SIGA_M_NAME="hwinfo-sound" SIGA_M_OUT="/usr/sbin/hwinfo --sound" SIGA_M_TYPE="com" ; main ; }
hw_sound_misc () {
SIGA_M_NAME="sound-misc" SIGA_M_OUT="/proc/asound/version" SIGA_M_MERGE="yes" ; main ; 
SIGA_M_TOP="no" SIGA_M_NAME="sound" SIGA_M_OUT="/proc/asound/cards" SIGA_M_MERGE="yes" ; main ;
link_top
}

sound_alsa_modules () { SIGA_M_NAME="alsa modules" SIGA_M_OUT="/proc/asound/modules" ; main ; }

hw_pcmcia () {
SIGA_M_NAME="pcmcia" SIGA_M_OUT="/etc/sysconfig/pcmcia" SIGA_M_EDIT="yes" SIGA_M_MERGE="yes" EDIT_FILE="yes" ; main ; 
SIGA_M_TOP="no" SIGA_M_NAME="pcmcia" SIGA_M_OUT="/sbin/cardctl ident" SIGA_M_TYPE="com" SIGA_M_MERGE="yes" ; main ;
SIGA_M_TOP="no" SIGA_M_NAME="pcmcia" SIGA_M_OUT="/sbin/probe -m" SIGA_M_TYPE="com" SIGA_M_MERGE="yes" ; main ;
SIGA_M_TOP="no" SIGA_M_NAME="pcmcia" SIGA_M_OUT="/bin/rpm -q pcmcia" SIGA_M_TYPE="com" SIGA_M_MERGE="yes" ; main ;
SIGA_M_TOP="no" SIGA_M_NAME="pcmcia" SIGA_M_OUT="/etc/pcmcia/config" SIGA_M_EDIT="yes" SIGA_M_MERGE="yes" ; main ; 
link_top
}

hw_links () {
SIGA_M_NAME="media links" SIGA_M_TYPE="null" SIGA_M_MERGE="yes" ; main ; 
  echo -e "\n --- /cd - /dvd --- " >> $SIGA_OUT
  ls -l / | grep 'cdr.*\|dvd.*' >> $SIGA_OUT 2>&1
  echo -e "\n --- /media/ --- " >> $SIGA_OUT
  ls -l /media/ >> $SIGA_OUT 2>&1
  echo -e "\n --- /dev/cdr* --- " >> $SIGA_OUT
  ls -l /dev/cdr* >> $SIGA_OUT 2>&1
  echo -e "\n --- /dev/dvd* --- " >> $SIGA_OUT
  ls -l /dev/dvd* >> $SIGA_OUT 2>&1
  echo -e "\n --- /dev/cdrecorder* --- " >> $SIGA_OUT
  ls -l /dev/cdrecorder* >> $SIGA_OUT 2>&1
  echo -e "\n --- /dev/fd? --- " >> $SIGA_OUT
  ls -l /dev/fd? >> $SIGA_OUT 2>&1
  link_top
  echo "- cd/dvd links done"
}

hw_media () { SIGA_M_NAME="media" SIGA_M_OUT="/bin/ls -l /media" SIGA_M_TYPE="com" ; main ; }

################################################################################
# harddisk
hd_part () { 
echo "<a name=harddisk><H2>$COL_COUNT.$TABLE_COUNT Hardisk</H2><HR><PRE>" >> $SIGA_OUT
SIGA_M_NAME="partitions" SIGA_M_OUT="/sbin/fdisk -l" SIGA_M_TYPE="com" ; main ; }

hd_mount () { SIGA_M_NAME="Mountpoints" SIGA_M_OUT="/proc/mounts" ; main ; }
hd_fstab () { SIGA_M_NAME="fstab" SIGA_M_OUT="/etc/fstab" EDIT_FILE="yes" ; main ; }

hd_set () {
  echo "<a name=settings><H2>$COL_COUNT.$TABLE_COUNT Settings</H2><PRE>" >> $SIGA_OUT
  if [ -e /proc/ide ]; then
    cat /proc/ide/hd*/settings >> $SIGA_OUT
  else
    echo "no ide harddisks found<br><br>" >> $SIGA_OUT
  fi
  link_top
  echo " <li><a href=#settings>$COL_COUNT.$TABLE_COUNT Settings</a></li>" >> $SIGA_HEAD
  echo "- settings info done"
}

################################################################################
# YOU

you_top () {
  COL_COUNT=$(($COL_COUNT+1))
  TABLE_COUNT=0
  hw_head_gen Software
  echo "<a name=YOU><H2>$COL_COUNT. YOU</H2><hr>" >> $SIGA_OUT
}


you_y2log () {
  echo "<a name=you_y2log><H2>$COL_COUNT.$TABLE_COUNT you y2log</H2>" >> $SIGA_OUT
  echo "<h4>/var/log/YaST2/y2log</h4><pre>" >> $SIGA_OUT
  echo -e "SIGA_$DATE" >> /var/log/YaST2/y2log
  Y2SLOG_DEBUG=1 yast2 online_update
  # sometimes its not in the main file ...
  if [ "`grep "SIGA_$DATE" /var/log/YaST2/y2log`" = "" ] ; then
    grep -A 10000 "SIGA_$DATE" /var/log/YaST2/y2log-1 >> $SIGA_OUT
    cat /var/log/YaST2/y2log >> $SIGA_OUT
  else
    grep -A 10000 "SIGA_$DATE" /var/log/YaST2/y2log >> $SIGA_OUT
  fi
  link_top
  echo " <li><a href=#you_y2log>$COL_COUNT.$TABLE_COUNT you y2log</a></li>" >> $SIGA_HEAD
  echo "- y2log info done"
}

you_config () { SIGA_M_NAME="you_config" SIGA_M_OUT="/var/lib/YaST2/you/config" ; main ; }
you_servers () { SIGA_M_NAME="you_servers" SIGA_M_OUT="/var/lib/YaST2/you/youservers" ; main ; }
you_sysconf () { SIGA_M_NAME="you_sysconf" SIGA_M_OUT="/etc/sysconfig/onlineupdate" ; main ; }
you_wgetrc () { SIGA_M_NAME="you_wgetrc" SIGA_M_OUT="/etc/wgetrc" ; main ; }


################################################################################
soft_top () {
  COL_COUNT=$(($COL_COUNT+1))
  TABLE_COUNT=0
  hw_head_gen Software
  echo "<a name=Software><H2>$COL_COUNT. Software</H2><hr>" >> $SIGA_OUT
}

soft_modules () { SIGA_M_NAME="modules" SIGA_M_OUT="/proc/modules" ; main ; }

soft_rpm () {
  SIGA_M_NAME="RPM" SIGA_M_OUT="rpm -qa" SIGA_M_TYPE="null" SIGA_M_MERGE="yes" ; main
  echo "Paketname   Version         Size        Description
        <hr><PRE>" >> $SIGA_OUT
  rpm -qa --queryformat '%-25{NAME}  %-16{VERSION} %-10{RELEASE} %-10{DISTRIBUTION}  %-10{SIZE} %-10{INSTALLTIME:date} %{SUMMARY}\n'|sort >> $SIGA_OUT 2>&1
  link_top
}

################################################################################
net_top () {
  COL_COUNT=$(($COL_COUNT+1))
  TABLE_COUNT=0
  hw_head_gen Network
  echo "<a name=Network><H2>11. network</H2><hr>" >> $SIGA_OUT
}
  
net_ifcfg () {
  echo "<a name=ifcfg><H2>$COL_COUNT.$TABLE_COUNT ifcfg</H2>" >> $SIGA_OUT
  for IFCFG in `ls /etc/sysconfig/network/ifcfg-* 2> /dev/null` ; do
    LINK_EDIT=~etc~sysconfig~network~$(basename "$IFCFG")
    echo "<h4>$IFCFG</h4><pre>" >> $SIGA_OUT
    cat "$IFCFG" | sed s/"password"\.*\=\.*\/"### password data ### marked out ###"/i | sed s/"WIRELESS_KEY"\.*\=\.*\/"### password data ### marked out ###"/i >> $SIGA_OUT
    link_top
  done
  if [ $IFCFG = "" ]; then
    echo "no /etc/network/ifcfg-* found <br><br>" >> $SIGA_OUT
    link_top
  fi
  echo " <li><a href=#ifcfg>$COL_COUNT.$TABLE_COUNT ifcfg</a></li>" >> $SIGA_HEAD
  echo "- ifcfg info done"
}

net_routes ()   { SIGA_M_NAME="routes" SIGA_M_OUT="/etc/sysconfig/network/routes" EDIT_FILE="yes" ; main ; }
net_ifstatus () { SIGA_M_NAME="ifstatus" SIGA_M_OUT="/sbin/ifconfig" SIGA_M_TYPE="com" ; main ; }
net_config () 	{ SIGA_M_NAME="network-config" SIGA_M_OUT="/etc/sysconfig/network/config" EDIT_FILE="yes" ; main ; }
net_sysctl () 	{ SIGA_M_NAME="sysctl" SIGA_M_OUT="/etc/sysconfig/sysctl" EDIT_FILE="yes" ; main ; }
net_proxy () 	{ SIGA_M_NAME="proxy" SIGA_M_OUT="/etc/sysconfig/proxy" EDIT_FILE="yes" ; main ; }
net_security () { SIGA_M_NAME="SuSEfirewall2" SIGA_M_OUT="/etc/sysconfig/SuSEfirewall2" EDIT_FILE="yes" ; main ; }
net_personalfirewall () { SIGA_M_NAME="Personal-Firewall" SIGA_M_OUT="/etc/sysconfig/personal-firewall" EDIT_FILE="yes" ; main ; }
net_ipv4_forward () { SIGA_M_NAME="ipv4 ip_forward" SIGA_M_OUT="/proc/sys/net/ipv4/ip_forward" ; main ; }
net_sendmail () { SIGA_M_NAME="sendmail" SIGA_M_OUT="/etc/sysconfig/sendmail" EDIT_FILE="yes" ; main ; }
net_ssh () 	{ SIGA_M_NAME="ssh" SIGA_M_OUT="/etc/sysconfig/ssh" EDIT_FILE="yes" ; main ; }
net_route ()  	{ SIGA_M_NAME="route" SIGA_M_OUT="/sbin/route -n" SIGA_M_TYPE="com" ; main ; }
net_filter () 	{ SIGA_M_NAME="filter" SIGA_M_OUT="/usr/sbin/iptables -nL" SIGA_M_TYPE="com" ; main ; }
net_resolv () 	{ SIGA_M_NAME="resolv" SIGA_M_OUT="/etc/resolv.conf" EDIT_FILE="yes" ; main ; }
net_inetd ()    { SIGA_M_NAME="indetd" SIGA_M_OUT="/etc/inetd.conf" EDIT_FILE="yes" ; main ; }
net_dhcp ()     { SIGA_M_NAME="dhcp" SIGA_M_OUT="/etc/sysconfig/network/dhcp" EDIT_FILE="yes" ; main ; }

################################################################################

mail_top () {
  COL_COUNT=$(($COL_COUNT+1))
  TABLE_COUNT=0
  hw_head_gen Mail
  echo "<a name=Mail><H2>2. Mail</H2><hr>" >> $SIGA_OUT
}

mail_sendmail_v ()  { SIGA_M_NAME="sendmail changes" SIGA_M_OUT="/bin/rpm -V sendmail" SIGA_M_TYPE="com" ; main ; }
mail_postfix_v ()   { SIGA_M_NAME="postfix changes" SIGA_M_OUT="/bin/rpm -V postfix" SIGA_M_TYPE="com" ; main ; }
mail_amavis_sendmail ()   { SIGA_M_NAME="amavis-sendmail Version" SIGA_M_OUT="/bin/rpm -V amavis-sendmail" SIGA_M_TYPE="com" ; main ; }
mail_amavis_postfix ()    { SIGA_M_NAME="amavis-postfix Version" SIGA_M_OUT="/bin/rpm -V amavis-postfix" SIGA_M_TYPE="com" ; main ; }
mail_sysc_mail ()   { SIGA_M_NAME="Mail" SIGA_M_OUT="/etc/sysconfig/mail" EDIT_FILE="yes" ; main ; }
mail_aliases ()     { SIGA_M_NAME="aliases" SIGA_M_OUT="/etc/aliases" EDIT_FILE="yes" ; main ; }
mail_sysc_sendmail ()     { SIGA_M_NAME="sendmail" SIGA_M_OUT="/etc/sysconfig/sendmail" EDIT_FILE="yes" ; main ; }
mail_virtuser ()    { SIGA_M_NAME="virtuser" SIGA_M_OUT="/etc/mail/virtusertable" EDIT_FILE="yes" ; main ; }
mail_gentable ()    { SIGA_M_NAME="gentable" SIGA_M_OUT="/etc/mail/genericstable" EDIT_FILE="yes" ; main ; }
mail_postfix ()     { SIGA_M_NAME="postfix" SIGA_M_OUT="/etc/sysconfig/postfix" EDIT_FILE="yes" ; main ; }
mail_postfix_main ()      { SIGA_M_NAME="main.cf" SIGA_M_OUT="/etc/postfix/main.cf" EDIT_FILE="yes" ; main ; }
mail_postfix_virtual ()   { SIGA_M_NAME="postfix-virtual" SIGA_M_OUT="/etc/postfix/virtual" EDIT_FILE="yes" ; main ; }
mail_postfix_canonical () { SIGA_M_NAME="postfix-canonical" SIGA_M_OUT="/etc/postfix/sender_canonical" EDIT_FILE="yes" ; main ; }


mail_poll () {
SIGA_M_NAME="poll.tcpip" SIGA_M_TYPE="null" SIGA_M_MERGE="yes" ; main ;
  grep poll.tcpip /var/log/messages >> $SIGA_OUT
  link_top
  echo "- grep poll.tcpip done"
}


################################################################################
conf_top () {
  COL_COUNT=$(($COL_COUNT+1))
  TABLE_COUNT=0
  hw_head_gen Configuration
  echo "<a name=Configuration><H2>3. Configuration</H2><hr>" >> $SIGA_OUT
}

conf_rc () 	{ SIGA_M_NAME="rc.config" SIGA_M_OUT="/etc/rc.config" EDIT_FILE="yes" ; main ; }
conf_modules () { SIGA_M_NAME="modprobe.conf" SIGA_M_OUT="/etc/modprobe.conf" EDIT_FILE="yes" ; main ; }
conf_modules_local () { SIGA_M_NAME="modprobe.conf.local" SIGA_M_OUT="/etc/modprobe.conf.local" EDIT_FILE="yes" ; main ; }

conf_messages_filtered () {
  echo "<a name=messages_fil><H2>$COL_COUNT.$TABLE_COUNT messages filtered</H2>" >> $SIGA_OUT
  echo "<h4>/bin/grep -v "SFW2-" /var/log/messages | tail -n 100</h4><pre>" >> $SIGA_OUT
  /bin/grep -v "SFW2-" /var/log/messages | tail -n 200  >> $SIGA_OUT 2>&1
  link_top
  echo " <li><a href=#messages_fil>$COL_COUNT.$TABLE_COUNT messages filter</a></li>" >> $SIGA_HEAD
  echo "- messages filter info done"
}

conf_messages_firewall () {
  
  echo "<a name=messages_fw><H2>$COL_COUNT.$TABLE_COUNT messages firewall</H2>" >> $SIGA_OUT
  echo "<h4>/bin/grep "SFW2-" /var/log/messages | tail -n 100</h4><pre>" >> $SIGA_OUT
  /bin/grep "SFW2-" /var/log/messages | tail -n 100  >> $SIGA_OUT 2>&1
  link_top
  echo " <li><a href=#messages_fw>$COL_COUNT.$TABLE_COUNT messages fw</a></li>" >> $SIGA_HEAD
  echo "- messages fw info done"

}

conf_messages () { SIGA_M_NAME="messages"
  case "$SUP_OPT" in
	-you|-modem|-dsl|-net|-isdn|-full ) conf_messages_filtered ; conf_messages_firewall ;;	
	*) conf_messages_filtered ;;
  esac }

conf_y2log ()   { SIGA_M_NAME="y2log" SIGA_M_OUT="/usr/bin/tail -n 200 /var/log/YaST2/y2log" SIGA_M_TYPE="com" ; main ; }
conf_chkconf () { SIGA_M_NAME="chkconfig" SIGA_M_OUT="/sbin/chkconfig -l" SIGA_M_TYPE="com" ; main ; }

conf_grub ()      { SIGA_M_NAME="grub" SIGA_M_OUT="/boot/grub/menu.lst" EDIT_FILE="yes" ; main ; }
conf_device ()    { SIGA_M_NAME="device.map" SIGA_M_OUT="/boot/grub/device.map" EDIT_FILE="yes" ; main ; }
conf_grub_conf () { SIGA_M_NAME="grub.conf" SIGA_M_OUT="/etc/grub.conf" EDIT_FILE="yes" ; main ; }

conf_lilo ()      { SIGA_M_NAME="lilo.conf" SIGA_M_OUT="/etc/lilo.conf" EDIT_FILE="yes" ; SIGA_MERGE="yes" ; main ; }
conf_lilo_test () { SIGA_M_NAME="lilo_test" SIGA_M_OUT="/sbin/lilo -v 3 -t" SIGA_M_TYPE="com" ; main ; }
conf_cmdline ()   { SIGA_M_NAME="cmdline" SIGA_M_OUT="/proc/cmdline" ; main ; }

################################################################################
print_top () {
COL_COUNT=$(($COL_COUNT+1))
TABLE_COUNT=0
hw_head_gen Printer
  echo "<a name=Printer><H2>$COL_COUNT.$TABLE_COUNT Printer</H2><hr>" >> $SIGA_OUT
}

print_printcap () 	{ SIGA_M_NAME="printcap" SIGA_M_OUT="/etc/printcap" EDIT_FILE="yes" ; main ; }

print_par_auto () {
  echo "<a name=autoprobe><H2>$COL_COUNT.$TABLE_COUNT autoprobe</H2><PRE>" >> $SIGA_OUT
  cat /proc/sys/dev/parport/parport*/autoprobe >> $SIGA_OUT
  echo "</PRE><a href=#top>top</a><BR><HR>" >> $SIGA_OUT
  echo " <li><a href=#autoprobe>$COL_COUNT.$TABLE_COUNT autoprobe</a></li>" >> $SIGA_HEAD
  echo "- autoprobe info done"
}

print_sysc_printer () 	{ SIGA_M_NAME="printer" SIGA_M_OUT="/etc/sysconfig/printer" EDIT_FILE="yes" ; main ; }
print_hwinfo () 	{ SIGA_M_NAME="print_hwinfo" SIGA_M_OUT="/usr/sbin/hwinfo --printer" SIGA_M_TYPE="com" ; main ; }

print_cups_cupsd ()     { SIGA_M_NAME="cupsd.conf" SIGA_M_OUT="/etc/cups/cupsd.conf" EDIT_FILE="yes" ; main ; }
print_cups_printers ()  { SIGA_M_NAME="printers.conf" SIGA_M_OUT="/etc/cups/printers.conf" EDIT_FILE="yes" ; main ; }
print_cups_client ()    { SIGA_M_NAME="client.conf" SIGA_M_OUT="/etc/cups/client.conf" EDIT_FILE="yes" ; main ; }

print_cups_error ()     { SIGA_M_NAME="error.log" SIGA_M_OUT="/var/log/cups/error_log.test" ; main ; }
print_cups_prnlog ()    { SIGA_M_NAME="prnlog" SIGA_M_OUT="/tmp/prnlog" ; main ; }
print_cups_par ()       { SIGA_M_NAME="cups-par" SIGA_M_OUT="/usr/lib/cups/backend/parallel" SIGA_M_TYPE="com" ; main ; }
print_cups_usb ()       { SIGA_M_NAME="cups-usb" SIGA_M_OUT="/usr/lib/cups/backend/usb" SIGA_M_TYPE="com" ; main ; }
print_cups_types ()     { SIGA_M_NAME="mime.types" SIGA_M_OUT="/etc/cups/mime.types" ; main ; }
print_cups_convs ()     { SIGA_M_NAME="mime.convs" SIGA_M_OUT="/etc/cups/mime.convs" ; main ; }

print_cups_lpstat ()    { lpq 1>/dev/null ; SIGA_M_NAME="lpstat" SIGA_M_OUT="/usr/bin/lpstat -t" SIGA_M_TYPE="com" ; main ; }
print_cups_lpc ()       { lpq 1>/dev/null ; SIGA_M_NAME="lpc" SIGA_M_OUT="/usr/sbin/lpc status" SIGA_M_TYPE="com" ; main ; }

print_cups_net () { SIGA_M_NAME="netstat" 
  netstat -nap | grep :515 > $TMP_DIR.siga_$$_netstat
  netstat -nap | grep :631 > $TMP_DIR.siga_$$_netstat
  SIGA_M_OUT="$TMP_DIR.siga_$$_netstat"
  main  
}

print_cups_ps () {
  echo "<a name=cups_ps><H2>$COL_COUNT.$TABLE_COUNT cups_ps</H2>" >> $SIGA_OUT
  echo "<h4>ps auxwww | grep cups</h4><br><pre>" >> $SIGA_OUT
  echo -en "\r" | lpr ; sleep 1 ; ps auxwww | grep cups >> $SIGA_OUT
  echo "<a href=#top>top</a><BR><HR>" >> $SIGA_OUT  
  echo " <li><a href=#cups_ps>$COL_COUNT.$TABLE_COUNT cups_ps</a></li>" >> $SIGA_HEAD
  echo "- cups ps info done"
}

# check for used printing system
print_cups () {
rpm -q lprng && PRINT_SYS="lprng"
rpm -q cups && PRINT_SYS="cups"

if [ $PRINT_SYS = "cups" ] ; then

  COL_COUNT=$(($COL_COUNT+1))
  TABLE_COUNT=0
  hw_head_gen Cups
  echo "<a name=Cups><H2>3. Cups</H2><hr>" >> $SIGA_OUT

  echo "<a name=print_cups><H2>$COL_COUNT.$TABLE_COUNT Cups</H2><PRE>" >> $SIGA_OUT
    
  cp -p /etc/cups/cupsd.conf /etc/cups/cupsd.conf_siga
  sed s/"LogLevel info"/"LogLevel debug"/ /etc/cups/cupsd.conf > /etc/cups/cupsd.conf_new

  if [ "$SUP_OPT" = "-print" ] ; then
    mv /etc/cups/cupsd.conf_new /etc/cups/cupsd.conf
    /usr/sbin/rccups stop 
    mv /var/log/cups/error_log /var/log/cups/error_log.$(date +%Y%m%d%H%M%S)
    /usr/sbin/rccups start
  fi  

  if [ -e /usr/lib/cups/filter/cupsomatic ] ; then  
    cp -p /usr/lib/cups/filter/cupsomatic /usr/lib/cups/filter/cupsomatic_siga
    cp -p /usr/lib/cups/filter/cupsomatic /usr/lib/cups/filter/cupsomatic_new
    sed s/"debug = 0"/"debug = 1"/ /usr/lib/cups/filter/cupsomatic > /usr/lib/cups/filter/cupsomatic_new
    mv /usr/lib/cups/filter/cupsomatic_new /usr/lib/cups/filter/cupsomatic
  fi

  if [ -e /usr/lib/cups/filter/foomatic-rip ] ; then
    cp -p /usr/lib/cups/filter/foomatic-rip /usr/lib/cups/filter/foomatic-rip_siga
    cp -p /usr/lib/cups/filter/foomatic-rip /usr/lib/cups/filter/foomatic-rip_new
    sed -e 's/my $debug = 0;/my $debug = 1;/' /usr/lib/cups/filter/foomatic-rip > /usr/lib/cups/filter/foomatic-rip_new
    cp -p /usr/lib/cups/filter/foomatic-rip_new /usr/bin/foomatic-rip
  fi

  for i in $(seq 1 100) ; do lpq &> $TMP_DIR.siga_$$_lpq && break ; sleep 1 ; done

  echo -en "\r" | lpr &> $TMP_DIR.siga_$$_lpr

  if [ "$SUP_OPT" = "-print" ] ; then
    /usr/sbin/rccups stop
    mv /var/log/cups/error_log /var/log/cups/error_log.test
    mv /etc/cups/cupsd.conf_siga /etc/cups/cupsd.conf

    if [ -e /usr/lib/cups/filter/cupsomatic_siga ] ; then
      mv /usr/lib/cups/filter/cupsomatic_siga /usr/lib/cups/filter/cupsomatic
    fi

    if [ -e /usr/lib/cups/filter/foomatic-rip_siga ] ; then
      mv /usr/lib/cups/filter/foomatic-rip_siga /usr/bin/foomatic-rip
    fi

    /usr/sbin/rccups start
  fi

rm /usr/lib/cups/filter/cupsomatic_siga 2&> /dev/null

  echo -e "\n--- lpq/lpr errors ---\n\n" >> /var/log/cups/error_log.test
  echo -e "\n--- lpq ---\n `cat $TMP_DIR.siga_$$_lpq`\n" >> /var/log/cups/error_log.test
  echo -e "\n--- lpr ---\n `cat $TMP_DIR.siga_$$_lpr`" >> /var/log/cups/error_log.test
  echo -e "\n--- CUPS_SERVER = $CUPS_SERVER ---\n" >> /var/log/cups/error_log.test
  find /etc/ -type f -print0 | xargs -0 grep "CUPS_SERVER" 2> /dev/null >> /var/log/cups/error_log.test
fi
}

print_cups_ppd () {
  echo "<a name=ppd><H2>$COL_COUNT.$TABLE_COUNT /etc/cups/ppd/*.ppd</H2>" >> $SIGA_OUT
  if [ "`ls /etc/cups/ppd/*.ppd 2>/dev/null`" != "" ] ; then 
  for PPDFILES in `ls /etc/cups/ppd/*.ppd 2>/dev/null` ; do
    echo "<h4>$PPDFILES</h4><pre>" >> $SIGA_OUT
    cat $PPDFILES >> $SIGA_OUT
  done
  else
    echo "no ppd files found <br><br>" >> $SIGA_OUT
  fi
  echo "<a href=#top>top</a><BR><HR>" >> $SIGA_OUT
  echo " <li><a href=#ppd>$COL_COUNT.$TABLE_COUNT ppd</a></li>" >> $SIGA_HEAD
  echo "- printer ppd info done"
}

print_apsfilterrc2 () {
  echo "<a name=apsfilterrc.all><H2>$COL_COUNT.$TABLE_COUNT /etc/apsfilterrc.*</H2>" >> $SIGA_OUT
  for APSFILES in $(ls /etc/apsfilterrc.* 2> /dev/null | grep -v y2save); do
    LINK_EDIT=~etc~$(basename $APSFILES)
    echo "<h4>$APSFILES</h4><pre>" >> $SIGA_OUT
    link_edit
    cat $APSFILES >> $SIGA_OUT
    link_edit
  done
  if [ $APSFILES"_" = "_" ]; then
    echo "no apsfilterrc.* found <br><br>" >> $SIGA_OUT
    echo "<a href=#top>top</a><BR><HR>" >> $SIGA_OUT
  fi
  echo " <li><a href=#apsfilterrc.all>$COL_COUNT.$TABLE_COUNT apsfrc*</a></li>" >> $SIGA_HEAD
  echo "- apsfilterrc.* info done"
}


print_lpdfilter () {
  echo "<a name=lpdfilter><H2>$COL_COUNT.$TABLE_COUNT lpdfilter</H2>" >> $SIGA_OUT
  echo "<h4>$LPDFILES</h4><pre>" >> $SIGA_OUT
  for LPDFILES in $(ls /etc/lpdfilter/ 2> /dev/null); do
    LINK_EDIT=~etc~lpdfilter~$LPDFILES
    LINK_REAL=`echo $LINK_EDIT | sed s,~,/,g`
      if [ -d "$LINK_REAL" ] ; then
	echo "<hr><h4>$LINK_REAL</h4><pre>" >> $SIGA_OUT
 	for DIRFILES in $(ls $LINK_REAL 2> /dev/null); do
	 echo -e "\n --- $DIRFILES --- \n" >> $SIGA_OUT 
	 cat "`echo $LINK_EDIT | sed s,~,/,g`""/""$DIRFILES" >> $SIGA_OUT
	 LINK_EDIT_OLD=$LINK_EDIT
	 LINK_EDIT="$LINK_EDIT""~""$DIRFILES"
	 link_edit
	 LINK_EDIT=$LINK_EDIT_OLD
	done
      fi
  done
  echo "<HR>" >> $SIGA_OUT
  echo " <li><a href=#lpdfilter>$COL_COUNT.$TABLE_COUNT lpdfilter</a></li>" >> $SIGA_HEAD
  echo "- lpdfilter info done"
}

print_misc () {
  echo "<a name=print_misc><H2>$COL_COUNT.$TABLE_COUNT Print misc</H2><PRE>" >> $SIGA_OUT
  echo -e "\n --- grep PRINTER= /etc/SuSEconfig/profile --- \n" >> $SIGA_OUT
  grep PRINTER= /etc/SuSEconfig/profile >> $SIGA_OUT
  echo -e "\n --- lpc status --- \n" >> $SIGA_OUT
  lpc status >> $SIGA_OUT 2>&1
  echo -e "\n ---ps aux | grep lpd--- \n" >> $SIGA_OUT
  ps aux|grep lpd >> $SIGA_OUT 2>&1
  echo -e "\n --- ls -ls /dev/lp* --- \n" >> $SIGA_OUT
  ls -ls /dev/lp* >> $SIGA_OUT 2>&1
  echo -e "\n --- ls -ls /dev/usblp* --- \n" >> $SIGA_OUT
  ls -ls /dev/usblp* >> $SIGA_OUT 2>&1

  link_top
  echo " <li><a href=#print_misc>$COL_COUNT.$TABLE_COUNT Print misc</a></li>" >> $SIGA_HEAD
  echo "- printer status info done"
}

print_lpd () { SIGA_M_NAME="lpd.conf" SIGA_M_OUT="/etc/lpd.conf" EDIT_FILE="yes" SIGA_M_MERGE="yes" ; main ; 
	       SIGA_M_TOP="no" SIGA_M_NAME="ldp.perms" SIGA_M_OUT="/etc/lpd.perms" ; main ; }


################################################################################
comm_top () {
  COL_COUNT=$(($COL_COUNT+1))
  TABLE_COUNT=0
  hw_head_gen Communication
  echo "<a name=Communication> <H2>5. Communication</H2><br><hr>" >> $SIGA_OUT
}

comm_wvdial_conf () 	{ SIGA_M_NAME="wvdial.conf" SIGA_M_OUT="/etc/wvdial.conf" EDIT_FILE="yes" ; main ; }
comm_rc_dialout ()  	{ SIGA_M_NAME="rc_dialout" SIGA_M_OUT="/etc/rc.dialout" EDIT_FILE="yes" ; main ; }
comm_smpppd_conf () 	{ SIGA_M_NAME="smpppd.conf" SIGA_M_OUT="/etc/smpppd.conf" EDIT_FILE="yes" ; main ; }
comm_ppp_options () 	{ SIGA_M_NAME="pppoptions" SIGA_M_OUT="/etc/ppp/options" EDIT_FILE="yes" ; main ; }
comm_ppp_iooptions ()	{ SIGA_M_NAME="pppioptions" SIGA_M_OUT="/etc/ppp/ioptions" EDIT_FILE="yes" ; main ; }
comm_pppoed_conf () 	{ SIGA_M_NAME="dslpppoedconf" SIGA_M_OUT="/etc/pppoed.conf" EDIT_FILE="yes" ; main ; }
comm_dsl_smpppd_log ()     { SIGA_M_NAME="smpppd.log" SIGA_M_OUT="/var/log/smpppd/smpppd.log" ; main ; }
comm_dsl_smpppd_dsl ()     { SIGA_M_NAME="smpppd.dsl" SIGA_M_OUT="/var/log/smpppd/ifcfg-dsl0.log" ; main ; }

comm_peers_pppoe () 	{ SIGA_M_NAME="peerspppoe" SIGA_M_OUT="/etc/ppp/peers/pppoe" EDIT_FILE="yes" ; main ; }
comm_hwinfo_modem () 	{ SIGA_M_NAME="modem_hwinfo" SIGA_M_OUT="/usr/sbin/hwinfo --modem" SIGA_M_TYPE="com" ; main ; }
comm_isdn_ctrl () 	{ SIGA_M_NAME="isdn_ctrl" SIGA_M_OUT="/usr/sbin/isdnctrl list all" SIGA_M_TYPE="com" ; main ; }
comm_isdn_capi ()       { SIGA_M_NAME="isdn_capi" SIGA_M_OUT="/etc/sysconfig/isdn/capi.conf.contr0" ; main ; }
comm_chkconfig_smpppd ()    { SIGA_M_NAME="chkconfig smpppd" SIGA_M_OUT="/sbin/chkconfig -l smpppd" SIGA_M_TYPE="com" ; main ; }
comm_ifstatus_dhcp0 ()    { SIGA_M_NAME="dhcp-eth0" SIGA_M_OUT="/sbin/ifstatus-dhcp eth0" SIGA_M_TYPE="com" ; main ; }
comm_ifstatus_dhcp1 ()    { SIGA_M_NAME="dhcp-eth1" SIGA_M_OUT="/sbin/ifstatus-dhcp eth1" SIGA_M_TYPE="com" ; main ; }

isdn_test () {

cp -p /etc/ppp/ioptions /etc/ppp/ioptions_siga

grep -q '^debug' /etc/ppp/ioptions || echo -e '\ndebug\ndebug\ndebug\n' >>/etc/ppp/ioptions
echo "siga ISDN Test started" | logger

rcsmpppd stop
killall kinternet
rcisdn stop
rcisdn start
rcsmpppd start
sleep 5

/usr/bin/cinternet -start& 
echo -e "\n \n please wait 20 seconds ..."
sleep 20
echo "siga ISDN Test stopped" | logger

/usr/bin/cinternet -stop&
sleep 5

cp -p /etc/ppp/ioptions_siga /etc/ppp/ioptions

SIGA_M_NAME="messages" SIGA_M_OUT="/usr/bin/tail -n 200 /var/log/messages" SIGA_M_TYPE="com" ; main ; 

}


comm_providers () {
  echo "<a name=isdn_providers><H2>$COL_COUNT.$TABLE_COUNT providers</H2>" >> $SIGA_OUT
  for ISDN_P in $(ls /etc/sysconfig/network/providers/* 2> /dev/null ); do
   LINK_EDIT=~etc~sysconfig~network~providers~$(basename $ISDN_P)
    echo "<h4>$ISDN_P</h4><pre>" >> $SIGA_OUT
    link_edit
    cat $ISDN_P | sed s/"password"\.*\=\.*\/"### password data ### marked out ###"/i >> $SIGA_OUT
    link_edit
    echo "<hr>" >> $SIGA_OUT
  done
  if [ "$ISDN_P" = "" ]; then
    echo "no providers found <br><br>" >> $SIGA_OUT
 fi
  link_top
  echo " <li><a href=#isdn_providers>$COL_COUNT.$TABLE_COUNT providers</a></li>" >> $SIGA_HEAD
  echo "- providers info done"
}

comm_isdn_cfg () {
  echo "<a name=isdn_cfg><H2>$COL_COUNT.$TABLE_COUNT isdn_cfg</H2>" >> $SIGA_OUT
  for ISDN_CFG in $(ls /etc/sysconfig/isdn/cfg-contr* 2> /dev/null ); do
   LINK_EDIT=~etc~sysconfig~isdn~$(basename $ISDN_CFG)
    echo "<h4>$ISDN_CFG</h4><pre>" >> $SIGA_OUT
    link_edit
    cat $ISDN_CFG >> $SIGA_OUT
    link_edit
    echo "<hr>" >> $SIGA_OUT
  done
  if [ "$ISDN_CFG" = "" ]; then
    echo "no isdn config found <br><br>" >> $SIGA_OUT
    echo "<a href=#top>top</a><BR><HR>" >> $SIGA_OUT
  fi
  echo " <li><a href=#isdn_cfg>$COL_COUNT.$TABLE_COUNT isdn_cfg</a></li>" >> $SIGA_HEAD
  echo "- isdn_cfg info done"
}

comm_isdn_cfg_net () {
  echo "<a name=isdn_cfg_net><H2>$COL_COUNT.$TABLE_COUNT isdn net config</H2>" >> $SIGA_OUT
  for ISDN_CFG_NET in $(ls /etc/sysconfig/isdn/cfg-net* 2> /dev/null ); do
   LINK_EDIT=~etc~sysconfig~isdn~$(basename $ISDN_CFG_NET)
    echo "<h4>$ISDN_CFG_NET</h4><pre>" >> $SIGA_OUT
    link_edit
    cat $ISDN_CFG_NET >> $SIGA_OUT
    link_edit
    echo "<hr>" >> $SIGA_OUT
  done
  if [ "$ISDN_CFG_NET" = "" ]; then
    echo "no isdn net config found <br><br>" >> $SIGA_OUT
    echo "<a href=#top>top</a><BR><HR>" >> $SIGA_OUT
  fi
  echo " <li><a href=#isdn_cfg_net>$COL_COUNT.$TABLE_COUNT isdn net config</a></li>" >> $SIGA_HEAD
  echo "- isdn net config info done"
}

dsl_speedtouch () {
speed_info="`/usr/sbin/hwinfo --usb`"
if [ "`/usr/sbin/hwinfo --usb | grep "Speed Touch USB"`" != "" ] ; then
  SIGA_M_NAME="speedtouch" SIGA_M_TYPE="null" SIGA_M_MERGE="yes" ; main ;
  echo -e "\n --- /bin/ps ax | grep speedmgmt --- " >> $SIGA_OUT
  /bin/ps ax | grep speedmgmt >> $SIGA_OUT 2>&1
  echo -e "\n --- ls -l /usr/sbin/speedmgmt --- " >> $SIGA_OUT
  ls -l /usr/sbin/speedmgmt >> $SIGA_OUT 2>&1
  echo -e "\n --- find /lib/modules/ -name speed\* --- " >> $SIGA_OUT
  find /lib/modules/ -name speed\* >> $SIGA_OUT 2>&1
  echo -e "\n --- ls -lR /etc/hotplug --- " >> $SIGA_OUT
  ls -lR /etc/hotplug >> $SIGA_OUT 2>&1
  echo -e "\n --- cat /etc/hotplug/usb/speedtouch --- " >> $SIGA_OUT
  cat /etc/hotplug/usb/speedtouch >> $SIGA_OUT 2>&1
  echo -e "\n --- grep -i speedtouch /etc/hotplug/usb.usermap --- " >> $SIGA_OUT
  grep -i speedtouch /etc/hotplug/usb.usermap >> $SIGA_OUT 2>&1
  link_top
fi
}

################################################################################
xf_top () {
  COL_COUNT=$(($COL_COUNT+1))
  TABLE_COUNT=0
  hw_head_gen XF86
  echo "<a name=XF86> <H2>7. XFree86</H2><hr>" >> $SIGA_OUT
}

xf_xf86_4 () { SIGA_M_NAME="xf86config4" SIGA_M_OUT="/etc/X11/xorg.conf" EDIT_FILE="yes" ; main ; }

xf_log () {
  echo "<a name=xfree86log><H2>$COL_COUNT.$TABLE_COUNT /var/log/XFree86.?.log</H2><hr><PRE>" >> $SIGA_OUT
  for n in 0 1; do
    if [ -f /var/log/XFree86.$n.log ]; then
      echo "/var/log/XFree86.$n.log<br>" >> $SIGA_OUT
      cat /var/log/XFree86.$n.log >> $SIGA_OUT
    else
      echo "no /var/log/XFree86.$n.log exists<br>" >> $SIGA_OUT
    fi
  done
  link_top
  echo "<li><a href=#xfree86log>$COL_COUNT.$TABLE_COUNT XFree86 log</a></li>" >> $SIGA_HEAD
  echo "- XFree86.log info done"
}

xf_sax_log () { SIGA_M_NAME="SaX.log" SIGA_M_OUT="/var/log/SaX.log" ; main ; }
xf_xdpyinfo () { SIGA_M_NAME="xdpyinfo" SIGA_M_OUT="/usr/X11R6/bin/xdpyinfo" SIGA_M_TYPE="com" ; main ; }



xf_xerr () {
  echo "<a name=hxerr><H2>$COL_COUNT.$TABLE_COUNT ~/.X.err</H2><hr><PRE>" >> $SIGA_OUT
  for n in $USERHOMEDIR /root; do
    if [ -f $n/.X.err ]; then
      echo "$n/.X.err <br>" >> $SIGA_OUT
      cat $n/.X.err >> $SIGA_OUT
    else
      echo "no $n/.X.err exists<br>" >> $SIGA_OUT
    fi
  done
  link_top
   echo "<li><a href=#hxerr>$COL_COUNT.$TABLE_COUNT .X.err</a></li>" >> $SIGA_HEAD
  echo "- $n/.X.err info done"
}

xf_xsession_errors () {
  echo "<a name=hxsessionerrors><H2>$COL_COUNT.$TABLE_COUNT ~/.xsession-errors</H2><hr><PRE>" >> $SIGA_OUT
  for n in $USERHOMEDIR /root; do
    if [ -r $n/.xsession-errors ]; then
      echo "$n/.xsession-errors <br>" >> $SIGA_OUT
      cat $n/.xsession-errors 2>/dev/null >> $SIGA_OUT
    else
      echo "$n/.xsession-errors does not exists or is unreadable.<br>" >> $SIGA_OUT
    fi
  done
  link_top
  echo "<li><a href=#hxsessionerrors>$COL_COUNT.$TABLE_COUNT xsession</a></li>" >> $SIGA_HEAD
  echo "- $n/.xsession-errors info done"
}

xf_startlog () {
  echo "<a name=hstartlog><H2>$COL_COUNT.$TABLE_COUNT ~/StartLog</H2><PRE>" >> $SIGA_OUT
  for n in $USERHOMEDIR /root; do
    if [ -f $n/StartLog ]; then
      echo "$n/StartLog <br>" >> $SIGA_OUT
      cat $n/StartLog >> $SIGA_OUT
    else
      echo "no $n/StartLog exists<br>" >> $SIGA_OUT
    fi
  done
  echo "</PRE><a href=#top>top</a><br><br><hr>" >> $SIGA_OUT
  echo "<li><a href=#hstartlog>$COL_COUNT.$TABLE_COUNT StartLog</a></li>" >> $SIGA_HEAD
  echo "- $n/StartLog info done"
}

xf_serverlog () {
  echo "<a name=hserverlog><H2>$COL_COUNT.$TABLE_COUNT ~/ServerLog</H2><PRE>" >> $SIGA_OUT
  for n in $USERHOMEDIR /root; do
    if [ -f $n/ServerLog ]; then
      echo "$n/ServerLog <br>" >> $SIGA_OUT
      cat $n/ServerLog >> $SIGA_OUT
    else
      echo "no $n/ServerLog exists<br>" >> $SIGA_OUT
    fi
  done
  echo "</PRE><a href=#top>top</a><br><br><hr>" >> $SIGA_OUT
  echo "<li><a href=#hserverlog>$COL_COUNT.$TABLE_COUNT ServerLog</a></li>" >> $SIGA_HEAD
  echo "- $n/ServerLog info done"
}

xf_links () {
  echo "<a name=xf_links><H2>$COL_COUNT.$TABLE_COUNT XF Links</H2><PRE>" >> $SIGA_OUT
  echo -e "\n --- xinit --- \n " >> $SIGA_OUT
  ls -l  /usr/X11R6/bin/xinit >> $SIGA_OUT 2>&1
  echo -e "\n --- /dev/video --- \n " >> $SIGA_OUT
  ls -l /dev/video* >> $SIGA_OUT 2>&1
  echo -e "\n --- /dev/mouse --- \n " >> $SIGA_OUT
  ls -l /dev/mouse* >> $SIGA_OUT 2>&1
  link_top
  echo "<li><a href=#xf_links>$COL_COUNT.$TABLE_COUNT XF Links</a></li>" >> $SIGA_HEAD
  echo "- xf links done"
}

xf_sysp () {
SIGA_M_NAME="sysp" SIGA_M_OUT="/usr/sbin/sysp -s mouse" SIGA_M_TYPE="com" SIGA_M_MERGE="yes" ; main ;
SIGA_M_TOP="no" SIGA_M_NAME="sysp" SIGA_M_OUT="/usr/sbin/sysp -c" SIGA_M_TYPE="com" SIGA_M_MERGE="yes" ; main ;
SIGA_M_TOP="no" SIGA_M_NAME="sysp" SIGA_M_OUT="/usr/sbin/sysp -s keyboard" SIGA_M_TYPE="com" SIGA_M_MERGE="yes" ; main ; 
echo "<hr>" >> $SIGA_OUT 
}

xf_3ddiag () { SIGA_M_NAME="3Ddiag" SIGA_M_OUT="/usr/bin/3Ddiag" SIGA_M_TYPE="com" ; main ; }
xf_framebuffer () { SIGA_M_NAME="Framebuffer" SIGA_M_OUT="/usr/sbin/hwinfo --framebuffer" SIGA_M_TYPE="com" ; main ; }

xf_libgl () {
  echo "<a name=libgl><H2>$COL_COUNT.$TABLE_COUNT /usr/lib/libGL*</H2><hr><PRE>" >> $SIGA_OUT
  ls -l /usr/lib/libGL* >> $SIGA_OUT
  link_top
  echo "<li><a href=#libgl>$COL_COUNT.$TABLE_COUNT libGL</a></li>" >> $SIGA_HEAD
  echo "- libGL info done"
}

################################################################################
gathering_end () {
  echo ""
  echo "- gathering done"
}

ascii_convert () {
  # convert html to ascii
    cat $TMP_DIR"siga.html" | sed s/"<a href=\/.*"//g | sed s,"<a href=#top>top</a>",, > $TMP_DIR.siga_text.html

    if [ -x /usr/bin/w3m ] ; then
      w3m -dump $TMP_DIR.siga_text.html > $SIGA_OUT_TXT
      ASCII_CONV="w3m"
    elif [ -x /usr/bin/lynx ] ; then
      lynx -dump -width 160 -nolist $TMP_DIR.siga_text.html > $SIGA_OUT_TXT
      ASCII_CONV="lynx"	
    else
    echo -e "\n *** w3m or lynx not found, no ascii convert! \n *** no $SIGA_OUT_TXT !"
    fi    
    rm $TMP_DIR.siga_text.html
    echo "- ascii convert with $ASCII_CONV done"
}

main () {

if [ "$SIGA_M_TOP" = "no" ] ; then
  echo "</pre><a href=#top>top</a><h2>$SIGA_M_NAME - $SIGA_M_OUT</h2><pre>"  >> $SIGA_OUT 
fi

# file or command?
case $SIGA_M_TYPE in

	null )  
		PRE_OUT=""
		;;
        
	com  )
		if [ -x "`echo $SIGA_M_OUT | cut -f1 -d " "`" ] ; then
		  PRE_OUT="`$SIGA_M_OUT 2>&1`" 
		  EDIT_FILE="no"
		else
	     	  PRE_OUT="command $SIGA_M_OUT not found"
		  EDIT_FILE="no"
		fi ;;
		
	# default is SIGA_M_TYPE="file"
	*)	
	    	if [ -r $SIGA_M_OUT ] ; then
             	  PRE_OUT="`cat $SIGA_M_OUT`"
	     	  LINK_EDIT=`echo "$SIGA_M_OUT" | sed s,/,~,g` 
	     	else
	     	  PRE_OUT="file $SIGA_M_OUT not found"
		  EDIT_FILE="no"
		fi ;;		
esac

# sed out comments on by default, replace <> with &lt & &gt
if [ "$GREP_COMMENTS" != "no" ] ; then
 PRE_OUT="`echo "$PRE_OUT" | grep -v ^# | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g' | grep -v ^$`"
fi

# sed out pw by default
if [ "$SED_PW" != "no" ] ; then
  PRE_OUT="`echo "$PRE_OUT" | sed s/"password"\.*\=\.*\/"### password data ### marked out ###"/i`"
fi

if [ "$SIGA_M_TOP" != "no" ] ; then
# write headline
echo "<a name=$SIGA_M_NAME><H2>$COL_COUNT.$TABLE_COUNT $SIGA_M_NAME - $SIGA_M_OUT</H2><br><pre>" >> $SIGA_OUT
else
echo "<pre>" >> $SIGA_OUT

fi

if [ "$EDIT_FILE" = "yes" ] ; then link_edit ; fi


if [ "$PRE_OUT" = "" ] && [ "$SIGA_M_TYPE" != "null" ] ; then
  echo " no output" >> $SIGA_OUT
else

  echo "$PRE_OUT" >> $SIGA_OUT 

fi

if [ "$EDIT_FILE" = "yes" ] ; then link_edit
  echo "<hr>" >> $SIGA_OUT 
else
  if [ "$SIGA_M_MERGE" != "yes" ] ; then
    link_top
  fi  
fi

# write entry into table
if [ "$SIGA_M_TOP" != "no" ] ; then
echo " <li><a href=#$SIGA_M_NAME>$COL_COUNT.$TABLE_COUNT $SIGA_M_NAME</a></li>" >> $SIGA_HEAD
fi
echo "- $SIGA_M_NAME info done"

#clearing all
SIGA_M_MERGE="";SIGA_M_TOP="";SIGA_M_NAME="";SIGA_M_OUT="";SIGA_M_TYPE="";EDIT_FILE="";GREP_COMMENTS="";SED_PW="";PRE_OUT=""

}


sysc_main () {
  LINK_EDIT=~etc~sysconfig~"$1"
  LINK_X=`echo "$1" | sed s,~,/,g`
  echo "<a name=$1><H2>$COL_COUNT.$TABLE_COUNT $LINK_X</H2><PRE>" >> $SIGA_OUT
  if [ -r /etc/sysconfig/$LINK_X ] ; then
    link_edit
    cat /etc/sysconfig/$LINK_X | grep -v ^# | sed 's/</\&lt;/g' | sed 's/>/\&gt;/g' | grep -v ^$ | sed s/"password"\.*\=\.*\/"### sensetive data ### marked out ###"/i >> $SIGA_OUT
    link_edit
  else
    echo -e "\n no /etc/sysconfig/$LINK_X found" >> $SIGA_OUT
  fi
    echo " <li><a href=#$1>$COL_COUNT.$TABLE_COUNT $LINK_X</a></li>" >> $SIGA_HEAD
    echo "<hr>" >> $SIGA_OUT
}

sysc1_top () {
  COL_COUNT=$(($COL_COUNT+1))
  TABLE_COUNT=0
  hw_head_gen Sysconfig1
  echo "<a name=sysconfig1> <H2>7. Sysconfig 1</H2><hr>" >> $SIGA_OUT
}

sysc_do () {
  COL_COUNT=$(($COL_COUNT+1))
  TABLE_COUNT=0
  hw_head_gen Sysconfig1
  echo "<a name=Sysconfig1> <H2>7. Sysconfig 1</H2><hr>" >> $SIGA_OUT
	for COUNT in $SYSC1_MAIN ; do
		TABLE_COUNT=$(($TABLE_COUNT+1))
          	sysc_main $COUNT
     	done
  COL_COUNT=$(($COL_COUNT+1))
  TABLE_COUNT=0
  hw_head_gen Sysconfig2
  echo "<a name=Sysconfig2> <H2>8. Sysconfig 2</H2><hr>" >> $SIGA_OUT
	for COUNT in $SYSC2_MAIN ; do
		TABLE_COUNT=$(($TABLE_COUNT+1))
          	sysc_main $COUNT
     	done
}

write_external () {
if [ "$CLI1" = "write" ] || [ "$CLI1" = "w" ]  ; then
	# writing on mounted windows partition or external storage if possible
	# check all directorys which are mounted in /media or /windows and are writeable
	MOUNT_LIST="`cat /proc/mounts | grep "rw" | grep ^\/dev | grep -e \/media -e \/windows`"
	#echo "$MOUNT_LIST" | \
	for MOUNT_DEVICE_POINT in "`echo "$MOUNT_LIST"`" ; do
	  WRITE_DIR="`echo "$MOUNT_DEVICE_POINT" | awk '{print $2}'`"
	  WRITE_ALL=""$WRITE_ALL" "$WRITE_DIR"" 
	done

	WORDS="`echo $WRITE_ALL | wc -w`"

	select_directory () {
		echo -e "\n please chose a dir to write siga files: - Bitte Verzeichnis auswählen"
		echo -e " files will be stored in directory siga - Dateien werden im Verzeichnis siga gespeichert\n"

		select WRITE_DIR in $WRITE_ALL ; do
	  	  if [ "$WRITE_DIR" = "" ] ; then
		    echo -e "\n wrong selection / falsche auswahl \n"
		    select_directory
		  else
		    break 
		  fi
		done
	}

	select_directory

	write_files_external () {
  		if [ -e "$WRITE_DIR""/siga/siga_"$DATE".html" ] || [ -e "$WRITE_DIR""/siga/siga_"$DATE".txt" ] ; then
		  echo -e " file already there, remove it first / datei vorhanden, bitte löschen"
		  exit
	  	else
 		  echo ""
    		  cp /tmp/siga/siga.html "$WRITE_DIR""/siga/siga_"$DATE".html" 
    		  cp /tmp/siga/siga.txt "$WRITE_DIR""/siga/siga_"$DATE".txt"
		  chmod -R 700 "$WRITE_DIR""/siga"
  		fi
	}

if [ "$WRITE_DIR" != "" ] ; then

	# test if a file or dir siga is already there
	if [ ! -d "$WRITE_DIR""/siga" ] ; then
	  # no dir or a file?
	  if [ -e "$WRITE_DIR""/siga" ] ; then
	    echo -e " file siga exists on "$WRITE_DIR", please remove it first "
	    echo -e " Datei siga existiert auf "$WRITE_DIR", bitte verschieben Sie diese zuerst."
	    exit
	  fi 
	  # no dir no file there
	  echo -e " making "$WRITE_DIR"/siga - Erzeuge "$WRITE_DIR"/siga"  
	  mkdir "$WRITE_DIR"/siga 
	  write_files_external 
	else
	  write_files_external
	fi
        fin
else
  echo -e " no external media found, copy the files manually \n"
  CLI1=""
  fin
fi


fi
}

floppy_write () {
 if [ "$CLI1" = "floppy" ] ; then
   if [ "$USERLANG" = "de" ] ; then
     echo -e " \n Bitte legen Sie eine Diskette in das erste Diskettenlaufwerk $FLOPPY_DEV ein.
 ACHTUNG! Die Disktette wird überschrieben, alle Daten werden gelöscht
 Bitte schreiben Sie YES um die Disketten zu formatieren"
   else
   echo -e "\n Please insert a floppydisk in the first floppydrive $FLOPPY_DEV
 WARNING! All data on floppydisk will be overwritten, all files will be deleted
 Please type YES to format the floppydisk "

fi

read FLOPPY
if [ "$FLOPPY" = "YES" ] ; then
  echo -e "\n please wait / bitte warten \n"
  mkfs.msdos /dev/fd0
  case $? in
       0) echo -e "\n copy data ...\n" ;;

       1) if [ "$USERLANG" = "de" ] ; then
            echo -e "\n Fehler !!!, bitte benutzen Sie eine andere Diskette \n und starten Sie siga erneut \n\n"
          else
            echo -e "\n Error !!!, please try another Disk \n and start siga again\n\n"
          fi
          exit 1 ;;
  esac
  mkdir $TMP_DIR$$.sigamount
  mount $FLOPPY_DEV $TMP_DIR$$.sigamount
  cp $SIGA_OUT $SIGA_OUT_TXT $TMP_DIR$$.sigamount
  umount $TMP_DIR$$.sigamount
  rm -r $TMP_DIR$$.sigamount
  fin

else

 echo -e "\n abort, you didn't typed YES - Abbruch, Sie haben nicht YES getippt"
 CLI1=""
fin
fi
fi

}

sup_case () {
  for SKIP_FILE in $(ls $TMP_DIR.siga_save_* 2> /dev/null) ; do
    	ALL_SKIP="$ALL_SKIP `cat $SKIP_FILE`"
  done
	for CONF in $INF ; do
		TABLE_COUNT=$(($TABLE_COUNT+1))
		if [ "`echo "$ALL_SKIP" | grep "$CONF"`" = "" ] ; then
                  SAVE_COUNT=$(($SAVE_COUNT+1))
                  echo "$CONF" > $TMP_DIR.siga_save_$SAVE_COUNT
          	  $CONF
	          rm $TMP_DIR.siga_save_$SAVE_COUNT
              	else
		  echo -e "<br> *** $CONF skipped *** <br><br><hr><br>" >> $SIGA_OUT
                  echo "$CONF" > $TMP_DIR.siga_save_$SAVE_COUNT
		fi
     	done
}

gather () {

html_head
sup_case
gathering_end
ascii_convert
floppy_write
write_external

echo "</TR></TABLE><br><br><hr>" >> $SIGA_HEAD

echo "- writing html head"
echo "<html><head><TITLE>SIGA - System Information gathering $VER</TITLE></HEAD><body>
        <a name=top>
	<H2>SIGA - System Information gathering $VER on $HOSTNAME "`date +%A" "%Y"-"%m"-"%d" "%T`"</H2>
        <hr><br><TABLE><TR><TD valign=top>" "`cat $SIGA_HEAD`" > $TMP_DIR.siga_head

cat $SIGA_OUT >> $TMP_DIR.siga_head

if [ "$CLI1" != "cat" ] ; then
 mv $TMP_DIR.siga_head $SIGA_OUT
fi

if [ "$CLI1" = "no" ] ; then
	echo -e "\n you chose no browser start"
	fin
fi

}

gather

if [ "$CLI1" = "no" ] ; then
  if [ "$USERLANG" = "de" ] ; then
    echo -e "\n *** Bitte schliessen Sie nicht dieses Fenster ***\n\n"
  else
    echo -e "\n *** please don't close this window ***\n\n"
  fi
fi

#cd $TMP_DIR

touch $TMP_DIR.siga_dummy
touch $TMP_DIR.sigawhile

export RUN=start

sleep 1

link_while () {
cd $TMP_DIR
  while [ -e $TMP_DIR.siga_dummy ]; do
    sleep 2
    if [ -e $TMP_DIR.siga_dummy ]; then
      DUMMY=`find .siga_edit_* -anewer $TMP_DIR.siga_dummy 2>/dev/null| sed s/.siga_edit_// | sed s/.html//`
fi
    echo $DUMMY > $TMP_DIR.sigawhile
    if [ "$DUMMY" != "" ] ; then
      pre_edit_file
    fi
  done
}

link_while &

while [ "`cat $TMP_DIR.sigawhile`" != "stop" ]; do
  if [ "$RUN" = "start" ] ; then
    BROWSER_RUN="`ps x|grep $BROWSER_PUR|grep $SIGA_OUT`"

    if [ "$BROWSER_PUR" = "lynx" ] || [ "$BROWSER_PUR" = "w3m" ] || [ "$BROWSER_PUR" = "konqueror" ]; then
      $BROWSER 2>/dev/null
    else
      if [ "$BROWSER_RUN" != "" ]; then
       BROWSER="netscape -remote openURL(file://$SIGA_OUT)"
      fi
    $BROWSER&
    fi
  fi

  DUMMY=`cat $TMP_DIR.sigawhile`
  while [ "$DUMMY" = "" ] ; do
    DUMMY="`cat $TMP_DIR.sigawhile`"
    BROWSER_RUN="`ps x|grep $BROWSER_PUR|grep $SIGA_OUT`"
    if [ "$BROWSER_RUN" = "" ] ; then
      fin
      exit
    fi
  done
  touch $TMP_DIR.siga_dummy

###############################################################################
# no edit on remote displays
# remove this ...
if  [ "`echo $CLI1 | cut -c1-3`" = "ip:" ] && [ "$REMOTE_EDIT" != "YES" ] ; then
  	post_edit_file
  	EDITOR="/bin/true"
fi

edit_case () {
	reset
	$EDITOR $1
	post_edit_file
}

edit_case `echo $DUMMY | sed s,~,/,g`

done
exit
