#!/bin/sh ############################################################################### # # # S10bridge_tuntap R01-01.00 # # # # =========================================================================== # # # # Purpose: # # # # This script is used to start and stop the network bridge devices. # # # # =========================================================================== # # # # Arguments: # # # # No arguments to the script # # # # =========================================================================== # # # # Programming Notes: # # # # This script will invoke the rc.bridge_tuntap script with the start option # # that is located in the rc.d directory. # # # # This script was designed to be able to run with ash if needed. # # # # =========================================================================== # # # # Revision: # # # # Revision Who When Why # # ========= =========== =========== ====================================== # # R00-00.00 DRLJr/I-AS 28/Apr/2014 Script created # # R01-00.00 DRLJr/I-AS 02/May/2014 Find existing network route info. # # R01-01.00 DRLJr/I-AS 22/mar/2016 Add boot mode to turn bridge off. # # # ############################################################################### #=============================================================================# # # #=============================================================================# get_field() { OFF=$1 if [ ${OFF} -le $# ] ; then shift ${OFF} ANS="$1" else ANS="" fi echo "${ANS}" return 0 } #=============================================================================# # Set the primary script to run if appropriate # #=============================================================================# RC_CMD="/etc/rc.d/rc.bridge_tuntap" #=============================================================================# # Get the name used to invoke the script. This will get the name of the link # # if a link was called to invoke the script. # #=============================================================================# CALLEDAS="`basename $0`" CODES="${CALLEDAS##S}" CODEK="${CALLEDAS##K}" #echo " " #echo "Invoked = $0 $*" #echo "Arg0 = $0" #echo "CALLEDAS = ${CALLEDAS}" #echo "CODES = ${CODES}" #echo "CODEK = ${CODEK}" #echo " " #=============================================================================# # Determine if the command is a start or stop command. If not called as # # Snnmmmm or Knnmmm then select "unknown", otherwise select "start" for the # # "S" command or "stop" for the "K" command. # #=============================================================================# if [ "$1" = "" ] ; then if [ "S${CODES}" = "${CALLEDAS}" ] ; then RC_OPT="start" elif [ "K${CODEK}" = "${CALLEDAS}" ] ; then RC_OPT="stop" else RC_OPT="unknown" fi else RC_OPT="$1" fi #=============================================================================# # Check if the file exists and execute it if it is executable # #=============================================================================# if [ "${NETBRIDGE}" != "OFF" ] ; then # Do this if [ -f ${RC_CMD} ] ; then # Exists - yes if [ -x ${RC_CMD} ] ; then # Executable if [ "${RC_OPT}" = "start" ] ; then # Start Request? /sbin/modprobe tun # Activate tun. fi # DRINFO=`/bin/netstat -r -n | /bin/grep "^0.0.0.0"` # Default Route DRADDR=`get_field 2 ${DRINFO}` # Get IP Address DRDEVC=`get_field 8 ${DRINFO}` # Get Device ${RC_CMD} ${RC_OPT} # Run Command NETDEV="`/sbin/ifconfig`" # Get Net info NETDEV="`echo ${NETDEV} | /bin/cut -d':' -f1`" # Get Device /sbin/route add -net default gw ${DRADDR} ${NETDEV} # Setup Route fi # else # echo "Warning: ${RC_CMD} does not exist." # fi # fi # ############################################################################### # # ###############################################################################