File: drbl-get-netmask

package info (click to toggle)
drbl 5.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,996 kB
  • sloc: sh: 43,555; perl: 8,820; xml: 867; makefile: 135
file content (27 lines) | stat: -rwxr-xr-x 720 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
# Authors: Steven Shiau <steven _at_ clonezilla org>, Ceasar Sun <ceasar _at_ nchc org tw>
# License: GPL
# Description: Get the netmask of network card interface

# Load DRBL setting and functions
DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"

. $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions


ethx=$1
export LC_ALL=C

Usage() {
  echo "Get the netmask of network card interface" 
  echo "Usage:"
  echo "$(basename $0) INTERFACE"
  echo "Ex: $(basename $0) eth0"
}

[ -z "$ethx" ] && Usage && exit 1
if ! ifconfig -a 2>/dev/null | grep -i -q "\<$ethx\>"; then
   exit 1
fi
LC_ALL=C ifconfig $ethx | grep -oE "(Mask:.*|netmask .+)" | sed -e 's/^Mask://g' -e 's/netmask //g' | awk '{print $1}'
exit 0