home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #
- ####################################################
- # #
- # File: netsetup #
- # Authors: Niels Mache, Ngo Than #
- # Last change: 07/05/1997 #
- # #
- # DLD - German Linux Distribution - #
- # #
- # Copyright (c) 1993-1997 delix Computer GmbH #
- # Schlo▀stra▀e 98 #
- # D-70176 Stuttgart #
- # All rights reserved. #
- # #
- ####################################################
-
- PATH=/sbin:/bin:/usr/bin
- RootPath="/dest"
- IPath=$RootPath
- clear="H"
- [ -z "$DLDVersion" ] && DLDVersion="5.2"
- [ -z "$DIALOGTITLE" ] && DIALOGTITLE=" DLD $DLDVersion (C) 1993-1997 by delix GmbH, Schlo▀str. 98, 70176 Stuttgart, Germany"
- title="Netzwerk Konfiguration"
-
- if [ "$TERM" = "xterm" ]; then
- export TERM=color_xterm
- fi
-
- mydialog() {
- dialog --backtitle "$DIALOGTITLE" "$@"
- }
-
-
- cleanup() {
- rm -f /tmp/ret /tmp/ret.set /tmp/err.set
- }
-
- error() {
- mydialog --title "Fehler:" --msgbox "$@" 10 73
- }
-
- errorCheck() {
- if [ -s /tmp/err.set ]; then
- error "`cat /tmp/err.set`"
- fi
- rm -f /tmp/err.set
- }
-
- # Main
-
- unset IPADDR NETWORK NETMASK BROADCAST GATEWAY HOSTNAME DOMAINNAME NAMESERVER
-
- [ -f /tmp/NETINST ] && source /tmp/NETINST
-
- while [ 1 ] ; do
-
- mydialog --title "$title" --inputbox \
- "\nBitte geben Sie den Hostname dieses Rechners ein:\n" \
- 11 55 "$HOSTNAME" 2> /tmp/ret.set
-
- [ "$?" != "0" ] && exit 1
- hostn=`cat /tmp/ret.set`
-
- DOMAINNAME=`echo $hostn | sed "s/[aA0-zZ9]*.//"`
- mydialog --title "$title" --inputbox \
- "\nBitte geben Sie den Domainname dieses Rechners ein:\n" \
- 11 57 "$DOMAINNAME" 2> /tmp/ret.set
-
- [ "$?" != "0" ] && exit 1
- domain=`cat /tmp/ret.set`
-
- mydialog --title "$title" --inputbox \
- "\nGeben Sie die IP Adresse dieses Rechners ein:\n" \
- 11 52 "$IPADDR" 2> /tmp/ret.set
-
- [ "$?" != "0" ] && exit 1
- ipaddr=`cat /tmp/ret.set`
-
- if [ ! -f /tmp/NETINST ]; then
- NETMASK="255.255.255.0"
- NETWORK=`echo $ipaddr | sed "/[0-9]*$/s//0/"`
- BROADCAST=`echo $ipaddr | sed "/[0-9]*$/s//255/"`
- GATEWAY=`echo $ipaddr | sed "/[0-9]*$/s//1/"`
- fi
-
- mydialog --title "$title" --inputbox \
- "\nGeben Sie die Netzwerkadresse dieses Rechners ein:\n" \
- 11 56 "$NETWORK" 2> /tmp/ret.set
-
- [ "$?" != "0" ] && exit 1
- network=`cat /tmp/ret.set`
-
- mydialog --title "$title" --inputbox \
- "\nGeben Sie die Netzmaskierung dieses Rechners ein:\n" \
- 11 55 "$NETMASK" 2> /tmp/ret.set
-
- [ "$?" != "0" ] && exit 1
- netmask=`cat /tmp/ret.set`
-
- mydialog --title "$title" --inputbox \
- "\nGeben Sie die Broadcastadresse dieses Rechners ein:\n" \
- 11 58 "$BROADCAST" 2> /tmp/ret.set
-
- [ "$?" != "0" ] && exit 1
- broadcast=`cat /tmp/ret.set`
-
- mydialog --title "$title" --inputbox \
- "\nGeben Sie die IP Adresse Ihres Gateways ein:\n" \
- 11 51 "$GATEWAY" 2> /tmp/ret.set
-
- [ "$?" != "0" ] && exit 1
- gateway=`cat /tmp/ret.set`
-
- if [ "$gateway" = "" ] ; then
- gateway=
- elif [ "$gateway" = "$ipaddr" ] ; then
- gateway=
- fi
-
- mydialog --title "$title" --inputbox \
- "\nBitte geben Sie die IP-Adresse des Nameservers ein:\n" \
- 11 58 "$NAMESERVER" 2> /tmp/ret.set
-
- [ "$?" != "0" ] && exit 1
- nameserver=`cat /tmp/ret.set`
-
- mydialog --title "Einstellungen" --yesno \
- "\n Sind Sie zufrieden mit diesen Einstellungen?\n\n\
- Hostname : $hostn\n\
- Domainname : $domain\n\
- Adresse : $ipaddr\n\
- Netzwerk : $network\n\
- Netzmaske : $netmask\n\
- Broadcast : $broadcast\n\
- Gateway : $gateway\n\
- Nameserver : $nameserver" 16 60
-
- Status="$?"
- HOSTNAME="$hostn"
- DOMAINNAME="$domain"
- IPADDR="$ipaddr"
- NETWORK="$network"
- NETMASK="$netmask"
- BROADCAST="$broadcast"
- GATEWAY="$gateway"
- NAMESERVER="$nameserver"
-
- if [ "$Status" = "0" ]; then
- break
- else
- mydialog --title "Netzwerk Konfiguration" --yesno \
- "\n Wollen Sie Netzwerk Konfiguration wiederholen?\n" 7 60
-
- if [ "$?" != "0" ]; then
- exit 1
- fi
- fi
-
- done
-
- mydialog --title "Netzwerk Konfiguration" --infobox \
- "\n Die Konfiguration des Netzwerks kann u.U. 1-2 Minuten\n\
- dauern. Haben Sie bitte etwas Geduld.\n" 6 59
-
- # Attach the loopback device.
- ifconfig lo 127.0.0.1 2>/dev/null
- route add -net 127.0.0.0 2>/dev/null
-
- start=1
- for i in /proc/[1-9]*; do
- if [ "`cat $i/cmdline`" = "/sbin/portmap" ]; then
- start=0
- break
- fi
- done
-
- if [ $start = 1 ]; then
- /sbin/portmap 2>/dev/null
- fi
-
- start=1
- for i in /proc/[1-9]*; do
- if [ "`cat $i/cmdline`" = "/sbin/inetd" ]; then
- start=0
- break
- fi
- done
-
- if [ $start = 1 ]; then
- /sbin/inetd 2>/dev/null
- fi
-
- if [ -n "$broadcast" ]; then
- ifconfig eth0 $ipaddr netmask $netmask broadcast $broadcast 2> /tmp/err.set
- else
- ifconfig eth0 $ipaddr netmask $netmask 2> /tmp/err.set
- fi
-
- errorCheck
-
- route add -net $network netmask $netmask 2> /tmp/err.set
- errorCheck
-
- if [ "$gateway" != "" ]; then
- route add default gw $gateway metric 1 2> /tmp/err.set
- errorCheck
- fi
-
- echo "Einstellungen:" > /tmp/ret
- ifconfig >> /tmp/ret
- route >> /tmp/ret
-
- mydialog --title "$title" --textbox \
- /tmp/ret 20 73
-
-
- while [ 1 ]; do
- mydialog --title "Netzwerk Setup" --inputbox \
- "Geben Sie die IP Adresse des NFS-Servers ein :" 8 54 $NFSSERVER 2> /tmp/ret.doi
- if [ "$?" != "0" ]; then
- exit 1
- fi
- nfsserver=`cat /tmp/ret.doi`
- if [ "$nfsserver" != "" ]; then
- break
- fi
- done
-
- mydialog --title "Netzwerk Setup" --inputbox \
- "\nGeben Sie das Verzeichnis auf dem NFS-Server an,\n\
- in dem sich die DLD Distribution befindet:\n" 12 54 $NFSPATH 2> /tmp/ret.doi
-
- if [ "$?" != "0" ]; then
- exit 1
- fi
-
- nfspath=`cat /tmp/ret.doi`
-
- if [ "$nfspath" = "" ]; then
- nfspath="/cdrom/delix"
- fi
-
- cat << EOF > /tmp/NETINST
- HOSTNAME="$hostn"
- DOMAINNAME="$domain"
- IPADDR="$ipaddr"
- NETMASK="$netmask"
- NETWORK="$network"
- BROADCAST="$broadcast"
- GATEWAY="$gateway"
- NFSSERVER="$nfsserver"
- NFSPATH="$nfspath"
- NAMESERVER="$nameserver"
- EOF
-
- mkdir -p $IPath/etc/sysconfig
- cat << EOF > $IPath/etc/sysconfig/network
- NETWORKING=yes
- HOSTNAME="$hostn"
- DOMAINNAME="$domain"
- GATEWAY="$gateway"
- GATEWAYDEV=eth0
- NAMESERVER="$nameserver"
- EOF
-
- echo "127.0.0.1 localhost" > $IPath/etc/hosts
- echo "$ipaddr $hostn" >> $IPath/etc/hosts
- echo "$hostn" > $IPath/etc/HOSTNAME
- echo "search $domain" > $IPath/etc/resolv.conf
- echo "nameserver $nameserver" >> $IPath/etc/resolv.conf
-
- mkdir -p $IPath/etc/sysconfig/network-scripts
-
- cat << EOF > $IPath/etc/sysconfig/network-scripts/ifcfg-eth0
- DEVICE="eth0"
- IPADDR="$ipaddr"
- NETMASK="$netmask"
- NETWORK="$network"
- BROADCAST="$broadcast"
- ONBOOT=yes
- BOOTP=no
- EOF
-
- chmod a+x $IPath/etc/sysconfig/network-scripts/ifcfg-eth0
-
- cleanup
- echo $clear
- exit 0
-