blob: 47fa8a7c6799ff0981817208fd2e944b2806574f [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001#!/bin/sh
2#
3### BEGIN INIT INFO
4# Provides: owcimomd
5# Required-Start: $network
6# Required-Stop: $network
7# Default-Start: 2 3 4 5
8# Default-Stop: 0 1 6
9# Short-Description: OpenWBEM CIMOM Daemon
10# Description: owcimomd
11# Start/Stop the OpenWBEM CIMOM Daemon
12### END INIT INFO
13#
14#
15# chkconfig: 2345 36 64
16# description: OpenWBEM CIMOM Daemon
17# processname: owcimomd
18
19NAME=owcimomd
20DAEMON=/usr/sbin/$NAME
21OPTIONS=
22PIDFILE=/var/run/$NAME.pid
23
24if [ $EUID != 0 ]; then
25 echo "This script must be run as root."
26 exit 1;
27fi
28
29if [ "$DESCRIPTIVE" = "" ]; then
30 DESCRIPTIVE="OpenWBEM CIMOM Daemon"
31fi
32
33lockfile=${SVIlock:-/var/lock/subsys/$NAME}
34
35[ -x $DAEMON ] || exit 0
36
37# See how we were called.
38. /etc/init.d/functions
39
40start() {
41 if [ ! -f "/etc/openwbem/serverkey.pem" ]; then
42 if [ -f "/etc/ssl/servercerts/servercert.pem" \
43 -a -f "/etc/ssl/servercerts/serverkey.pem" ]; then
44 echo "Using common server certificate /etc/ssl/servercerts/servercert.pem"
45 ln -s /etc/ssl/servercerts/server{cert,key}.pem /etc/openwbem/
46 else
47 echo "Generating OpenWBEM server public certificate and private key"
48 FQDN=`hostname --fqdn`
49 if [ "x${FQDN}" = "x" ]; then
50 FQDN=localhost.localdomain
51 fi
52cat << EOF | sh /etc/openwbem/owgencert > /dev/null 2>&1
53--
54SomeState
55SomeCity
56SomeOrganization
57SomeOrganizationalUnit
58${FQDN}
59root@${FQDN}
60EOF
61 fi
62 fi
63
64 # Start daemons.
65 echo -n "Starting the $DESCRIPTIVE"
66 daemon $DAEMON $OPTIONS > /dev/null 2>&1
67 RETVAL=$?
68
69 if [ $RETVAL -eq 0 ]; then
70 touch $lockfile
71 success
72 fi
73
74 echo
75 return $RETVAL
76}
77
78stop() {
79 # Stop daemons.
80 echo -n "Shutting down $DESCRIPTIVE"
81 killproc $DAEMON
82 RETVAL=$?
83
84 if [ $RETVAL -eq 0 ]; then
85 rm -f $lockfile
86 success
87 else
88 failure
89 fi
90 echo
91 return $RETVAL
92}
93
94restart() {
95 stop
96 start
97}
98
99case "$1" in
100 start)
101 start
102 ;;
103
104 stop)
105 stop
106 ;;
107
108 restart|force-reload)
109 restart
110 ;;
111
112 reload)
113 echo -n "Reload service $DESCRIPTIVE"
114 killproc -p $PIDFILE -HUP $DAEMON
115 RETVAL=$?
116 echo
117 exit $RETVAL
118 ;;
119
120 status)
121 echo -n "Checking for service $DESCRIPTIVE"
122 status $DAEMON
123 RETVAL=$?
124 exit $RETVAL
125 ;;
126
127 *)
128 echo "Usage: $0 {restart|start|stop|reload|force-reload|status}"
129esac
130
131exit $RETVAL