I am trying to understand why a bash script seems to stop its execution at an if
statement. I have added echo statements in the scripts.
I have a first batch called make.sh
:
#!/bin/bash
export OPENSHIFT_RUNTIME_DIR=${OPENSHIFT_HOMEDIR}/app-root/runtime
export ROOT_DIR=${OPENSHIFT_RUNTIME_DIR} #CARTRIDGE
export LIB_DIR=${ROOT_DIR}/lib
export CONF_DIR=${OPENSHIFT_REPO_DIR}/conf
export DIST_PHP_VER=5.6.11
pushd ${OPENSHIFT_REPO_DIR}/misc
chmod +x make_php
echo 'before source make_php'
source make_php
echo 'before check_all'
check_all
popd
The make_php
script is:
#!/bin/bash
function install_php() {
...
}
function check_php() {
echo 'entering check php'
if [[ -x $OPENSHIFT_RUNTIME_DIR/bin/php-cgi ]] ; then
echo 'entering check php between if'
if [[ "`$OPENSHIFT_RUNTIME_DIR/bin/php-cgi`" =~ "${DIST_PHP_VER}" ]] ; then
echo 'leaving check php return 0'
return 0
fi
fi
echo "Check PHP ${DIST_PHP_VER} Failed. Start installing"
install_php
}
function check_composer() {
echo 'entering check composer'
...
echo 'leaving check composer'
}
function check_all() {
echo 'entering check all'
check_php
echo 'after check php'
check_composer
echo 'after composer'
}
When I execute ./make.sh
, the output is:
before source make_php
entering check all
entering check php
entering check php between if
and I don't get the prompt back, I have to CTRL-C
What could be causing this issue? And how to solve it?
UPDATE
When I go to $OPENSHIFT_RUNTIME_DIR/bin/ and execute php-cgi, the program locks... This could explain the issue.