More Sonarqube fixes for Linux

This commit is contained in:
Dave Page 2022-08-10 15:54:51 +01:00
parent c0c4524ec3
commit 0f11033989
2 changed files with 12 additions and 16 deletions

View File

@ -15,7 +15,7 @@ _setup_env() {
APP_NAME=$(grep "^APP_NAME" web/config.py | cut -d"=" -f2 | sed "s/'//g" | sed 's/^ //' | sed 's/ //g' | tr '[:upper:]' '[:lower:]') APP_NAME=$(grep "^APP_NAME" web/config.py | cut -d"=" -f2 | sed "s/'//g" | sed 's/^ //' | sed 's/ //g' | tr '[:upper:]' '[:lower:]')
APP_LONG_VERSION=${APP_RELEASE}.${APP_REVISION} APP_LONG_VERSION=${APP_RELEASE}.${APP_REVISION}
APP_SUFFIX=$(grep "^APP_SUFFIX" web/config.py | cut -d"=" -f2 | sed 's/ //g' | sed "s/'//g") APP_SUFFIX=$(grep "^APP_SUFFIX" web/config.py | cut -d"=" -f2 | sed 's/ //g' | sed "s/'//g")
if [ ! -z ${APP_SUFFIX} ]; then if [ -n "${APP_SUFFIX}" ]; then
APP_LONG_VERSION=${APP_LONG_VERSION}-${APP_SUFFIX} APP_LONG_VERSION=${APP_LONG_VERSION}-${APP_SUFFIX}
fi fi
} }
@ -114,7 +114,7 @@ _create_python_virtualenv() {
# Link the python<version> directory to python so that the private environment path is found by the application. # Link the python<version> directory to python so that the private environment path is found by the application.
if test -d "${DIR_PYMODULES_PATH}"; then if test -d "${DIR_PYMODULES_PATH}"; then
ln -s $(basename "${DIR_PYMODULES_PATH}") "${DIR_PYMODULES_PATH}/../python" ln -s "$(basename "${DIR_PYMODULES_PATH}")" "${DIR_PYMODULES_PATH}/../python"
fi fi
} }
@ -193,7 +193,8 @@ _build_docs() {
cd "${SOURCEDIR}/docs/en_US" || exit cd "${SOURCEDIR}/docs/en_US" || exit
python3 build_code_snippet.py python3 build_code_snippet.py
SYS_PYTHONPATH=$(/usr/bin/python3 -c "import sys; print(':'.join([p for p in sys.path if p]))") SYS_PYTHONPATH=$(/usr/bin/python3 -c "import sys; print(':'.join([p for p in sys.path if p]))")
if [ $1 == "redhat" ] && [ "${OS_VERSION}" == "7" ]; then # shellcheck disable=SC2154
if [ "$1" == "redhat" ] && [ "${OS_VERSION}" == "7" ]; then
PYTHONPATH=$PYTHONPATH:${SYS_PYTHONPATH} python3 /usr/local/bin/sphinx-build . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html" PYTHONPATH=$PYTHONPATH:${SYS_PYTHONPATH} python3 /usr/local/bin/sphinx-build . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html"
else else
PYTHONPATH=$PYTHONPATH:${SYS_PYTHONPATH} python3 -msphinx . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html" PYTHONPATH=$PYTHONPATH:${SYS_PYTHONPATH} python3 -msphinx . "${SERVERROOT}/usr/${APP_NAME}/share/docs/en_US/html"

View File

@ -20,7 +20,7 @@ IS_SUSE=0
UNAME=$(uname -a) UNAME=$(uname -a)
# Get the distro from the environment # Get the distro from the environment
if [ "x${PGADMIN_PLATFORM_TYPE}" == "x" ]; then if [ "${PGADMIN_PLATFORM_TYPE}" == "" ]; then
if [ -f /etc/redhat-release ]; then if [ -f /etc/redhat-release ]; then
PLATFORM_TYPE=redhat PLATFORM_TYPE=redhat
elif [[ ${UNAME} =~ "Ubuntu" ]] || [[ ${UNAME} =~ "Debian" ]] || [ -f /etc/apt/sources.list ]; then elif [[ ${UNAME} =~ "Ubuntu" ]] || [[ ${UNAME} =~ "Debian" ]] || [ -f /etc/apt/sources.list ]; then
@ -72,9 +72,7 @@ fi
# Run setup script first: # Run setup script first:
echo "Creating configuration database..." echo "Creating configuration database..."
/usr/pgadmin4/venv/bin/python3 /usr/pgadmin4/web/setup.py if ! /usr/pgadmin4/venv/bin/python3 /usr/pgadmin4/web/setup.py;
if [ $? != 0 ]
then then
echo "Error setting up server mode. Please examine the output above." echo "Error setting up server mode. Please examine the output above."
exit 1 exit 1
@ -108,7 +106,7 @@ if [ ${IS_DEBIAN} == 1 ]; then
if [ ${AUTOMATED} == 1 ]; then if [ ${AUTOMATED} == 1 ]; then
RESPONSE=Y RESPONSE=Y
else else
read -p "We can now configure the Apache Web server for you. This involves enabling the wsgi module and configuring the pgAdmin 4 application to mount at /pgadmin4. Do you wish to continue (y/n)? " RESPONSE read -r -p "We can now configure the Apache Web server for you. This involves enabling the wsgi module and configuring the pgAdmin 4 application to mount at /pgadmin4. Do you wish to continue (y/n)? " RESPONSE
fi fi
case ${RESPONSE} in case ${RESPONSE} in
@ -121,12 +119,11 @@ if [ ${IS_DEBIAN} == 1 ]; then
esac esac
fi fi
ps cax | grep ${APACHE} > /dev/null if pgrep ${APACHE} > /dev/null; then
if [ $? -eq 0 ]; then
if [ ${AUTOMATED} == 1 ]; then if [ ${AUTOMATED} == 1 ]; then
RESPONSE=Y RESPONSE=Y
else else
read -p "The Apache web server is running and must be restarted for the pgAdmin 4 installation to complete. Continue (y/n)? " RESPONSE read -r -p "The Apache web server is running and must be restarted for the pgAdmin 4 installation to complete. Continue (y/n)? " RESPONSE
fi fi
case ${RESPONSE} in case ${RESPONSE} in
@ -144,20 +141,18 @@ else
if [ ${AUTOMATED} == 1 ]; then if [ ${AUTOMATED} == 1 ]; then
RESPONSE=Y RESPONSE=Y
else else
read -p "The Apache web server is not running. We can enable and start the web server for you to finish pgAdmin 4 installation. Continue (y/n)? " RESPONSE read -r -p "The Apache web server is not running. We can enable and start the web server for you to finish pgAdmin 4 installation. Continue (y/n)? " RESPONSE
fi fi
case ${RESPONSE} in case ${RESPONSE} in
y|Y ) y|Y )
systemctl enable ${APACHE} if ! systemctl enable ${APACHE}; then
if [ $? != 0 ]; then
echo "Error enabling ${APACHE}. Please check the systemd logs" echo "Error enabling ${APACHE}. Please check the systemd logs"
else else
echo "Apache successfully enabled." echo "Apache successfully enabled."
fi fi
systemctl start ${APACHE} if ! systemctl start ${APACHE}; then
if [ $? != 0 ]; then
echo "Error starting ${APACHE}. Please check the systemd logs" echo "Error starting ${APACHE}. Please check the systemd logs"
else else
echo "Apache successfully started." echo "Apache successfully started."