Skip to content

Commit

Permalink
Merge pull request openbaton#55 from openbaton/fix-screen
Browse files Browse the repository at this point in the history
Fix: fix the check for openbaton existing screens
  • Loading branch information
lorenzotomasini authored Dec 13, 2017
2 parents cada87d + 76ddd18 commit 9657b40
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions generic-vnfm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ _openbaton_base="/opt/openbaton"
_generic_base="${_openbaton_base}/generic-vnfm"
_openbaton_config_file="/etc/openbaton/openbaton-vnfm-generic.properties"
_version=${version}
_version="5.1.1-SNAPSHOT"
_screen_session_name="openbaton"
_screen_name="generic-vnfm"


Expand Down Expand Up @@ -72,36 +74,36 @@ function start {
fi
check_rabbitmq
check_already_running
screen_exists=$(screen -ls | grep openbaton | wc -l);
if [ "${screen_exists}" -eq "0" ]; then

if [ "${1}" == "true" ]; then
if [ -f ${_openbaton_config_file} ]; then
if [ "${1}" == "true" ]; then
java -jar "${_generic_base}/build/libs/generic-vnfm-${_version}.jar" --spring.config.location=file:${_openbaton_config_file}
else
echo "Starting the Generic-VNFM in a new screen session (attach to the screen with screen -x openbaton)"
screen -c screenrc -d -m -S openbaton -t ${_screen_name} java -jar "${_generic_base}/build/libs/generic-vnfm-${_version}.jar" --spring.config.location=file:${_openbaton_config_file}
fi
java -jar "${_generic_base}/build/libs/generic-vnfm-${_version}.jar" --spring.config.location=file:${_openbaton_config_file}
else
if [ "${1}" == "true" ]; then
java -jar "${_generic_base}/build/libs/generic-vnfm-${_version}.jar"
else
screen -c screenrc -d -m -S openbaton -t ${_screen_name} java -jar "${_generic_base}/build/libs/generic-vnfm-${_version}.jar"
fi
java -jar "${_generic_base}/build/libs/generic-vnfm-${_version}.jar"
fi
else
echo "Starting the Generic-VNFM in the existing screen session (attach to the screen with screen -x openbaton)"
if [ -f ${_openbaton_config_file} ]; then
screen -S openbaton -X screen -t ${_screen_name} java -jar "${_generic_base}/build/libs/generic-vnfm-${_version}.jar" --spring.config.location=file:${_openbaton_config_file}
screen_exists=$(screen -ls | grep "\.${_screen_session_name}" | wc -l);
if [ "${screen_exists}" -eq "0" ]; then
echo "Starting the Generic-VNFM in a new screen session (attach to the screen with screen -x openbaton)"
if [ -f ${_openbaton_config_file} ]; then
screen -c screenrc -d -m -S ${_screen_session_name} -t ${_screen_name} java -jar "${_generic_base}/build/libs/generic-vnfm-${_version}.jar" --spring.config.location=file:${_openbaton_config_file}
else
screen -c screenrc -d -m -S ${_screen_session_name} -t ${_screen_name} java -jar "${_generic_base}/build/libs/generic-vnfm-${_version}.jar"
fi
else
screen -S openbaton -X screen -t ${_screen_name} java -jar "${_generic_base}/build/libs/generic-vnfm-${_version}.jar"
echo "Starting the Generic-VNFM in the existing screen session (attach to the screen with screen -x openbaton)"
if [ -f ${_openbaton_config_file} ]; then
screen -S ${_screen_session_name} -X screen -t ${_screen_name} java -jar "${_generic_base}/build/libs/generic-vnfm-${_version}.jar" --spring.config.location=file:${_openbaton_config_file}
else
screen -S ${_screen_session_name} -X screen -t ${_screen_name} java -jar "${_generic_base}/build/libs/generic-vnfm-${_version}.jar"
fi
fi
fi
}

function stop {
if screen -list | grep "openbaton" > /dev/null ; then
screen -S openbaton -p ${_screen_name} -X stuff '\003'
if screen -list | grep "\.${_screen_session_name}" > /dev/null ; then
screen -S ${_screen_session_name} -p ${_screen_name} -X stuff '\003'
fi
}

Expand Down

0 comments on commit 9657b40

Please sign in to comment.