projects
/
lab.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* FIX: use 'tr' to replace repeated SPACE with a single SPACE before 'cut' lines
[lab.git]
/
iproute
/
setroute.sh
diff --git
a/iproute/setroute.sh
b/iproute/setroute.sh
old mode 100644
(file)
new mode 100755
(executable)
index
2ff477e
..
59102fa
--- a/
iproute/setroute.sh
+++ b/
iproute/setroute.sh
@@
-15,7
+15,7
@@
set -x
# optional arugument to set default gateway manually
GATEWAY=$1
# optional arugument to set default gateway manually
GATEWAY=$1
-TID=`/sbin/ip addr show dev ${IFACE} | grep -w ${IFACE}: | cut -d : -f 1`
+TID=`/sbin/ip addr show dev ${IFACE} | grep -w ${IFACE}: | tr -s ' ' | cut -d : -f 1`
if [ "${PHASE}" = "post-down" ]; then
# delete routing table and policy and exit
if [ "${PHASE}" = "post-down" ]; then
# delete routing table and policy and exit
@@
-30,19
+30,19
@@
fi
# get IP address, network mask, default gateway info
# get IP address, network mask, default gateway info
-IPADDR=`/sbin/ip addr show dev ${IFACE} | grep -w inet | cut -d t -f 2 | cut -d ' ' -f 2 | cut -d / -f 1`
+IPADDR=`/sbin/ip addr show dev ${IFACE} | grep -w inet | tr -s ' ' | cut -d ' ' -f 3 | cut -d / -f 1`
if [ -z "${IPADDR}" ]; then
# fail to bind IP address to device
echo "${IFACE} has no IP address."
exit
fi
if [ -z "${IPADDR}" ]; then
# fail to bind IP address to device
echo "${IFACE} has no IP address."
exit
fi
-NETWORK=`/sbin/ip route show dev ${IFACE} | grep -w ${IPADDR} | cut -d ' ' -f 1`
+NETWORK=`/sbin/ip route show dev ${IFACE} | grep -w ${IPADDR} | tr -s ' ' | cut -d ' ' -f 1`
if [ -z "${GATEWAY}" ]; then
if [ -z "${GATEWAY}" ]; then
- GATEWAY=`/sbin/ip route show dev ${IFACE} | grep -w default | cut -d ' ' -f 3`
+ GATEWAY=`/sbin/ip route show dev ${IFACE} | grep -w default | tr -s ' ' | cut -d ' ' -f 3`
fi
if [ -z "${GATEWAY}" ]; then
fi
if [ -z "${GATEWAY}" ]; then
- GATEWAY=`/sbin/ip route | grep -w default | cut -d ' ' -f 3`
+ GATEWAY=`/sbin/ip route | grep -w default | tr -s ' ' | cut -d ' ' -f 3`
# this may add wrong default route especially on RHEL
fi
# this may add wrong default route especially on RHEL
fi