summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmy Fong <amy.fong@windriver.com>2014-03-17 14:14:48 -0400
committerBruce Ashfield <bruce.ashfield@windriver.com>2014-03-17 15:27:41 -0400
commit9a74961bafabc404f015fc5d8a9da969d263dad3 (patch)
treeedc0caa250166b128c89f606d17373c75e233d26
parent71ef5b7acb5815c678cda0c115e98e6b1d06e1aa (diff)
downloadmeta-cloud-services-9a74961bafabc404f015fc5d8a9da969d263dad3.tar.gz
OpenStack: Add to missing functionality in sysvinit scripts
Add status/reload to sysvinit scripts Modify tgtd to make start/stop work better (borrowed from Debian's implementation) Signed-off-by: Amy Fong <amy.fong@windriver.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
-rw-r--r--meta-openstack/recipes-devtools/python/python-ceilometer/ceilometer.init19
-rw-r--r--meta-openstack/recipes-devtools/python/python-cinder/cinder-volume19
-rw-r--r--meta-openstack/recipes-devtools/python/python-cinder/cinder.init19
-rw-r--r--meta-openstack/recipes-devtools/python/python-glance/glance.init20
-rw-r--r--meta-openstack/recipes-devtools/python/python-heat/heat.init19
-rw-r--r--meta-openstack/recipes-devtools/python/python-horizon/horizon.init19
-rw-r--r--meta-openstack/recipes-devtools/python/python-keystone/keystone19
-rw-r--r--meta-openstack/recipes-devtools/python/python-neutron/neutron-agent.init19
-rw-r--r--meta-openstack/recipes-devtools/python/python-neutron/neutron-server.init19
-rw-r--r--meta-openstack/recipes-devtools/python/python-nova/nova-all19
-rw-r--r--meta-openstack/recipes-devtools/python/python-nova/nova-consoleauth19
-rw-r--r--meta-openstack/recipes-devtools/python/python-nova/nova-novncproxy19
-rw-r--r--meta-openstack/recipes-devtools/python/python-nova/nova.init19
-rw-r--r--meta-openstack/recipes-support/tgt/files/tgtd.init86
14 files changed, 281 insertions, 53 deletions
diff --git a/meta-openstack/recipes-devtools/python/python-ceilometer/ceilometer.init b/meta-openstack/recipes-devtools/python/python-ceilometer/ceilometer.init
index c726855..23ca780 100644
--- a/meta-openstack/recipes-devtools/python/python-ceilometer/ceilometer.init
+++ b/meta-openstack/recipes-devtools/python/python-ceilometer/ceilometer.init
@@ -58,6 +58,18 @@ stop()
58 rm -f $PIDFILE 58 rm -f $PIDFILE
59} 59}
60 60
61status()
62{
63 pid=`cat $PIDFILE 2>/dev/null`
64 if [ -n "$pid" ]; then
65 if ps -p $pid >&- ; then
66 echo "$DESC is running"
67 return
68 fi
69 fi
70 echo "$DESC is not running"
71}
72
61case "$1" in 73case "$1" in
62 start) 74 start)
63 start 75 start
@@ -65,12 +77,15 @@ case "$1" in
65 stop) 77 stop)
66 stop 78 stop
67 ;; 79 ;;
68 restart|force-reload) 80 restart|force-reload|reload)
69 stop 81 stop
70 start 82 start
71 ;; 83 ;;
84 status)
85 status
86 ;;
72 *) 87 *)
73 echo "Usage: $0 {start|stop|force-reload|restart}" 88 echo "Usage: $0 {start|stop|force-reload|restart|reload|status}"
74 exit 1 89 exit 1
75 ;; 90 ;;
76esac 91esac
diff --git a/meta-openstack/recipes-devtools/python/python-cinder/cinder-volume b/meta-openstack/recipes-devtools/python/python-cinder/cinder-volume
index 3cc2aa3..2c9334e 100644
--- a/meta-openstack/recipes-devtools/python/python-cinder/cinder-volume
+++ b/meta-openstack/recipes-devtools/python/python-cinder/cinder-volume
@@ -56,6 +56,18 @@ stop()
56 rm -f $PIDFILE 56 rm -f $PIDFILE
57} 57}
58 58
59status()
60{
61 pid=`cat $PIDFILE 2>/dev/null`
62 if [ -n "$pid" ]; then
63 if ps -p $pid >&- ; then
64 echo "$DESC is running"
65 return
66 fi
67 fi
68 echo "$DESC is not running"
69}
70
59case "$1" in 71case "$1" in
60 start) 72 start)
61 start 73 start
@@ -63,12 +75,15 @@ case "$1" in
63 stop) 75 stop)
64 stop 76 stop
65 ;; 77 ;;
66 restart|force-reload) 78 restart|force-reload|reload)
67 stop 79 stop
68 start 80 start
69 ;; 81 ;;
82 status)
83 status
84 ;;
70 *) 85 *)
71 echo "Usage: $0 {start|stop|force-reload|restart}" 86 echo "Usage: $0 {start|stop|force-reload|restart|reload|status}"
72 exit 1 87 exit 1
73 ;; 88 ;;
74esac 89esac
diff --git a/meta-openstack/recipes-devtools/python/python-cinder/cinder.init b/meta-openstack/recipes-devtools/python/python-cinder/cinder.init
index 7ae3dbf..0a3923a 100644
--- a/meta-openstack/recipes-devtools/python/python-cinder/cinder.init
+++ b/meta-openstack/recipes-devtools/python/python-cinder/cinder.init
@@ -54,6 +54,18 @@ stop()
54 rm -f $PIDFILE 54 rm -f $PIDFILE
55} 55}
56 56
57status()
58{
59 pid=`cat $PIDFILE 2>/dev/null`
60 if [ -n "$pid" ]; then
61 if ps -p $pid >&- ; then
62 echo "$DESC is running"
63 return
64 fi
65 fi
66 echo "$DESC is not running"
67}
68
57case "$1" in 69case "$1" in
58 start) 70 start)
59 start 71 start
@@ -61,12 +73,15 @@ case "$1" in
61 stop) 73 stop)
62 stop 74 stop
63 ;; 75 ;;
64 restart|force-reload) 76 restart|force-reload|reload)
65 stop 77 stop
66 start 78 start
67 ;; 79 ;;
80 status)
81 status
82 ;;
68 *) 83 *)
69 echo "Usage: $0 {start|stop|force-reload|restart}" 84 echo "Usage: $0 {start|stop|force-reload|restart|reload|status}"
70 exit 1 85 exit 1
71 ;; 86 ;;
72esac 87esac
diff --git a/meta-openstack/recipes-devtools/python/python-glance/glance.init b/meta-openstack/recipes-devtools/python/python-glance/glance.init
index c61abaa..def500f 100644
--- a/meta-openstack/recipes-devtools/python/python-glance/glance.init
+++ b/meta-openstack/recipes-devtools/python/python-glance/glance.init
@@ -4,6 +4,7 @@
4# Provides: 4# Provides:
5# Required-Start: $remote_fs $network $syslog 5# Required-Start: $remote_fs $network $syslog
6# Required-Stop: $remote_fs $syslog 6# Required-Stop: $remote_fs $syslog
7# Default-Start: 2 3 4 5
7# Default-Stop: 0 1 6 8# Default-Stop: 0 1 6
8# Short-Description: Glance API server 9# Short-Description: Glance API server
9# Description: OpenStack Image Service (code-named Glance) API server 10# Description: OpenStack Image Service (code-named Glance) API server
@@ -57,6 +58,18 @@ stop()
57 rm -f $PIDFILE 58 rm -f $PIDFILE
58} 59}
59 60
61status()
62{
63 pid=`cat $PIDFILE 2>/dev/null`
64 if [ -n "$pid" ]; then
65 if ps -p $pid >&- ; then
66 echo "$DESC is running"
67 return
68 fi
69 fi
70 echo "$DESC is not running"
71}
72
60case "$1" in 73case "$1" in
61 start) 74 start)
62 start 75 start
@@ -64,12 +77,15 @@ case "$1" in
64 stop) 77 stop)
65 stop 78 stop
66 ;; 79 ;;
67 restart|force-reload) 80 restart|force-reload|reload)
68 stop 81 stop
69 start 82 start
70 ;; 83 ;;
84 status)
85 status
86 ;;
71 *) 87 *)
72 echo "Usage: $0 {start|stop|force-reload|restart}" 88 echo "Usage: $0 {start|stop|force-reload|restart|reload|status}"
73 exit 1 89 exit 1
74 ;; 90 ;;
75esac 91esac
diff --git a/meta-openstack/recipes-devtools/python/python-heat/heat.init b/meta-openstack/recipes-devtools/python/python-heat/heat.init
index a7a168d..e37c4c8 100644
--- a/meta-openstack/recipes-devtools/python/python-heat/heat.init
+++ b/meta-openstack/recipes-devtools/python/python-heat/heat.init
@@ -64,6 +64,18 @@ stop()
64 rm -f $PIDFILE 64 rm -f $PIDFILE
65} 65}
66 66
67status()
68{
69 pid=`cat $PIDFILE 2>/dev/null`
70 if [ -n "$pid" ]; then
71 if ps -p $pid >&- ; then
72 echo "$DESC is running"
73 return
74 fi
75 fi
76 echo "$DESC is not running"
77}
78
67case "$1" in 79case "$1" in
68 start) 80 start)
69 start 81 start
@@ -71,12 +83,15 @@ case "$1" in
71 stop) 83 stop)
72 stop 84 stop
73 ;; 85 ;;
74 restart|force-reload) 86 restart|force-reload|reload)
75 stop 87 stop
76 start 88 start
77 ;; 89 ;;
90 status)
91 status
92 ;;
78 *) 93 *)
79 echo "Usage: $0 {start|stop|force-reload|restart}" 94 echo "Usage: $0 {start|stop|force-reload|restart|reload|status}"
80 exit 1 95 exit 1
81 ;; 96 ;;
82esac 97esac
diff --git a/meta-openstack/recipes-devtools/python/python-horizon/horizon.init b/meta-openstack/recipes-devtools/python/python-horizon/horizon.init
index 65b96e4..994fbec 100644
--- a/meta-openstack/recipes-devtools/python/python-horizon/horizon.init
+++ b/meta-openstack/recipes-devtools/python/python-horizon/horizon.init
@@ -54,6 +54,18 @@ stop()
54 rm -f $PIDFILE 54 rm -f $PIDFILE
55} 55}
56 56
57status()
58{
59 pid=`cat $PIDFILE 2>/dev/null`
60 if [ -n "$pid" ]; then
61 if ps -p $pid >&- ; then
62 echo "$DESC is running"
63 return
64 fi
65 fi
66 echo "$DESC is not running"
67}
68
57case "$1" in 69case "$1" in
58 start) 70 start)
59 start 71 start
@@ -61,12 +73,15 @@ case "$1" in
61 stop) 73 stop)
62 stop 74 stop
63 ;; 75 ;;
64 restart|force-reload) 76 restart|force-reload|reload)
65 stop 77 stop
66 start 78 start
67 ;; 79 ;;
80 status)
81 status
82 ;;
68 *) 83 *)
69 echo "Usage: $0 {start|stop|force-reload|restart}" 84 echo "Usage: $0 {start|stop|force-reload|restart|reload|status}"
70 exit 1 85 exit 1
71 ;; 86 ;;
72esac 87esac
diff --git a/meta-openstack/recipes-devtools/python/python-keystone/keystone b/meta-openstack/recipes-devtools/python/python-keystone/keystone
index a5529df..463b05f 100644
--- a/meta-openstack/recipes-devtools/python/python-keystone/keystone
+++ b/meta-openstack/recipes-devtools/python/python-keystone/keystone
@@ -51,6 +51,18 @@ stop ()
51 rm -f $PIDFILE 51 rm -f $PIDFILE
52} 52}
53 53
54status()
55{
56 pid=`cat $PIDFILE 2>/dev/null`
57 if [ -n "$pid" ]; then
58 if ps -p $pid >&- ; then
59 echo "$DESC is running"
60 return
61 fi
62 fi
63 echo "$DESC is not running"
64}
65
54case "$1" in 66case "$1" in
55 start) 67 start)
56 start 68 start
@@ -58,12 +70,15 @@ case "$1" in
58 stop) 70 stop)
59 stop 71 stop
60 ;; 72 ;;
61 restart|force-reload) 73 restart|force-reload|reload)
62 stop 74 stop
63 start 75 start
64 ;; 76 ;;
77 status)
78 status
79 ;;
65 *) 80 *)
66 echo "Usage: $0 {start|stop|force-reload|restart}" 81 echo "Usage: $0 {start|stop|force-reload|restart|reload|status}"
67 exit 1 82 exit 1
68 ;; 83 ;;
69esac 84esac
diff --git a/meta-openstack/recipes-devtools/python/python-neutron/neutron-agent.init b/meta-openstack/recipes-devtools/python/python-neutron/neutron-agent.init
index f575746..e02ea9e 100644
--- a/meta-openstack/recipes-devtools/python/python-neutron/neutron-agent.init
+++ b/meta-openstack/recipes-devtools/python/python-neutron/neutron-agent.init
@@ -50,6 +50,18 @@ stop()
50 rm -f $PIDFILE 50 rm -f $PIDFILE
51} 51}
52 52
53status()
54{
55 pid=`cat $PIDFILE 2>/dev/null`
56 if [ -n "$pid" ]; then
57 if ps -p $pid >&- ; then
58 echo "$DESC is running"
59 return
60 fi
61 fi
62 echo "$DESC is not running"
63}
64
53case "$1" in 65case "$1" in
54 start) 66 start)
55 start 67 start
@@ -57,12 +69,15 @@ case "$1" in
57 stop) 69 stop)
58 stop 70 stop
59 ;; 71 ;;
60 restart|force-reload) 72 restart|force-reload|reload)
61 stop 73 stop
62 start 74 start
63 ;; 75 ;;
76 status)
77 status
78 ;;
64 *) 79 *)
65 echo "Usage: $0 {start|stop|force-reload|restart}" 80 echo "Usage: $0 {start|stop|force-reload|restart|reload|status}"
66 exit 1 81 exit 1
67 ;; 82 ;;
68esac 83esac
diff --git a/meta-openstack/recipes-devtools/python/python-neutron/neutron-server.init b/meta-openstack/recipes-devtools/python/python-neutron/neutron-server.init
index 387f602..bd1fe86 100644
--- a/meta-openstack/recipes-devtools/python/python-neutron/neutron-server.init
+++ b/meta-openstack/recipes-devtools/python/python-neutron/neutron-server.init
@@ -53,6 +53,18 @@ stop()
53 rm -f $PIDFILE 53 rm -f $PIDFILE
54} 54}
55 55
56status()
57{
58 pid=`cat $PIDFILE 2>/dev/null`
59 if [ -n "$pid" ]; then
60 if ps -p $pid >&- ; then
61 echo "$DESC is running"
62 return
63 fi
64 fi
65 echo "$DESC is not running"
66}
67
56case "$1" in 68case "$1" in
57 start) 69 start)
58 start 70 start
@@ -60,12 +72,15 @@ case "$1" in
60 stop) 72 stop)
61 stop 73 stop
62 ;; 74 ;;
63 restart|force-reload) 75 restart|force-reload|reload)
64 stop 76 stop
65 start 77 start
66 ;; 78 ;;
79 status)
80 status
81 ;;
67 *) 82 *)
68 echo "Usage: $0 {start|stop|force-reload|restart}" 83 echo "Usage: $0 {start|stop|force-reload|restart|reload|status}"
69 exit 1 84 exit 1
70 ;; 85 ;;
71esac 86esac
diff --git a/meta-openstack/recipes-devtools/python/python-nova/nova-all b/meta-openstack/recipes-devtools/python/python-nova/nova-all
index 5891759..b3ff40e 100644
--- a/meta-openstack/recipes-devtools/python/python-nova/nova-all
+++ b/meta-openstack/recipes-devtools/python/python-nova/nova-all
@@ -53,6 +53,18 @@ stop ()
53 rm -f $PIDFILE 53 rm -f $PIDFILE
54} 54}
55 55
56status()
57{
58 pid=`cat $PIDFILE 2>/dev/null`
59 if [ -n "$pid" ]; then
60 if ps -p $pid >&- ; then
61 echo "$DESC is running"
62 return
63 fi
64 fi
65 echo "$DESC is not running"
66}
67
56case "$1" in 68case "$1" in
57 start) 69 start)
58 start 70 start
@@ -60,12 +72,15 @@ case "$1" in
60 stop) 72 stop)
61 stop 73 stop
62 ;; 74 ;;
63 restart|force-reload) 75 restart|force-reload|reload)
64 stop 76 stop
65 start 77 start
66 ;; 78 ;;
79 status)
80 status
81 ;;
67 *) 82 *)
68 echo "Usage: $0 {start|stop|force-reload|restart}" 83 echo "Usage: $0 {start|stop|force-reload|restart|reload|status}"
69 exit 1 84 exit 1
70 ;; 85 ;;
71esac 86esac
diff --git a/meta-openstack/recipes-devtools/python/python-nova/nova-consoleauth b/meta-openstack/recipes-devtools/python/python-nova/nova-consoleauth
index 13ad285..56561db 100644
--- a/meta-openstack/recipes-devtools/python/python-nova/nova-consoleauth
+++ b/meta-openstack/recipes-devtools/python/python-nova/nova-consoleauth
@@ -43,6 +43,19 @@ if ! [ -x ${DAEMON} ] ; then
43 exit 0 43 exit 0
44fi 44fi
45 45
46DESC="nova console"
47status()
48{
49 pid=`cat $PIDFILE 2>/dev/null`
50 if [ -n "$pid" ]; then
51 if ps -p $pid >&- ; then
52 echo "$DESC is running"
53 return
54 fi
55 fi
56 echo "$DESC is not running"
57}
58
46case "$1" in 59case "$1" in
47 start) 60 start)
48 test "$ENABLED" = "true" || exit 0 61 test "$ENABLED" = "true" || exit 0
@@ -56,7 +69,7 @@ case "$1" in
56 start-stop-daemon --stop --oknodo --pidfile ${PIDFILE} 69 start-stop-daemon --stop --oknodo --pidfile ${PIDFILE}
57 log_end_msg $? 70 log_end_msg $?
58 ;; 71 ;;
59 restart|force-reload) 72 restart|force-reload|reload)
60 test "$ENABLED" = "true" || exit 1 73 test "$ENABLED" = "true" || exit 1
61 $0 stop 74 $0 stop
62 sleep 1 75 sleep 1
@@ -64,10 +77,10 @@ case "$1" in
64 ;; 77 ;;
65 status) 78 status)
66 test "$ENABLED" = "true" || exit 0 79 test "$ENABLED" = "true" || exit 0
67 status_of_proc -p $PIDFILE $DAEMON nova-consoleauth && exit 0 || exit $? 80 status
68 ;; 81 ;;
69 *) 82 *)
70 echo "Usage: /etc/init.d/nova-consoleauth {start|stop|restart|force-reload|status}" 83 echo "Usage: /etc/init.d/nova-consoleauth {start|stop|restart|force-reload|status|reload|status}"
71 exit 1 84 exit 1
72 ;; 85 ;;
73esac 86esac
diff --git a/meta-openstack/recipes-devtools/python/python-nova/nova-novncproxy b/meta-openstack/recipes-devtools/python/python-nova/nova-novncproxy
index 76cd1df..c976194 100644
--- a/meta-openstack/recipes-devtools/python/python-nova/nova-novncproxy
+++ b/meta-openstack/recipes-devtools/python/python-nova/nova-novncproxy
@@ -40,6 +40,19 @@ if ! [ -x ${DAEMON} ] ; then
40 exit 0 40 exit 0
41fi 41fi
42 42
43DESC="nova vnc proxy"
44status()
45{
46 pid=`cat $PIDFILE 2>/dev/null`
47 if [ -n "$pid" ]; then
48 if ps -p $pid >&- ; then
49 echo "$DESC is running"
50 return
51 fi
52 fi
53 echo "$DESC is not running"
54}
55
43case "$1" in 56case "$1" in
44 start) 57 start)
45 test "$ENABLED" = "true" || exit 0 58 test "$ENABLED" = "true" || exit 0
@@ -53,7 +66,7 @@ case "$1" in
53 start-stop-daemon --stop --oknodo --pidfile ${PIDFILE} 66 start-stop-daemon --stop --oknodo --pidfile ${PIDFILE}
54 log_end_msg $? 67 log_end_msg $?
55 ;; 68 ;;
56 restart|force-reload) 69 restart|force-reload|reload)
57 test "$ENABLED" = "true" || exit 1 70 test "$ENABLED" = "true" || exit 1
58 $0 stop 71 $0 stop
59 sleep 1 72 sleep 1
@@ -61,10 +74,10 @@ case "$1" in
61 ;; 74 ;;
62 status) 75 status)
63 test "$ENABLED" = "true" || exit 0 76 test "$ENABLED" = "true" || exit 0
64 status_of_proc -p $PIDFILE $DAEMON nova-novncproxy && exit 0 || exit $? 77 status
65 ;; 78 ;;
66 *) 79 *)
67 echo "Usage: /etc/init.d/nova-novncproxy {start|stop|restart|force-reload|status}" 80 echo "Usage: /etc/init.d/nova-novncproxy {start|stop|restart|force-reload|status|reload|status}"
68 exit 1 81 exit 1
69 ;; 82 ;;
70esac 83esac
diff --git a/meta-openstack/recipes-devtools/python/python-nova/nova.init b/meta-openstack/recipes-devtools/python/python-nova/nova.init
index c317f84..5d298fd 100644
--- a/meta-openstack/recipes-devtools/python/python-nova/nova.init
+++ b/meta-openstack/recipes-devtools/python/python-nova/nova.init
@@ -57,6 +57,18 @@ stop ()
57 rm -f $PIDFILE 57 rm -f $PIDFILE
58} 58}
59 59
60status()
61{
62 pid=`cat $PIDFILE 2>/dev/null`
63 if [ -n "$pid" ]; then
64 if ps -p $pid >&- ; then
65 echo "$DESC is running"
66 return
67 fi
68 fi
69 echo "$DESC is not running"
70}
71
60case "$1" in 72case "$1" in
61 start) 73 start)
62 start 74 start
@@ -64,12 +76,15 @@ case "$1" in
64 stop) 76 stop)
65 stop 77 stop
66 ;; 78 ;;
67 restart|force-reload) 79 restart|force-reload|reload)
68 stop 80 stop
69 start 81 start
70 ;; 82 ;;
83 status)
84 status
85 ;;
71 *) 86 *)
72 echo "Usage: $0 {start|stop|force-reload|restart}" 87 echo "Usage: $0 {start|stop|force-reload|restart|reload|status}"
73 exit 1 88 exit 1
74 ;; 89 ;;
75esac 90esac
diff --git a/meta-openstack/recipes-support/tgt/files/tgtd.init b/meta-openstack/recipes-support/tgt/files/tgtd.init
index 3408645..ab91190 100644
--- a/meta-openstack/recipes-support/tgt/files/tgtd.init
+++ b/meta-openstack/recipes-support/tgt/files/tgtd.init
@@ -12,43 +12,73 @@
12 12
13DESC="tgtd" 13DESC="tgtd"
14DAEMON="/usr/sbin/tgtd" 14DAEMON="/usr/sbin/tgtd"
15PIDFILE="/var/run/tgtd.pid" 15TGTD_CONFIG=/etc/tgt/targets.conf
16 16
17start () 17start ()
18{ 18{
19 if [ -e $PIDFILE ]; then
20 PIDDIR=/proc/$(cat $PIDFILE)
21 if [ -d ${PIDDIR} ]; then
22 echo "$DESC already running."
23 exit 1
24 else
25 echo "Removing stale PID file $PIDFILE"
26 rm -f $PIDFILE
27 fi
28 fi
29
30 echo -n "Starting $DESC..." 19 echo -n "Starting $DESC..."
31 20 # Start tgtd first
32 start-stop-daemon --start --quiet --pidfile ${PIDFILE} \ 21 $DAEMON &>/dev/null
33 --make-pidfile --exec ${DAEMON} 22 RETVAL=$?
34 23 if [ "$RETVAL" -ne 0 ]; then
35 if [ $? -eq 0 ]; then
36 echo "done."
37 else
38 echo "failed." 24 echo "failed."
25 exit 1
39 fi 26 fi
27
28 # Put tgtd into "offline" state until all the targets are configured.
29 # We don't want initiators to (re)connect and fail the connection
30 # if it's not ready.
31 tgtadm --op update --mode sys --name State -v offline
32 # Configure the targets.
33 tgt-admin -e -c $TGTD_CONFIG
34 # Put tgtd into "ready" state.
35 tgtadm --op update --mode sys --name State -v ready
36
37 echo "done."
40} 38}
41 39
42stop () 40stop ()
43{ 41{
44 echo -n "Stopping $DESC..." 42 echo -n "Stopping $DESC..."
45 start-stop-daemon --stop --quiet --pidfile $PIDFILE 43
46 if [ $? -eq 0 ]; then 44 # Remove all targets. It only removes targets which are not in use.
47 echo "done." 45 tgt-admin --update ALL -c /dev/null &>/dev/null
48 else 46 # tgtd will exit if all targets were removed
49 echo "failed." 47 tgtadm --op delete --mode system &>/dev/null
48 RETVAL=$?
49 if [ "$RETVAL" -eq 107 ] ; then
50 if [ "$TASK" != "restart" ] ; then
51 exit 1
52 fi
53 elif [ "$RETVAL" -ne 0 ] ; then
54 echo "Some initiators are still connected - could not stop tgtd"
55 exit 2
50 fi 56 fi
51 rm -f $PIDFILE 57 echo -n
58}
59
60reload()
61{
62 echo "Reloading configuration of $DESC" "$NAME"
63 # Update configuration for targets. Only targets which
64 # are not in use will be updated.
65 tgt-admin --update ALL -c $TGTD_CONFIG &>/dev/null
66 RETVAL=$?
67 if [ "$RETVAL" -eq 107 ] ; then
68 echo "tgtd is not running"
69 exit 1
70 fi
71}
72
73status()
74{
75 tgt-admin -s >/dev/null 2>&1
76 RETVAL=$?
77 if [ "$RETVAL" -eq 107 ] ; then
78 echo "tgtd is not running"
79 else
80 echo "tgtd is running"
81 fi
52} 82}
53 83
54case "$1" in 84case "$1" in
@@ -62,6 +92,12 @@ case "$1" in
62 stop 92 stop
63 start 93 start
64 ;; 94 ;;
95 reload)
96 reload
97 ;;
98 status)
99 status
100 ;;
65 *) 101 *)
66 echo "Usage: $0 {start|stop|force-reload|restart}" 102 echo "Usage: $0 {start|stop|force-reload|restart}"
67 exit 1 103 exit 1