forked from hreinecke/tcm-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_fc.sh
More file actions
51 lines (46 loc) · 982 Bytes
/
Copy pathremove_fc.sh
File metadata and controls
51 lines (46 loc) · 982 Bytes
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
#!/bin/bash
##check if the user has root access
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
fc=/sys/kernel/config/target/fc
for wwpn in ${fc}/??:??:??:??:??:??:??:?? ; do
[ -d $wwpn ] || continue
for t in ${wwpn}/tpgt_* ; do
[ -d $t ] || continue
for a in ${t}/acls/* ; do
for l in ${a}/lun_* ; do
for p in $l/* ; do
[ -L $p ] || continue
echo "Remove acl lun mapping $p"
rm -f $p
done
echo "Remove acl lun $l"
rmdir $l || exit 1
done
echo "Remove acl $a"
rmdir $a || exit 1
done
for l in ${t}/lun/lun_* ; do
[ -d $l ] || continue
for p in $l/* ; do
[ -L $p ] || continue
echo "Remove lun mapping $p"
rm -f $p
done
echo "Remove lun $l"
rmdir $l || exit 1
done
for p in ${t}/np/* ; do
echo "Remove $p"
rmdir $p
done
echo "Remove $t"
rmdir $t || exit 1
done
echo "Remove $wwpn"
rmdir $wwpn || exit 1
done
echo "Remove $fc"
rmdir $fc || exit 1