blob: 6d9fe3b0dbaba8c27f6fb19e9b07f0ef75c16df2 (
plain)
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
54
|
#!/bin/bash
### BEGIN INIT INFO
# Provides: target
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Short-Description: Start LIO targets
# Description: Loads configfs and restores LIO config with targetcli
### END INIT INFO
case "$1" in
start)
if [ ! -d /sys/kernel/config ]; then
echo "Mounting configfs"
modprobe configfs
mount -t configfs configfs /sys/kernel/config
if [ $? != 0 ]; then
exit 1
fi
fi
echo "Starting lio targets"
/usr/bin/targetcli restoreconfig clear_existing=true
if [[ $? -gt 0 ]]; then
exit 1
fi
;;
stop)
echo "Stopping lio targets"
/usr/bin/targetcli clearconfig confirm=true
if [[ $? -gt 0 ]]; then
exit 1
fi
;;
restart|force-reload)
$0 stop
sleep 3
$0 start
;;
status)
echo "Checking status of lio targets";
/usr/bin/targetcli sessions
;;
*)
echo "usage: $0 {start|stop|restart|force-reload|status}"
esac
exit 0
|