Return setup scripts in the consistent state
Change-Id: I853f598ef348e339d9cf9522a94d019ac538b462
This commit is contained in:
parent
ff91a8a8a9
commit
91781f1fb8
@ -17,7 +17,7 @@ function log {
|
||||
if [ "$DEBUGLVL" -gt 0 ]; then
|
||||
chars=$(echo "@$" | wc -c)
|
||||
case $DEBUGLVL in
|
||||
1 )
|
||||
1)
|
||||
echo -e "LOG:>$@"
|
||||
;;
|
||||
2)
|
||||
|
4
etc/init.d/README.rst
Normal file
4
etc/init.d/README.rst
Normal file
@ -0,0 +1,4 @@
|
||||
SysV init scripts
|
||||
=====================
|
||||
murano-api-redhat - for RedHat based Linux distibution
|
||||
murano-api-debian - for Debian based Linux distibution
|
@ -1,102 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Copyright (c) 2013 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# Author: Igor Yozhikov <iyozhikov@mirantis.com>
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: murano-api
|
||||
# Required-Start: $network $local_fs $remote_fs $syslog
|
||||
# Required-Stop: $remote_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: OpenStack Murano API Server
|
||||
# Description: This startup script launches murano-api service daemon.
|
||||
### END INIT INFO
|
||||
# chkconfig: 3 90 10
|
||||
# description: This startup script launches murano-api service daemon.
|
||||
# config: /etc/murano/murano-api.conf, /etc/murano/murano-api-paste.ini
|
||||
#
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
|
||||
DESC="murano-api"
|
||||
NAME=murano-api
|
||||
DAEMON=$(which murano-api)
|
||||
PIDFILE=/var/run/murano/$NAME.pid
|
||||
SCRIPTNAME=/etc/init.d/openstack-$NAME
|
||||
SYSTEM_USER=murano
|
||||
CONFIG_FILE=/etc/murano/murano-api.conf
|
||||
LOCKFILE=/var/lock/subsys/$NAME
|
||||
# Exit if the package is not installed
|
||||
[ -x $DAEMON ] || exit 5
|
||||
|
||||
# source function library
|
||||
. /etc/init.d/functions
|
||||
|
||||
RETVAL=0
|
||||
|
||||
|
||||
start() {
|
||||
if [ ! -d "/var/run/murano" ]; then
|
||||
mkdir -p /var/run/murano
|
||||
chown -R $SYSTEM_USER /var/run/murano
|
||||
fi
|
||||
echo -n "Starting $NAME: "
|
||||
daemon --user $SYSTEM_USER "$DAEMON --config-file=$CONFIG_FILE &>/dev/null & echo \$! > $PIDFILE"
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && touch $LOCKFILE
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n "Stopping $NAME: "
|
||||
#killproc $DAEMON -TERM
|
||||
killproc -p $PIDFILE $DAEMON
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
rh_status() {
|
||||
# run checks to determine if the service is running or use generic status
|
||||
status $DAEMON
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
|
||||
restart)
|
||||
restart
|
||||
;;
|
||||
|
||||
status)
|
||||
rh_status
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart}"
|
||||
exit 2
|
||||
esac
|
||||
exit $?
|
21
setup.sh
21
setup.sh
@ -196,11 +196,12 @@ function inject_init()
|
||||
retval=0
|
||||
_dist=$(lowercase $DISTRO_BASED_ON)
|
||||
eval src_init_sctipt="$DAEMON_NAME-$_dist"
|
||||
_initscript="openstack-$DAEMON_NAME"
|
||||
_initscript="$DAEMON_NAME"
|
||||
cp -f "$RUN_DIR/etc/init.d/$src_init_sctipt" "/etc/init.d/$_initscript" || retval=$?
|
||||
chmod +x "/etc/init.d/$_initscript" || retval=$?
|
||||
iniset '' 'SYSTEM_USER' "$DAEMON_USER" "/etc/init.d/$_initscript"
|
||||
iniset '' 'DAEMON' "$(shslash $SERVICE_EXEC_PATH)" "/etc/init.d/$_initscript"
|
||||
iniset '' 'SCRIPTNAME' "$(shslash "/etc/init.d/$_initscript")" "/etc/init.d/$_initscript"
|
||||
case $_dist in
|
||||
"debian")
|
||||
update-rc.d $_initscript defaults || retval=$?
|
||||
@ -217,7 +218,7 @@ function purge_init()
|
||||
{
|
||||
retval=0
|
||||
_dist=$(lowercase $DISTRO_BASED_ON)
|
||||
_initscript="openstack-$DAEMON_NAME"
|
||||
_initscript="$DAEMON_NAME"
|
||||
service $_initscript stop
|
||||
if [ $? -ne 0 ]; then
|
||||
retval=1
|
||||
@ -267,14 +268,20 @@ function install_daemon()
|
||||
_src_conf_dir="$RUN_DIR/etc/murano"
|
||||
for file in $(ls $_src_conf_dir)
|
||||
do
|
||||
cp -f "$_src_conf_dir/$file" "$DAEMON_CFG_DIR/$file.sample"
|
||||
if [ ! -e "$DAEMON_CFG_DIR/$file" ]; then
|
||||
log "\"$DAEMON_CFG_DIR/$file\" exists."
|
||||
cp -f "$_src_conf_dir/$file" "$DAEMON_CFG_DIR/$file"
|
||||
#cp -f "$_src_conf_dir/$file" "$DAEMON_CFG_DIR/$file.sample"
|
||||
cp -f "$_src_conf_dir/$file" "$DAEMON_CFG_DIR/$file"
|
||||
config_file=$_prefix$(echo $file | sed -e 's/.sample$//')
|
||||
#if [ ! -e "$DAEMON_CFG_DIR/$file" ]; then
|
||||
if [ ! -e "$DAEMON_CFG_DIR/$config_file" ]; then
|
||||
cp -f "$_src_conf_dir/$file" "$DAEMON_CFG_DIR/$config_file"
|
||||
else
|
||||
log "\"$DAEMON_CFG_DIR/$config_file\" exists, skipping copy."
|
||||
fi
|
||||
done
|
||||
log "Setting log file and sqlite db placement..."
|
||||
iniset 'DEFAULT' 'log_file' "$(shslash $DAEMON_LOG_DIR/$DAEMON_NAME.log)" "$DAEMON_CFG_DIR/$DAEMON_NAME.conf"
|
||||
iniset 'DEFAULT' 'verbose' 'True' "$DAEMON_CFG_DIR/$DAEMON_NAME.conf"
|
||||
iniset 'DEFAULT' 'debug' 'True' "$DAEMON_CFG_DIR/$DAEMON_NAME.conf"
|
||||
iniset 'database' 'connection' "$(shslash $DAEMON_DB_CONSTR)" "$DAEMON_CFG_DIR/$DAEMON_NAME.conf"
|
||||
log "Searching daemon in \$PATH..."
|
||||
get_service_exec_path || exit $?
|
||||
@ -286,7 +293,7 @@ function install_daemon()
|
||||
iniset 'database' 'connection' "$(shslash $DAEMON_DB_CONSTR)" "$DAEMON_CFG_DIR/$DAEMON_NAME.conf"
|
||||
log "...database configuration finished."
|
||||
fi
|
||||
log "Everything done, please, verify \"$DAEMON_CFG_DIR/$DAEMON_NAME.conf\", service created as \"openstack-murano-api\"."
|
||||
log "Everything done, please, verify \"$DAEMON_CFG_DIR/$DAEMON_NAME.conf\", service created as \"murano-api\"."
|
||||
}
|
||||
function uninstall_daemon()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user