root / bin / get-conf-iscsi-volume @ 30
Historique | Voir | Annoter | Télécharger (2,68 ko)
1 |
#!/bin/bash |
---|---|
2 |
if [ "$1" == "" ] |
3 |
then |
4 |
echo "Syntax : $0 path_dev"1>&2 |
5 |
exit 1; |
6 |
fi |
7 |
TID_ISCSI=$(cat /proc/net/iet/volume |grep -B1 "$1$" |grep "tid" |awk '{split($0,array,"tid:")} END {print array[2]}'|cut -d " " -f1) |
8 |
if [ "$TID_ISCSI" == "" ] |
9 |
then |
10 |
echo "Device not found $TID_ISCSI" |
11 |
exit 0 |
12 |
fi |
13 |
COPY_LINE=1 |
14 |
TARGET=$(cat /proc/net/iet/session |grep tid:$TID_ISCSI |awk '{split($0,array,"name:")} END {print array[2]}') |
15 |
LUN=$(cat /proc/net/iet/volume |grep "tid:$TID_ISCSI" -A1 | awk '{split($0,array,"lun:")} END {print array[2]}'|cut -d " " -f1) |
16 |
TYPE=$(cat /proc/net/iet/volume |grep "tid:$TID_ISCSI" -A1 | awk '{split($0,array,"iotype:")} END {print array[2]}'|cut -d " " -f1) |
17 |
DEV_PATH=$(cat /proc/net/iet/volume |grep "tid:$TID_ISCSI" -A1 | awk '{split($0,array,"path:")} END {print array[2]}'|cut -d " " -f1) |
18 |
|
19 |
echo "tid $TID_ISCSI" |
20 |
echo "target $TARGET" |
21 |
echo "lun $LUN" |
22 |
echo "exportType $TYPE" |
23 |
echo "devPath $DEV_PATH" |
24 |
COPY_LINE=0 |
25 |
while read line |
26 |
do |
27 |
SEARCH_TARGET=$(echo $line |grep -i "^Target") |
28 |
if [ "$SEARCH_TARGET" != "" ] |
29 |
then |
30 |
COPY_LINE=0 |
31 |
fi |
32 |
SEARCH_MYTARGET=$(echo $line |grep -i "^Target $TARGET") |
33 |
if [ "$SEARCH_MYTARGET" != "" ] |
34 |
then |
35 |
COPY_LINE=1 |
36 |
fi |
37 |
if [ $COPY_LINE -eq 1 ] |
38 |
then |
39 |
SEARCH_USER=$(echo $line |grep -i "^IncomingUser") |
40 |
if [ "$SEARCH_USER" != "" ] |
41 |
then |
42 |
USERCHAP=$(echo $SEARCH_USER|cut -d " " -f2) |
43 |
PASSCHAP=$(echo $SEARCH_USER|cut -d " " -f3) |
44 |
if [ "$USERCHAP" != "IncomingUser" ] |
45 |
then |
46 |
echo "login $USERCHAP" |
47 |
echo "passwd $PASSCHAP" |
48 |
fi |
49 |
fi |
50 |
fi |
51 |
|
52 |
done < "/etc/iet/ietd.conf" |
53 |
|
54 |
|
55 |
COPY_LINE=0 |
56 |
while read line |
57 |
do |
58 |
SEARCH_TID=$(echo $line |grep -i "^tid") |
59 |
if [ "$SEARCH_TID" != "" ] |
60 |
then |
61 |
COPY_LINE=0 |
62 |
fi |
63 |
SEARCH_MYTID=$(echo $line |grep -i "^tid:$TID_ISCSI ") |
64 |
if [ "$SEARCH_MYTID" != "" ] |
65 |
then |
66 |
COPY_LINE=1 |
67 |
fi |
68 |
if [ $COPY_LINE -eq 1 ] |
69 |
then |
70 |
SEARCH_SID=$(echo $line |grep -i "sid:"| awk '{split($0,array,"sid:")} END {print array[2]}'|cut -d " " -f1) |
71 |
if [ "$SEARCH_SID" != "" ] |
72 |
then |
73 |
SESSION_IP=$(cat /proc/net/iet/session |grep "sid:$SEARCH_SID" -A1 | awk '{split($0,array,"ip:")} END {print array[2]}'|cut -d " " -f1) |
74 |
if [ "$SESSION_IP" != "" ] |
75 |
then |
76 |
echo "sid $SEARCH_SID" |
77 |
echo "sessionIP $SESSION_IP" |
78 |
fi |
79 |
fi |
80 |
fi |
81 |
|
82 |
done < "/proc/net/iet/session" |
83 |
|
84 |
allowIP="" |
85 |
while read line |
86 |
do |
87 |
SEARCH_MYTARGET=$(echo $line |grep -i "$TARGET") |
88 |
if [ "$SEARCH_MYTARGET" != "" ] |
89 |
then |
90 |
if [ "$allowIP" == "" ] |
91 |
then |
92 |
allowIP=$(echo $SEARCH_MYTARGET |cut -d " " -f2) |
93 |
else |
94 |
allowIP=$allowIP";"$(echo $SEARCH_MYTARGET |cut -d " " -f2) |
95 |
fi |
96 |
fi |
97 |
done < "/etc/iet/initiators.allow" |
98 |
echo "allowIP $allowIP" |