-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathaoe-interfaces.in
53 lines (48 loc) · 1.02 KB
/
aoe-interfaces.in
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! /bin/sh
# aoe-interfaces - set or list the allowed AoE network interfaces
# Copyright 2009, CORAID, Inc., and licensed under GPL v.2.
zero="`basename $0`"
devf=@devdir@/interfaces
sysf=/sys/module/aoe/parameters/aoe_iflist
if test -z "$*"; then
if test -r "$sysf"; then
cat "$sysf"
else
# can't read from interfaces device
false
fi
exit
fi
if test "$1" = "-c"; then
shift
if test "$#" != "0"; then
echo "$zero Error: -c flag takes no arguments" 1>&2
exit 1
fi
fi
netifs="$*"
err=no
for i in $netifs; do
test -d "/sys/class/net/$i" || {
echo "$zero Error: \"$i\" is not a network interface" 1>&2
err=yes
}
done
if test "$err" = "yes"; then
exit 1
fi
if test -w "$sysf"; then
printf '%s\0' "$netifs" > "$sysf"
else
if test ! -w "$devf"; then
echo 1>&2 "$zero: $devf does not exist or is not writeable."
exit 1
fi
if test ! -c "$devf"; then
exec 1>&2
echo "$zero: $devf is not a character device file"
echo "$zero: use udev or aoe-mkdevs to create it"
exit 1
fi
printf '%s\0' "$netifs" > "$devf"
fi