Browse Source

Add installer and init.d scripts

Change-Id: I7d1b06cfcf4028202bd962576bdc5e01b733c5bf
Igor Yozhikov 5 years ago
parent
commit
366d9cc010

+ 2
- 2
python-agent/etc/agent.conf View File

@@ -1,8 +1,8 @@
1 1
 [DEFAULT]
2 2
 debug=True
3 3
 verbose=True
4
-
5
-storage=.
4
+log_file = /var/log/murano-agent.log
5
+storage=/var/murano/plans
6 6
 
7 7
 [rabbitmq]
8 8
 

+ 103
- 0
python-agent/init.d/murano-agent-deb View File

@@ -0,0 +1,103 @@
1
+#!/bin/sh
2
+#    Copyright (c) 2013 Mirantis, Inc.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+#    Author: Igor Yozhikov <iyozhikov@mirantis.com>
16
+#
17
+### BEGIN INIT INFO
18
+# Provides:          murano-agent
19
+# Required-Start:    $network $local_fs $remote_fs $syslog
20
+# Required-Stop:     $remote_fs
21
+# Default-Start:     2 3 4 5
22
+# Default-Stop:      0 1 6
23
+# Short-Description: Launches the murano linux agent
24
+# Description:       This startup script launches murano linux agent.
25
+### END INIT INFO
26
+
27
+
28
+PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
29
+DESC="murano-agent"
30
+NAME=murano-agent
31
+DAEMON=/usr/local/bin/muranoagent
32
+PIDFILE=/var/run/$NAME.pid
33
+SCRIPTNAME=/etc/init.d/$NAME
34
+SYSTEM_USER=root
35
+CONFIG_FILE=/etc/murano/agent.conf
36
+DATADIR=/var/murano/plans
37
+
38
+# Exit if the package is not installed
39
+[ -x $DAEMON ] || exit 5
40
+
41
+# source function library
42
+. /lib/lsb/init-functions
43
+
44
+if [ ! -d "$DATADIR" ]; then
45
+        mkdir -p ${DATADIR}
46
+        chown ${SYSTEM_USER} ${DATADIR}
47
+fi
48
+
49
+do_start () {
50
+        start-stop-daemon --start --background --quiet --chuid $SYSTEM_USER:$SYSTEM_USER --make-pidfile --pidfile $PIDFILE --startas $DAEMON --test -- --config-file=$CONFIG_FILE > /dev/null || return 1
51
+        start-stop-daemon --start --background --quiet --chuid $SYSTEM_USER:$SYSTEM_USER --make-pidfile --pidfile $PIDFILE --startas $DAEMON -- --config-file=$CONFIG_FILE || return 2
52
+}
53
+
54
+do_stop () {
55
+        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
56
+        RETVAL="$?"
57
+        rm -f $PIDFILE
58
+        return "$RETVAL"
59
+}
60
+
61
+case "$1" in
62
+  start)
63
+    log_daemon_msg "Starting $DESC" "$NAME"
64
+    do_start
65
+    case "$?" in
66
+                0|1) log_end_msg 0 ;;
67
+                2) log_end_msg 1 ;;
68
+        esac
69
+  ;;
70
+  stop)
71
+        log_daemon_msg "Stopping $DESC" "$NAME"
72
+        do_stop
73
+        case "$?" in
74
+                0|1) log_end_msg 0 ;;
75
+                2) log_end_msg 1 ;;
76
+        esac
77
+        ;;
78
+  status)
79
+       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
80
+       ;;
81
+  restart|force-reload)
82
+        log_daemon_msg "Restarting $DESC" "$NAME"
83
+        do_stop
84
+        case "$?" in
85
+          0|1)
86
+                do_start
87
+                case "$?" in
88
+                        0) log_end_msg 0 ;;
89
+                        1) log_end_msg 1 ;; # Old process is still running
90
+                        *) log_end_msg 1 ;; # Failed to start
91
+                esac
92
+                ;;
93
+          *)
94
+                # Failed to stop
95
+                log_end_msg 1
96
+                ;;
97
+        esac
98
+        ;;
99
+  *)
100
+        echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
101
+        exit 3
102
+        ;;
103
+esac

+ 103
- 0
python-agent/init.d/murano-agent-el6 View File

@@ -0,0 +1,103 @@
1
+#!/bin/sh
2
+#    Copyright (c) 2013 Mirantis, Inc.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+#    Author: Igor Yozhikov <iyozhikov@mirantis.com>
16
+#
17
+### BEGIN INIT INFO
18
+# Provides: murano-agent
19
+# Required-Start:    $network $local_fs $remote_fs $syslog
20
+# Required-Stop:     $remote_fs
21
+# Default-Start:     2 3 4 5
22
+# Default-Stop:      0 1 6
23
+# Short-Description: Launches the murano linux agent
24
+# Description: This startup script launches murano linux agent.
25
+### END INIT INFO
26
+# chkconfig: 3 90 10
27
+# description: This startup script launches the murano linux agent.
28
+# config: /etc/murano/agent.conf
29
+#
30
+PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
31
+DESC="murano-agent"
32
+NAME=murano-agent
33
+DAEMON=/usr/local/bin/muranoagent
34
+PIDFILE=/var/run/$NAME.pid
35
+SCRIPTNAME=/etc/init.d/$NAME
36
+SYSTEM_USER=root
37
+CONFIG_FILE=/etc/murano/agent.conf
38
+DATADIR=/var/murano/plans
39
+LOCKFILE=/var/lock/subsys/$NAME
40
+# Exit if the package is not installed
41
+[ -x $DAEMON ] || exit 5
42
+
43
+# source function library
44
+. /etc/init.d/functions
45
+
46
+RETVAL=0
47
+
48
+if [ ! -d "$DATADIR" ]; then
49
+    mkdir -p $DATADIR
50
+    chown $SYSTEM_USER $DATADIR
51
+fi
52
+
53
+start() {
54
+    echo -n "Starting $NAME: "
55
+    daemon --user $SYSTEM_USER "$DAEMON --config-file=$CONFIG_FILE &>/dev/null & echo \$! > $PIDFILE"
56
+    RETVAL=$?
57
+    echo
58
+    [ $RETVAL -eq 0 ] && touch $LOCKFILE
59
+    return $RETVAL
60
+}
61
+
62
+stop() {
63
+    echo -n "Stopping $NAME: "
64
+    #killproc $DAEMON -TERM
65
+    killproc -p $PIDFILE $DAEMON
66
+    RETVAL=$?
67
+    echo
68
+    [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
69
+    return $RETVAL
70
+}
71
+
72
+restart() {
73
+    stop
74
+    start
75
+}
76
+
77
+rh_status() {
78
+    # run checks to determine if the service is running or use generic status
79
+    status $DAEMON
80
+}
81
+
82
+
83
+case "$1" in
84
+    start)
85
+        start
86
+        ;;
87
+
88
+    stop)
89
+        stop
90
+        ;;
91
+
92
+    restart)
93
+        restart
94
+        ;;
95
+
96
+    status)
97
+        rh_status
98
+        ;;
99
+    *)
100
+        echo $"Usage: $0 {start|stop|status|restart}"
101
+        exit 2
102
+esac
103
+exit $?

+ 1
- 0
python-agent/requirements.txt View File

@@ -4,3 +4,4 @@ bunch
4 4
 oslo.config>=1.2.0
5 5
 http://tarballs.openstack.org/murano-common/murano-common-release-0.3.tar.gz#egg=murano-common-release-0.3
6 6
 iso8601
7
+babel

+ 210
- 0
python-agent/setup-centos.sh View File

@@ -0,0 +1,210 @@
1
+#!/bin/sh
2
+#    Copyright (c) 2013 Mirantis, Inc.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+#
16
+#   CentOS script
17
+LOGLVL=1
18
+SERVICE_CONTENT_DIRECTORY=`cd $(dirname "$0") && pwd`
19
+PREREQ_PKGS="git wget make gcc python-pip python-iso8601 python-six python-anyjson python-eventlet python-devel python-setuptools"
20
+PIPAPPS="pip python-pip pip-python"
21
+PIPCMD=""
22
+SERVICE_SRV_NAME="murano-agent"
23
+ETC_CFG_DIR="/etc/murano"
24
+
25
+
26
+
27
+# Functions
28
+# Loger function
29
+log()
30
+{
31
+	MSG=$1
32
+	if [ $LOGLVL -gt 0 ]; then
33
+		echo "LOG:> $MSG"
34
+	fi
35
+}
36
+
37
+# find pip
38
+find_pip()
39
+{
40
+	for cmd in $PIPAPPS
41
+	do
42
+		_cmd=$(which $cmd 2>/dev/null)
43
+		if [ $? -eq 0 ];then
44
+			break
45
+		fi
46
+	done
47
+	if [ -z $_cmd ];then
48
+		echo "Can't find \"pip\" in system, please install it first, exiting!"
49
+		exit 1
50
+	else
51
+		PIPCMD=$_cmd
52
+	fi
53
+}
54
+
55
+# Check or install package
56
+in_sys_pkg()
57
+{
58
+	PKG=$1
59
+	rpm -q $PKG > /dev/null 2>&1
60
+	if [ $? -eq 0 ]; then
61
+	    log "Package \"$PKG\" already installed"
62
+	else
63
+		log "Installing \"$PKG\"..."
64
+		yum install $PKG --assumeyes > /dev/null 2>&1
65
+		if [ $? -ne 0 ];then
66
+		    log "installation fails, exiting!!!"
67
+		    exit
68
+		fi
69
+	fi
70
+}
71
+
72
+# install
73
+inst()
74
+{
75
+# Checking packages
76
+	for PKG in $PREREQ_PKGS
77
+	do
78
+		in_sys_pkg $PKG
79
+	done
80
+# Find python pip
81
+	find_pip
82
+	MRN_CND_SPY=$SERVICE_CONTENT_DIRECTORY/setup.py
83
+	if [ -e $MRN_CND_SPY ]; then
84
+		chmod +x $MRN_CND_SPY
85
+		log "$MRN_CND_SPY output:_____________________________________________________________"
86
+## Setup through pip
87
+		# Creating tarball
88
+		rm -rf $SERVICE_CONTENT_DIRECTORY/*.egg-info
89
+		cd $SERVICE_CONTENT_DIRECTORY && python $MRN_CND_SPY egg_info
90
+		if [ $? -ne 0 ];then
91
+			log "\"$MRN_CND_SPY\" egg info creation FAILS, exiting!!!"
92
+			exit 1
93
+		fi
94
+		rm -rf $SERVICE_CONTENT_DIRECTORY/dist/*
95
+		cd $SERVICE_CONTENT_DIRECTORY && $MRN_CND_SPY sdist
96
+		if [ $? -ne 0 ];then
97
+			log "\"$MRN_CND_SPY\" tarball creation FAILS, exiting!!!"
98
+			exit 1
99
+		fi
100
+		# Running tarball install
101
+		TRBL_FILE=$(basename `ls $SERVICE_CONTENT_DIRECTORY/dist/murano-agent*.tar.gz`)
102
+		$PIPCMD install $SERVICE_CONTENT_DIRECTORY/dist/$TRBL_FILE
103
+		if [ $? -ne 0 ];then
104
+			log "$PIPCMD install \"$TRBL_FILE\" FAILS, recreate terball with \"python setup.py sdist\" command, exiting!!!"
105
+			exit 1
106
+		fi
107
+		# Creating etc directory for config files
108
+		if [ ! -d $ETC_CFG_DIR ];then
109
+			log "Creating $ETC_CFG_DIR direcory..."
110
+			mkdir -p $ETC_CFG_DIR
111
+			if [ $? -ne 0 ];then
112
+				log "Can't create $ETC_CFG_DIR, exiting!!!"
113
+				exit 1
114
+			fi
115
+		fi
116
+		log "Making sample configuration file at \"$ETC_CFG_DIR\""
117
+		cp -f "$SERVICE_CONTENT_DIRECTORY/etc/agent.conf" "$ETC_CFG_DIR/agent.conf"
118
+	else
119
+		log "$MRN_CND_SPY not found!"
120
+	fi
121
+}
122
+
123
+# searching for service executable in path
124
+get_service_exec_path()
125
+{
126
+	if [ -z "$SERVICE_EXEC_PATH" ]; then
127
+		SERVICE_EXEC_PATH=$(which muranoagent)
128
+		if [ $? -ne 0 ]; then
129
+			log "Can't find \"muranoagent ($SERVICE_SRV_NAME)\", please install the \"$SERVICE_SRV_NAME\" by running \"$(basename "$0") install\" or set variable SERVICE_EXEC_PATH=/path/to/daemon before running setup script, exiting!"
130
+			exit 1
131
+		fi
132
+	else
133
+		if [ ! -x "$SERVICE_EXEC_PATH" ]; then
134
+			log "\"$SERVICE_EXEC_PATH\" in not executable, please install the muranoagent \"($SERVICE_SRV_NAME)\" or set variable SERVICE_EXEC_PATH=/path/to/daemon before running setup script, exiting!"
135
+			exit 1
136
+		fi
137
+	fi
138
+}
139
+
140
+# uninstall
141
+uninst()
142
+{
143
+	# Uninstall trough  pip
144
+	find_pip
145
+	# looking up for python package installed
146
+	PYPKG=$SERVICE_SRV_NAME
147
+	_pkg=$($PIPCMD freeze | grep $PYPKG)
148
+	if [ $? -eq 0 ]; then
149
+		log "Removing package \"$PYPKG\" with pip"
150
+		$PIPCMD uninstall $_pkg --yes
151
+	else
152
+		log "Python package \"$PYPKG\" not found"
153
+	fi
154
+}
155
+
156
+# inject init
157
+injectinit()
158
+{
159
+	log "Enabling $SERVICE_SRV_NAME in init.d..."
160
+	cp -f "$SERVICE_CONTENT_DIRECTORY/init.d/murano-agent-el6" "/etc/init.d/$SERVICE_SRV_NAME"
161
+	sed -i "s/DAEMON=.*/DAEMON=$(echo $SERVICE_EXEC_PATH | sed -e 's/\//\\\//g')/" /etc/init.d/$SERVICE_SRV_NAME
162
+	chmod 755 /etc/init.d/$SERVICE_SRV_NAME
163
+	chkconfig --add $SERVICE_SRV_NAME
164
+	chkconfig $SERVICE_SRV_NAME on
165
+}
166
+
167
+purgeinit()
168
+{
169
+	log "Removing from init.d..."
170
+	chkconfig $SERVICE_SRV_NAME off
171
+	chkconfig --del $SERVICE_SRV_NAME
172
+	rm -f /etc/init.d/$SERVICE_SRV_NAME
173
+	#Fedora compat.
174
+	systemctl --system daemon-reload > /dev/null 2>&1
175
+}
176
+
177
+# Command line args'
178
+COMMAND="$1"
179
+case $COMMAND in
180
+	inject-init )
181
+		get_service_exec_path
182
+		log "Injecting \"$SERVICE_SRV_NAME\" to init..."
183
+		injectinit
184
+		postinst
185
+		;;
186
+
187
+	install )
188
+		inst
189
+		get_service_exec_path
190
+		injectinit
191
+		;;
192
+
193
+	purge-init )
194
+		log "Purging \"$SERVICE_SRV_NAME\" from init..."
195
+		service $SERVICE_SRV_NAME stop
196
+		purgeinit
197
+		;;
198
+
199
+	uninstall )
200
+		log "Uninstalling \"$SERVICE_SRV_NAME\" from system..."
201
+		service $SERVICE_SRV_NAME stop
202
+		purgeinit
203
+		uninst
204
+		;;
205
+
206
+	* )
207
+		echo -e "Usage: $(basename "$0") command \nCommands:\n\tinstall - Install $SERVICE_SRV_NAME software\n\tuninstall - Uninstall $SERVICE_SRV_NAME software\n\tinject-init - Add $SERVICE_SRV_NAME to the system start-up\n\tpurge-init - Remove $SERVICE_SRV_NAME from the system start-up"
208
+		exit 1
209
+		;;
210
+esac

+ 0
- 0
python-agent/setup.py View File


+ 206
- 0
python-agent/setup.sh View File

@@ -0,0 +1,206 @@
1
+#!/bin/sh
2
+#    Copyright (c) 2013 Mirantis, Inc.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+#
16
+#   Ubuntu script
17
+LOGLVL=1
18
+SERVICE_CONTENT_DIRECTORY=`cd $(dirname "$0") && pwd`
19
+PREREQ_PKGS="git wget make gcc python-pip python-iso8601 python-six python-anyjson python-eventlet python-dev python-setuptools"
20
+PIPAPPS="pip python-pip pip-python"
21
+PIPCMD=""
22
+SERVICE_SRV_NAME="murano-agent"
23
+ETC_CFG_DIR="/etc/murano"
24
+
25
+
26
+
27
+# Functions
28
+# Loger function
29
+log()
30
+{
31
+	MSG=$1
32
+	if [ $LOGLVL -gt 0 ]; then
33
+		echo "LOG:> $MSG"
34
+	fi
35
+}
36
+
37
+# find pip
38
+find_pip()
39
+{
40
+	for cmd in $PIPAPPS
41
+	do
42
+		_cmd=$(which $cmd 2>/dev/null)
43
+		if [ $? -eq 0 ];then
44
+			break
45
+		fi
46
+	done
47
+	if [ -z $_cmd ];then
48
+		echo "Can't find \"pip\" in system, please install it first, exiting!"
49
+		exit 1
50
+	else
51
+		PIPCMD=$_cmd
52
+	fi
53
+}
54
+
55
+# Check or install package
56
+in_sys_pkg()
57
+{
58
+	PKG=$1
59
+	dpkg -s $PKG > /dev/null 2>&1
60
+	if [ $? -eq 0 ]; then
61
+		log "Package \"$PKG\" already installed"
62
+	else
63
+		log "Installing \"$PKG\"..."
64
+		apt-get install $PKG --yes > /dev/null 2>&1
65
+		if [ $? -ne 0 ];then
66
+			log "installation fails, exiting!!!"
67
+			exit
68
+		fi
69
+	fi
70
+}
71
+
72
+# install
73
+inst()
74
+{
75
+# Checking packages
76
+	for PKG in $PREREQ_PKGS
77
+	do
78
+		in_sys_pkg $PKG
79
+	done
80
+# Find python pip
81
+	find_pip
82
+	MRN_CND_SPY=$SERVICE_CONTENT_DIRECTORY/setup.py
83
+	if [ -e $MRN_CND_SPY ]; then
84
+		chmod +x $MRN_CND_SPY
85
+		log "$MRN_CND_SPY output:_____________________________________________________________"
86
+## Setup through pip
87
+		# Creating tarball
88
+		rm -rf $SERVICE_CONTENT_DIRECTORY/*.egg-info
89
+		cd $SERVICE_CONTENT_DIRECTORY && python $MRN_CND_SPY egg_info
90
+		if [ $? -ne 0 ];then
91
+			log "\"$MRN_CND_SPY\" egg info creation FAILS, exiting!!!"
92
+			exit 1
93
+		fi
94
+		rm -rf $SERVICE_CONTENT_DIRECTORY/dist/*
95
+		cd $SERVICE_CONTENT_DIRECTORY && $MRN_CND_SPY sdist
96
+		if [ $? -ne 0 ];then
97
+			log "\"$MRN_CND_SPY\" tarball creation FAILS, exiting!!!"
98
+			exit 1
99
+		fi
100
+		# Running tarball install
101
+		TRBL_FILE=$(basename `ls $SERVICE_CONTENT_DIRECTORY/dist/murano-agent*.tar.gz`)
102
+		$PIPCMD install $SERVICE_CONTENT_DIRECTORY/dist/$TRBL_FILE
103
+		if [ $? -ne 0 ];then
104
+			log "$PIPCMD install \"$TRBL_FILE\" FAILS, recreate terball with \"python setup.py sdist\" command, exiting!!!"
105
+			exit 1
106
+		fi
107
+		# Creating etc directory for config files
108
+		if [ ! -d $ETC_CFG_DIR ];then
109
+			log "Creating $ETC_CFG_DIR direcory..."
110
+			mkdir -p $ETC_CFG_DIR
111
+			if [ $? -ne 0 ];then
112
+				log "Can't create $ETC_CFG_DIR, exiting!!!"
113
+				exit 1
114
+			fi
115
+		fi
116
+		log "Making sample configuration file at \"$ETC_CFG_DIR\""
117
+		cp -f "$SERVICE_CONTENT_DIRECTORY/etc/agent.conf" "$ETC_CFG_DIR/agent.conf"
118
+	else
119
+		log "$MRN_CND_SPY not found!"
120
+	fi
121
+}
122
+
123
+# searching for service executable in path
124
+get_service_exec_path()
125
+{
126
+	if [ -z "$SERVICE_EXEC_PATH" ]; then
127
+		SERVICE_EXEC_PATH=$(which muranoagent)
128
+		if [ $? -ne 0 ]; then
129
+			log "Can't find \"muranoagent ($SERVICE_SRV_NAME)\", please install the \"$SERVICE_SRV_NAME\" by running \"$(basename "$0") install\" or set variable SERVICE_EXEC_PATH=/path/to/daemon before running setup script, exiting!"
130
+			exit 1
131
+		fi
132
+	else
133
+		if [ ! -x "$SERVICE_EXEC_PATH" ]; then
134
+			log "\"$SERVICE_EXEC_PATH\" in not executable, please install the muranoagent \"($SERVICE_SRV_NAME)\" or set variable SERVICE_EXEC_PATH=/path/to/daemon before running setup script, exiting!"
135
+			exit 1
136
+		fi
137
+	fi
138
+}
139
+
140
+# uninstall
141
+uninst()
142
+{
143
+	# Uninstall trough  pip
144
+	find_pip
145
+	# looking up for python package installed
146
+	PYPKG=$SERVICE_SRV_NAME
147
+	_pkg=$($PIPCMD freeze | grep $PYPKG)
148
+	if [ $? -eq 0 ]; then
149
+		log "Removing package \"$PYPKG\" with pip"
150
+		$PIPCMD uninstall $_pkg --yes
151
+	else
152
+		log "Python package \"$PYPKG\" not found"
153
+	fi
154
+}
155
+
156
+# inject init
157
+injectinit()
158
+{
159
+	log "Enabling $SERVICE_SRV_NAME in init.d..."
160
+	cp -f "$SERVICE_CONTENT_DIRECTORY/init.d/murano-agent-deb" "/etc/init.d/$SERVICE_SRV_NAME"
161
+	sed -i "s/DAEMON=.*/DAEMON=$(echo $SERVICE_EXEC_PATH | sed -e 's/\//\\\//g')/" /etc/init.d/$SERVICE_SRV_NAME
162
+	chmod 755 /etc/init.d/$SERVICE_SRV_NAME
163
+	update-rc.d $SERVICE_SRV_NAME defaults
164
+}
165
+
166
+purgeinit()
167
+{
168
+	log "Removing from init.d..."
169
+	update-rc.d -f $SERVICE_SRV_NAME remove
170
+	rm -f /etc/init.d/$SERVICE_SRV_NAME
171
+}
172
+
173
+# Command line args'
174
+COMMAND="$1"
175
+case $COMMAND in
176
+	inject-init )
177
+		get_service_exec_path
178
+		log "Injecting \"$SERVICE_SRV_NAME\" to init..."
179
+		injectinit
180
+		postinst
181
+		;;
182
+
183
+	install )
184
+		inst
185
+		get_service_exec_path
186
+		injectinit
187
+		;;
188
+
189
+	purge-init )
190
+		log "Purging \"$SERVICE_SRV_NAME\" from init..."
191
+		service $SERVICE_SRV_NAME stop
192
+		purgeinit
193
+		;;
194
+
195
+	uninstall )
196
+		log "Uninstalling \"$SERVICE_SRV_NAME\" from system..."
197
+		service $SERVICE_SRV_NAME stop
198
+		purgeinit
199
+		uninst
200
+		;;
201
+
202
+	* )
203
+		echo -e "Usage: $(basename "$0") command \nCommands:\n\tinstall - Install $SERVICE_SRV_NAME software\n\tuninstall - Uninstall $SERVICE_SRV_NAME software\n\tinject-init - Add $SERVICE_SRV_NAME to the system start-up\n\tpurge-init - Remove $SERVICE_SRV_NAME from the system start-up"
204
+		exit 1
205
+		;;
206
+esac

Loading…
Cancel
Save