Debian Codegraph @

scripts/bin/drbl-get-network

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # Author: Steven Shiau <steven _at_ clonezilla org>
3 # License: GPL
4 # Description: Get the network address from IP address and netmask
5 # Notes: "ipcalc" program is totally different in Debian and RedHat-like distribution.
6 # NOTE! We do NOT use this program in drblpush anymore. Just use the perl script ipcalc which is collected in package drbl.
7
8 # Load DRBL setting and functions
9 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
10
11 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
12
13 export LC_ALL=C
14 # Append a default search path.
15 PATH="$PATH:/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
16 export PATH
17
18 Usagescip-shell shell shell-project 0.0.0 Usage().() {
19 echoscip-shell system . . echo. "Get the network address from IP address and netmask"
20 echoscip-shell system . . echo. "Usage:"
21 echoscip-shell system . . echo. "$(basenamescip-shell system . . basename. $0) IPADDR NETMASK"
22 echoscip-shell system . . echo. "Ex: $(basenamescip-shell system . . basename. $0) 192.168.10.213 255.255.255.240"
23 }
24
25 # Parse command-line options
26 while [scip-shell system . . `[`. $# -gt 0 ]; do
27 case "$1" in
28 -*) echoscip-shell system . . echo. "${0}: ${1}: invalid option" >&2
29 Usagescip-shell shell shell-project 0.0.0 Usage(). >& 2
30 exit 2 ;;
31 *) break ;;
32 esac
33 done
34
35 ipaddr=$1
36 netmask=$2
37 [scip-shell system . . `[`. -z "$ipaddr" ] && exit 0
38 [scip-shell system . . `[`. -z "$netmask" ] && exit 0
39
40 # The output of ipcalc without "=", it must be in Debian... we use ipsc.
41 # Debian's ipcalc output like this
42 # Network: 192.168.103.208/28 11000000.10101000.01100111.1101 0000
43 network="$(drbl-ipcalc $ipaddr $netmask | awkscip-shell system . . awk. -F" " '/Network:/ {print $2}scip-shell filesystem . . `/Network:/ {print $2}`.' | sedscip-shell system . . sed. -e "s/\/.*//g")"
44 echoscip-shell system . . echo. $network