[bug-Fix] Gw6c-Client (Gateway6)

MrTweek1987

Neuer User
Mitglied seit
2 Mai 2011
Beiträge
116
Punkte für Reaktionen
0
Punkte
0
Bevor ich hier nen ticket eröffne kurze information zu "linux.sh" des Gw6-Clients unter freetz

Änderungen:

  • Der Parameter für entfernen von IFs / Adressen wurde angepasst
  • Das Script gibt nun bei startfehlern von "radvd" Konfigurationsparameter aus um eventuell den radvd-Daemon selber zu Konfigurieren)
  • Es wird nun überprüft ob die datei "radvd-conf" (von gw6c) existiert, bevor er gestartet wird -> Config-infos werden dann ausgegeben...
  • Gestript (Kommentare entfernt) sparte 1 KB! XD


Code:
!/bin/sh

LANGUAGE=C

if [ -z $TSP_VERBOSE ]; then
   TSP_VERBOSE=0
fi

KillProcess()
{
   if [ ! -z $TSP_VERBOSE ]; then
      if [ $TSP_VERBOSE -ge 2 ]; then
         echo killing $*
      fi
   fi
   PID=`ps axww | grep $1 | grep -v grep | awk '{ print $1;}'`
   echo $PID
   if [ ! -z $PID ]; then
      kill $PID
   fi
}

Display()
{
   if [ -z $TSP_VERBOSE ]; then
      return;
   fi
   if [ $TSP_VERBOSE -lt $1 ]; then
      return;
   fi
   shift
   echo "$*"
}

Exec()
{
   if [ ! -z $TSP_VERBOSE ]; then
      if [ $TSP_VERBOSE -ge 2 ]; then
         echo $*
      fi
   fi
   $* # Execute command
   if [ $? -ne 0 ]; then
      echo "Error while executing $1"
      echo "   Command: $*"
      exit 1
   fi
}

ExecNoCheck()
{
   if [ ! -z $TSP_VERBOSE ]; then
      if [ $TSP_VERBOSE -ge 2 ]; then
         echo $*
      fi
   fi
   $* # Execute command
}

# Program localization 

Display 1 "--- Start of configuration script. ---"
Display 1 "Script: " `basename $0`

ifconfig=/sbin/ifconfig
route=/sbin/route
ipconfig=/sbin/ip
rtadvd=/usr/sbin/radvd
rtadvd_pid=/var/run/radvd/radvd.pid
sysctl=/sbin/sysctl
rtadvdconfigfilename=gw6c-rtadvd.conf
rtadvdconfigfile=[COLOR="red"]/var/tmp/gw6c-rtadvd.conf[/COLOR]  #fixed can't create '/usr/share/gw6/gw6c-rtadvd.conf': Read-only file system 

if [ -z $TSP_HOME_DIR ]; then
   echo "TSP_HOME_DIR variable not specified!;"
   exit 1
fi

if [ ! -d $TSP_HOME_DIR ]; then
   echo "Error : directory $TSP_HOME_DIR does not exist"
   exit 1
fi
#

if [ -z $TSP_HOST_TYPE ]; then
   echo Error: TSP_HOST_TYPE not defined.
   exit 1
fi

if [ X"${TSP_OPERATION}" = X"TSP_TUNNEL_TEARDOWN" ]; then

  Display 1 Tunnel tear down starting...

  if [ X"${TSP_HOST_TYPE}" = X"router" ]; then

    KillProcess $rtadvdconfigfile
    ExecNoCheck $route -A inet6 del $TSP_PREFIX::/$TSP_PREFIXLEN

    if [ X"${TSP_PREFIXLEN}" != X"64" ]; then
      ExecNoCheck $route -A inet6 del $TSP_PREFIX::/$TSP_PREFIXLEN dev lo
    fi
    ExecNoCheck [COLOR="red"]$ifconfig $TSP_HOME_INTERFACE del $TSP_PREFIX::1/64[/COLOR]
  fi

  ExecNoCheck $route -A inet6 del ::/0     2>/dev/null  # delete default route
  ExecNoCheck $route -A inet6 del 2000::/3 2>/dev/null  # delete gw route

  if [ -x $ipconfig ]; then
    ExecNoCheck $ipconfig tunnel del $TSP_TUNNEL_INTERFACE
  else  
    $ifconfig $TSP_TUNNEL_INTERFACE >/dev/null 2>/dev/null
    if [ $? -eq 0 ]; then

      Delete interface IPv6 configuration.
      PREF=`echo $TSP_CLIENT_ADDRESS_IPV6 | sed "s/:0*/:/g" |cut -d : -f1-2`
      OLDADDR=`$ifconfig $TSP_TUNNEL_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
      if [ ! -z $OLDADDR ]; then
        ExecNoCheck $ifconfig $TSP_TUNNEL_INTERFACE del $OLDADDR
      fi
      ExecNoCheck $ifconfig $TSP_TUNNEL_INTERFACE down
    fi
  fi

  Display 1 "Tunnel tear down completed."

  exit 0
fi

if [ X"${TSP_HOST_TYPE}" = X"host" ] || [ X"${TSP_HOST_TYPE}" = X"router" ]; then

   Display 1 "$TSP_TUNNEL_INTERFACE setup"
   if [ X"${TSP_TUNNEL_MODE}" = X"v6v4" ]; then
      Display 1 "Setting up link to $TSP_SERVER_ADDRESS_IPV4"
      if [ -x $ipconfig ]; then
	 ExecNoCheck $ipconfig tunnel del $TSP_TUNNEL_INTERFACE
	 ExecNoCheck sleep 1
         Exec $ipconfig tunnel add $TSP_TUNNEL_INTERFACE mode sit ttl 64 remote $TSP_SERVER_ADDRESS_IPV4
      else
         Exec $ifconfig $TSP_TUNNEL_INTERFACE tunnel ::$TSP_SERVER_ADDRESS_IPV4
      fi
   fi

   Exec $ifconfig $TSP_TUNNEL_INTERFACE up
   PREF=`echo $TSP_CLIENT_ADDRESS_IPV6 | sed "s/:0*/:/g" |cut -d : -f1-2`
   OLDADDR=`$ifconfig $TSP_TUNNEL_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
   if [ ! -z $OLDADDR ]; then
      Display 1 "Removing old IPv6 address $OLDADDR"
      Exec [COLOR="red"]$ifconfig $TSP_TUNNEL_INTERFACE del $OLDADDR[/COLOR]
   fi

   Display 1 "This host is: $TSP_CLIENT_ADDRESS_IPV6/$TSP_TUNNEL_PREFIXLEN"
   Exec $ifconfig $TSP_TUNNEL_INTERFACE add $TSP_CLIENT_ADDRESS_IPV6/$TSP_TUNNEL_PREFIXLEN
   Exec $ifconfig $TSP_TUNNEL_INTERFACE mtu 1280

   Display 1 "Adding default route"
   ExecNoCheck $route -A inet6 del ::/0 2>/dev/null # delete old default route
   ExecNoCheck $route -A inet6 del 2000::/3 2>/dev/null  # delete old gw route
   Exec $route -A inet6 add ::/0 dev $TSP_TUNNEL_INTERFACE
   Exec $route -A inet6 add 2000::/3 dev $TSP_TUNNEL_INTERFACE
fi

if [ X"${TSP_HOST_TYPE}" = X"router" ]; then

   Display 1 "Router configuration"
   Exec $sysctl -w net.ipv6.conf.all.forwarding=1

   if [ X"${TSP_PREFIXLEN}" != X"64" ]; then
     ExecNoCheck $route -A inet6 add $TSP_PREFIX::/$TSP_PREFIXLEN dev lo 2>/dev/null
   fi
   OLDADDR=`$ifconfig $TSP_HOME_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
   if [ ! -z $OLDADDR ]; then
      Display 1 "Removing old IPv6 address $OLDADDR"
      Exec [COLOR="red"]$ifconfig $TSP_HOME_INTERFACE del $OLDADDR[/COLOR]
   fi
   Display 1 "Adding prefix to $TSP_HOME_INTERFACE"
   Exec [COLOR="red"]$ifconfig $TSP_HOME_INTERFACE add $TSP_PREFIX::1/64[/COLOR]

   /etc/init.d/radvd stop
   if [ -f $rtadvdconfigfile ]; then
     KillProcess $rtadvdconfigfile
   fi

   cat > $rtadvdconfigfile <<EOF
##### rtadvd.conf made by Gateway6 Client ####
interface $TSP_HOME_INTERFACE
{
  [COLOR="red"]AdvSendAdvert on;
  AdvManagedFlag on;
  AdvOtherConfigFlag on;
  AdvReachableTime 0;
  AdvRetransTimer 10;
  AdvCurHopLimit 64;
  AdvDefaultLifetime 1800;
  AdvHomeAgentFlag off;
  AdvDefaultPreference medium;
  AdvSourceLLAddress on;
  MaxRtrAdvInterval 600;
  MinRtrAdvInterval 198;
  MinDelayBetweenRAs 3;[/COLOR]
  
  prefix $TSP_PREFIX::/64
  {
    [COLOR="red"]AdvValidLifetime 86400;
    AdvPreferredLifetime 14400;
    AdvOnLink on;
    AdvAutonomous on;
    AdvRouterAddr off;[/COLOR]
  };
  
  RDNSS $TSP_CLIENT_ADDRESS_IPV6 #RDNSS (DNS-Server)
  {
	[COLOR="red"]AdvRDNSSLifetime 1200;[/COLOR]
  };
};
EOF

  [COLOR="red"] if [ -f $rtadvdconfigfile ]; then
   Display 1 "Starting radvd: $rtadvd -u radvd -C /var/tmp/gw6c-rtadvd.conf"
   Exec $rtadvd -u radvd -p $rtadvd_pid -C $rtadvdconfigfile
   else
   Display 1 "radvd(gw6c)-config: $rtadvdconfigfile ist nicht vorhanden! (Client läuft jedoch...)"
   Display 1 "radvd-Infos: (Interface: $TSP_HOME_INTERFACE) - (Prefix: $TSP_PREFIX::1/64) - (gw6c-Client-Adresse: $TSP_CLIENT_ADDRESS_IPV6/$TSP_TUNNEL_PREFIXLEN)" 
   echo "Error : File: $rtadvdconfigfile does not exist!"
   echo "radvd-Infos: (Interface: $TSP_HOME_INTERFACE) - (Prefix: $TSP_PREFIX::1/64) - (gw6c-Client-Adresse: $TSP_CLIENT_ADDRESS_IPV6/$TSP_TUNNEL_PREFIXLEN)"
   fi[/COLOR]
fi

Display 1 "--- End of configuration script. ---"

exit 0
 

sf3978

IPPF-Promi
Mitglied seit
2 Dez 2007
Beiträge
7,751
Punkte für Reaktionen
10
Punkte
38
Wieso "bug-Fix"? Die Datei befindet sich doch im Verzeichnis "template".
 

MrTweek1987

Neuer User
Mitglied seit
2 Mai 2011
Beiträge
116
Punkte für Reaktionen
0
Punkte
0
die radvd.conf vom gw6c? nee die erstellt er beim starten...

rtadvdconfigfile=/var/tmp/gw6c-rtadvd.conf #fixed can't create '/usr/share/gw6/gw6c-rtadvd.conf': Read-only file system

Code:
   cat > $rtadvdconfigfile <<EOF
##### rtadvd.conf made by Gateway6 Client ####
interface $TSP_HOME_INTERFACE
{
  AdvSendAdvert on;
  AdvManagedFlag on;
  AdvOtherConfigFlag on;
  AdvReachableTime 0;
  AdvRetransTimer 10;
  AdvCurHopLimit 64;
  AdvDefaultLifetime 1800;
  AdvHomeAgentFlag off;
  AdvDefaultPreference medium;
  AdvSourceLLAddress on;
  MaxRtrAdvInterval 600;
  MinRtrAdvInterval 198;
  MinDelayBetweenRAs 3;
  
  prefix $TSP_PREFIX::/64
  {
    AdvValidLifetime 86400;
    AdvPreferredLifetime 14400;
    AdvOnLink on;
    AdvAutonomous on;
    AdvRouterAddr off;
  };
  
  RDNSS $TSP_CLIENT_ADDRESS_IPV6 #RDNSS (DNS-Server)
  {
	AdvRDNSSLifetime 1200;
  };
};
EOF
 
Zuletzt bearbeitet:

sf3978

IPPF-Promi
Mitglied seit
2 Dez 2007
Beiträge
7,751
Punkte für Reaktionen
10
Punkte
38

Mister XY

Neuer User
Mitglied seit
26 Feb 2012
Beiträge
6
Punkte für Reaktionen
0
Punkte
0
Das steht bei mir in der gw6c.log beim ausführen des scriptes 2012/03/09 18:11:40 I gw6c: Executing configuration script: /bin/sh "/usr/share/gw6/template/linux.sh".
2012/03/09 18:11:40 I gw6c: Executing configuration script: /bin/sh "/usr/share/gw6/template/linux.sh".
2012/03/09 18:11:40 E gw6c: Failed to execute template script correctly.
2012/03/09 18:11:40 E gw6c: Interface setup (running the template linux) failed. Quitting.
2012/03/09 18:11:40 E gw6c: Last error is 4: INTERFACE_SETUP_FAILED.
2012/03/09 18:11:40 I gw6c: Done.
 

Zurzeit aktive Besucher

3CX PBX - GRATIS
Linux / Win / Cloud

Statistik des Forums

Themen
232,831
Beiträge
2,027,214
Mitglieder
350,920
Neuestes Mitglied
askmeforit79