mirror of https://github.com/tLDP/LDP
new
This commit is contained in:
parent
408f389ae2
commit
abeb0cdc67
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
# echo-params.sh
|
||||
|
||||
# Call this script with a few command line parameters.
|
||||
# For example:
|
||||
# sh echo-params.sh first second third fourth fifth
|
||||
|
||||
params=$# # Number of command-line parameters.
|
||||
param=1 # Start at first command-line param.
|
||||
|
||||
while [ "$param" -le "$params" ]
|
||||
do
|
||||
echo -n "Command line parameter "
|
||||
echo -n \$$param # Gives only the *name* of variable.
|
||||
# ^^^ # $1, $2, $3, etc.
|
||||
# Why?
|
||||
# \$ escapes the first "$"
|
||||
#+ so it echoes literally,
|
||||
#+ and $param dereferences "$param" . . .
|
||||
#+ . . . as expected.
|
||||
echo -n " = "
|
||||
eval echo \$$param # Gives the *value* of variable.
|
||||
# ^^^^ ^^^ # The "eval" forces the *evaluation*
|
||||
#+ of \$$
|
||||
#+ as an indirect variable reference.
|
||||
|
||||
(( param ++ )) # On to the next.
|
||||
done
|
||||
|
||||
exit $?
|
||||
|
||||
# =================================================
|
||||
|
||||
$ sh echo-params.sh first second third fourth fifth
|
||||
Command line parameter $1 = first
|
||||
Command line parameter $2 = second
|
||||
Command line parameter $3 = third
|
||||
Command line parameter $4 = fourth
|
||||
Command line parameter $5 = fifth
|
|
@ -0,0 +1,31 @@
|
|||
#!/bin/bash
|
||||
# Script by Juan Nicolas Ruiz
|
||||
# Used with his kind permission.
|
||||
|
||||
# Setting up (and stopping) a GRE tunnel.
|
||||
|
||||
|
||||
# --- start-tunnel.sh ---
|
||||
|
||||
LOCAL_IP="192.168.1.17"
|
||||
REMOTE_IP="10.0.5.33"
|
||||
OTHER_IFACE="192.168.0.100"
|
||||
REMOTE_NET="192.168.3.0/24"
|
||||
|
||||
/sbin/ip tunnel add netb mode gre remote $REMOTE_IP \
|
||||
local $LOCAL_IP ttl 255
|
||||
/sbin/ip addr add $OTHER_IFACE dev netb
|
||||
/sbin/ip link set netb up
|
||||
/sbin/ip route add $REMOTE_NET dev netb
|
||||
|
||||
exit 0 #############################################
|
||||
|
||||
# --- stop-tunnel.sh ---
|
||||
|
||||
REMOTE_NET="192.168.3.0/24"
|
||||
|
||||
/sbin/ip route del $REMOTE_NET dev netb
|
||||
/sbin/ip link set netb down
|
||||
/sbin/ip tunnel del netb
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue