215 lines
6.8 KiB
Plaintext
215 lines
6.8 KiB
Plaintext
![]() |
#!/bin/bash
|
|||
|
#Framework, welches ein komplettes Linux System aus den Sourcen erstellt
|
|||
|
#dieses Framework wird im CVS Repository
|
|||
|
#:pserver:cvs.compuextreme.de:/Data/cvs zur Verf<72>gung gestellt
|
|||
|
#
|
|||
|
#Lage dieser Datei im Archiv: $Source$
|
|||
|
#
|
|||
|
#(c) 2003 Harald Kueller, Germany
|
|||
|
#This program is free software; you can redistribute it and/or
|
|||
|
#modify ist under the terms of the GNU General Public License
|
|||
|
#as published by the Free Software Foundation; either version
|
|||
|
#2 of the License, or (at your option) any later version.
|
|||
|
#
|
|||
|
#This program is distributed in the hope that it will be useful,
|
|||
|
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|||
|
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|||
|
#See the GNU General Public License for more details.
|
|||
|
#
|
|||
|
#You should have received a copy of the GNU General Public License
|
|||
|
#along with this program; if not write to the Free Software Foundation,
|
|||
|
#Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
#
|
|||
|
#Script:
|
|||
|
#Funkitonssammlung zur Unterstuetzung der /etc/init.d/* scripten
|
|||
|
#
|
|||
|
#Letzte <20>nderung von: $Author$
|
|||
|
#Datum der letzten <20>nderung: $Date$
|
|||
|
#Version der Datei: $Revision$
|
|||
|
#
|
|||
|
#$Log$
|
|||
|
#Revision 1.15 2007/02/23 00:48:05 segler
|
|||
|
#nameif vor die Konfiguration gesetzt.
|
|||
|
#es werden Konfigfiles /etc/mactab* der Reihe nach abgearbeitet.
|
|||
|
#Dies hat den Vorteil, dass man ggf. in /etc/mactab.1 eth1 nach eth2 wegmoven und
|
|||
|
#eth0 mit dem urspr<70>nglichen eth1 neu setzen kann um in /etc/mactab.2 eth2
|
|||
|
#nach eth1 moven.
|
|||
|
#Die Konfigfiles haben die Form:
|
|||
|
#eth0 XX:XX:XX:XX:XX:XX # ethernet
|
|||
|
#eth1 XX:XX:XX:XX:XX:XX # wireless
|
|||
|
#
|
|||
|
#Revision 1.14 2004/03/03 12:48:08 kueller
|
|||
|
#Header auf neuen Viitor GPL Header umgestellt
|
|||
|
#
|
|||
|
#
|
|||
|
#
|
|||
|
#Revision 1.9 2002/07/07 09:18:09 hkueller
|
|||
|
#Korrekturen in der Ablaufkontrolle (Routing Setup wird auf jedenfall durchlaufen - wichtig f<>r das Zusammenspiel mit dhcp usw.)
|
|||
|
#Funktionalit<69>t von /etc/sysconfig/net/notrouter mit implementiert
|
|||
|
#
|
|||
|
#Revision 1.8 2002/02/05 02:59:04 hkueller
|
|||
|
#functions: getbroadcast() hinzugefuegt - gibt broadcast eines Netzes
|
|||
|
# zurueck - Aufruf: getbroadcast <IP> <NETMASK>
|
|||
|
# getmask erweitert - keine mask in /etc/netmasks ->
|
|||
|
# defaultmask (Class A/B/C)
|
|||
|
#networks: Ueberfaelliger eintrag fuer PTP entfernt
|
|||
|
# Eintraege zur Konfiguration mit ifconfig hinzugefuegt - aber
|
|||
|
# auskommentiert.
|
|||
|
#
|
|||
|
#Revision 1.7 2002/01/27 13:58:43 hkueller
|
|||
|
#Debugging statement entfernt
|
|||
|
#auswertung der /etc/sysconfig/net/gateways neu erstellt.
|
|||
|
#Jetzt wird net/host/dev routing erm<72>glicht
|
|||
|
#
|
|||
|
#Revision 1.5 2001/11/17 23:41:36 kueller
|
|||
|
#Network Setup erweitert. Netmasks werden jetzt aus /etc/netmasks erkannt.
|
|||
|
#Konfiguration der Netmask in /etc/sysconfig/hostname.<if> nicht mehr
|
|||
|
#notwendig!
|
|||
|
#Korrekturen bei der netzmask erkennung unter zsh
|
|||
|
#
|
|||
|
#Revision 1.4 2001/11/03 18:49:26 segler
|
|||
|
#
|
|||
|
#Bugfix: Abfrage auf existierende hostname.* fuer mehrere Interfaces erweitert
|
|||
|
#
|
|||
|
#Revision 1.3 2001/09/28 22:33:16 kueller
|
|||
|
#Korrektur der abfrage auf existierende /etc/sysconfig/hostname.* dateien.
|
|||
|
#
|
|||
|
#Revision 1.2 2001/09/25 11:57:23 kueller
|
|||
|
#Fehlermeldung bei nicht forhandener /etc/sysconfig/net/hostname.* bereinigt
|
|||
|
#
|
|||
|
#Revision 1.1.1.1 2001/09/23 00:02:08 kueller
|
|||
|
#Neustart wg. Datenverlust
|
|||
|
#
|
|||
|
#Revision 1.1.1.1 2001/08/08 10:02:32 kueller
|
|||
|
#sysvinit addons
|
|||
|
#
|
|||
|
#
|
|||
|
|
|||
|
# Version: 0.01
|
|||
|
# Version: 0.02 M<>glichkeit der Einrichtung eines PTP Netzwerkes
|
|||
|
# Version: 0.03 RIP Unterst<73>tung wenn routed installiert ist
|
|||
|
# Version: 0.04 Umstellung auf iproute Verwendung. Damit Bugfix
|
|||
|
# der falsch gesetzten Broadcast adressen
|
|||
|
#
|
|||
|
|
|||
|
source /etc/init.d/functions
|
|||
|
|
|||
|
#DEBUG=echo
|
|||
|
|
|||
|
if ls /etc/sysconfig/net/hostname.* >/dev/null 2>&1; then
|
|||
|
DEVNUM=`ls /etc/sysconfig/net/hostname.* 2>/dev/null|wc -w`
|
|||
|
else
|
|||
|
DEVNUM=0
|
|||
|
fi
|
|||
|
|
|||
|
case "$1" in
|
|||
|
start)
|
|||
|
if ls /etc/mactab* >/dev/null 2>/dev/null ; then
|
|||
|
for maccfg in /etc/mactab*; do
|
|||
|
nameif -c $maccfg >/dev/null
|
|||
|
done
|
|||
|
fi
|
|||
|
|
|||
|
if [ "$DEVNUM" != 0 ]; then
|
|||
|
for i in `ls /etc/sysconfig/net/hostname.*|cut -d "." -f2`; do
|
|||
|
HOST=`cat /etc/sysconfig/net/hostname.$i|awk '{print $1}'`
|
|||
|
IP=`grep $HOST /etc/hosts|awk '{print $1}'`
|
|||
|
NETMASK=`getmask $IP`
|
|||
|
SHMASK=`GetShortMask $NETMASK`
|
|||
|
echo -n "setting up interface $i:IP=$IP NMASK=$NETMASK"
|
|||
|
if [ "$NETMASK" = "" ]; then
|
|||
|
DEV=`echo $i|cut -d ":" -f 1`
|
|||
|
$DEBUG ip addr add $IP broadcast + dev $DEV
|
|||
|
$DEBUG ip link set $DEV up
|
|||
|
else
|
|||
|
DEV=`echo $i|cut -d ":" -f 1`
|
|||
|
$DEBUG ip addr add $IP/$SHMASK broadcast + dev $DEV
|
|||
|
$DEBUG ip link set $DEV up
|
|||
|
fi
|
|||
|
evaluate_retval
|
|||
|
done
|
|||
|
fi
|
|||
|
if [ ! -f /etc/sysconfig/net/notrouter ]; then
|
|||
|
echo "Configuring System with routing allowed"
|
|||
|
if [ -f /etc/sysconfig/net/gateways ]; then
|
|||
|
sed -e "/^#/d" /etc/sysconfig/net/gateways | \
|
|||
|
sed -e "/^ *$/d" >/tmp/gateways
|
|||
|
exec 3</tmp/gateways
|
|||
|
read <&3 TYPE NETWORK OPTION GW NETMASK
|
|||
|
while [ $TYPE ]; do
|
|||
|
if [ "$OPTION" == "dev" ]; then
|
|||
|
echo -n "Adding device Route to $NETWORK with $NETMASK on $GW"
|
|||
|
route add -$TYPE $NETWORK netmask $NETMASK dev $GW
|
|||
|
evaluate_retval
|
|||
|
fi
|
|||
|
if [ "$OPTION" == "gw" ]; then
|
|||
|
echo -n "Adding net Route to $NETWORK with $NETMASK and gw $GW"
|
|||
|
route add -$TYPE $NETWORK netmask $NETMASK gw $GW
|
|||
|
evaluate_retval
|
|||
|
fi
|
|||
|
read <&3 TYPE NETWORK OPTION GW NETMASK
|
|||
|
done
|
|||
|
exec 3>&-
|
|||
|
rm /tmp/gateways
|
|||
|
fi
|
|||
|
if [ -f /etc/sysconfig/net/defaultrouter ]; then
|
|||
|
echo -n "setting up defaultrouter `cat /etc/sysconfig/net/defaultrouter`"
|
|||
|
$DEBUG route add default gw `cat /etc/sysconfig/net/defaultrouter`
|
|||
|
evaluate_retval
|
|||
|
fi
|
|||
|
NUMIF=`ip -f inet addr show|grep inet|wc -l`
|
|||
|
if [ $NUMIF -gt 2 ]; then
|
|||
|
echo -n "Enable ip_forwarding"
|
|||
|
echo "1" >/proc/sys/net/ipv4/ip_forward
|
|||
|
evaluate_retval
|
|||
|
fi
|
|||
|
if [ -f /usr/sbin/routed ]; then
|
|||
|
if [ $NUMIF -gt 2 ]; then
|
|||
|
echo -n "Starte Routing Information Protokoll Server"
|
|||
|
$DEBUG /usr/sbin/routed -s -g &
|
|||
|
evaluate_retval
|
|||
|
else
|
|||
|
echo -n "Starte Routing Information Protokoll Client"
|
|||
|
$DEBUG /usr/sbin/routed -q &
|
|||
|
evaluate_retval
|
|||
|
fi
|
|||
|
fi
|
|||
|
else
|
|||
|
if [ -f /usr/sbin/routed ]; then
|
|||
|
echo -n "Starte RIP Client im silent mode"
|
|||
|
$DEBUG /usr/sbin/routed -q &
|
|||
|
evaluate_retval
|
|||
|
fi
|
|||
|
fi
|
|||
|
;;
|
|||
|
stop)
|
|||
|
NUMIF=`ip -f inet addr show|grep inet|wc -l`
|
|||
|
if [ -f /usr/sbin/routed ]; then
|
|||
|
echo -n "Stopping Routing Information Protokoll"
|
|||
|
killproc routed
|
|||
|
fi
|
|||
|
if [ $DEVNUM != 0 ]; then
|
|||
|
for i in `ls /etc/sysconfig/net/hostname.*|cut -d "." -f2`; do
|
|||
|
echo -n "shutting down interface $i"
|
|||
|
#ifconfig $i down
|
|||
|
HOST=`cat /etc/sysconfig/net/hostname.$i|awk '{print $1}'`
|
|||
|
IP=`grep $HOST /etc/hosts|awk '{print $1}'`
|
|||
|
echo -n " Address $IP"
|
|||
|
DEV=`echo $i|cut -d ":" -f 1`
|
|||
|
ip addr del $IP dev $DEV
|
|||
|
evaluate_retval
|
|||
|
done
|
|||
|
fi
|
|||
|
;;
|
|||
|
restart)
|
|||
|
$0 stop
|
|||
|
sleep 1
|
|||
|
$0 start
|
|||
|
;;
|
|||
|
*)
|
|||
|
echo "Usage: $0: {start|stop|restart}"
|
|||
|
exit 1
|
|||
|
;;
|
|||
|
esac
|
|||
|
#end /etc/inet.d/network
|