remove $proj-dist.conf for centos
[openstack-build/neutron-build.git] / rpm / SOURCES / neutron-mlnx-agent.init
1 #!/bin/bash
2 #
3 # neutron-mlnx-agent  OpenStack Neutron Mellanox Agent
4 #
5 # chkconfig:   - 98 02
6 # description: OpenStack Neutron Mellanox Agent
7 ### END INIT INFO
8
9 . /etc/rc.d/init.d/functions
10
11 proj=neutron
12 plugin=mlnx-agent
13 prog=$proj-$plugin
14 exec="/usr/bin/$prog"
15 configs=(
16     "/etc/$proj/$proj.conf" \
17     "/etc/$proj/plugins/mlnx/mlnx_conf.ini" \
18 )
19 pidfile="/var/run/$proj/$prog.pid"
20
21 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
22
23 lockfile=/var/lock/subsys/$prog
24
25 start() {
26     [ -x $exec ] || exit 5
27     for config in ${configs[@]}; do
28         [ -f $config ] || exit 6
29     done
30     echo -n $"Starting $prog: "
31     daemon --user neutron --pidfile $pidfile "$exec --log-file /var/log/$proj/$plugin.log ${configs[@]/#/--config-file } &>/dev/null & echo \$! > $pidfile"
32     retval=$?
33     echo
34     [ $retval -eq 0 ] && touch $lockfile
35     return $retval
36 }
37
38 stop() {
39     echo -n $"Stopping $prog: "
40     killproc -p $pidfile $prog
41     retval=$?
42     echo
43     [ $retval -eq 0 ] && rm -f $lockfile
44     return $retval
45 }
46
47 restart() {
48     stop
49     start
50 }
51
52 reload() {
53     restart
54 }
55
56 force_reload() {
57     restart
58 }
59
60 rh_status() {
61     status -p $pidfile $prog
62 }
63
64 rh_status_q() {
65     rh_status >/dev/null 2>&1
66 }
67
68
69 case "$1" in
70     start)
71         rh_status_q && exit 0
72         $1
73         ;;
74     stop)
75         rh_status_q || exit 0
76         $1
77         ;;
78     restart)
79         $1
80         ;;
81     reload)
82         rh_status_q || exit 7
83         $1
84         ;;
85     force-reload)
86         force_reload
87         ;;
88     status)
89         rh_status
90         ;;
91     condrestart|try-restart)
92         rh_status_q || exit 0
93         restart
94         ;;
95     *)
96         echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
97         exit 2
98 esac
99 exit $?