From 1a26eda9cfd0315bec158f466cabb47d517c32b4 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 30 Aug 2019 12:32:03 +0200 Subject: [PATCH 1/4] change is_this_installed --- lib.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib.sh b/lib.sh index 81ec514..d6a9e7f 100644 --- a/lib.sh +++ b/lib.sh @@ -220,10 +220,11 @@ local PROMPT="$1" # Check if program is installed (is_this_installed apache2) is_this_installed() { -if [ "$(dpkg-query -W -f='${Status}' "${1}" 2>/dev/null | grep -c "ok installed")" == "1" ] +if dpkg-query -W -f='${Status}' "${1}" | grep -q "ok installed" then - print_text_in_color "$IRed" "${1} is installed, it must be a clean server." - exit 1 + return 0 +else + return 1 fi } From 3eb79724c7e3ecc7c3b1506d830b8949c96706da Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 30 Aug 2019 12:34:22 +0200 Subject: [PATCH 2/4] add stop_is_installed --- lib.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib.sh b/lib.sh index d6a9e7f..d49a6ea 100644 --- a/lib.sh +++ b/lib.sh @@ -218,6 +218,15 @@ local PROMPT="$1" whiptail --msgbox "${PROMPT}" "$WT_HEIGHT" "$WT_WIDTH" } +# Check if program is installed (stop_if_installed apache2) +stop_if_installed() { +if [ "$(dpkg-query -W -f='${Status}' "${1}" 2>/dev/null | grep -c "ok installed")" == "1" ] +then + print_text_in_color "$IRed" "${1} is installed, it must be a clean server." + exit 1 +fi +} + # Check if program is installed (is_this_installed apache2) is_this_installed() { if dpkg-query -W -f='${Status}' "${1}" | grep -q "ok installed" From a4d7c00dc9afb06772edd9329b4db0d6aac465ec Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 30 Aug 2019 12:37:05 +0200 Subject: [PATCH 3/4] Update wordpress_install.sh --- wordpress_install.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wordpress_install.sh b/wordpress_install.sh index d8e93c3..0afbfea 100644 --- a/wordpress_install.sh +++ b/wordpress_install.sh @@ -54,12 +54,12 @@ if ! version 18.04 "$DISTRO" 18.04.4; then fi # Check if it's a clean server -is_this_installed postgresql -is_this_installed apache2 -is_this_installed nginx -is_this_installed php -is_this_installed mysql-common -is_this_installed mariadb-server +stop_if_installed postgresql +stop_if_installed apache2 +stop_if_installed nginx +stop_if_installed php +stop_if_installed mysql-common +stop_if_installed mariadb-server # Create $SCRIPTS dir if [ ! -d "$SCRIPTS" ] From a0075f573dba4fb94280f2617d9bd950030b8b7f Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Fri, 30 Aug 2019 12:39:03 +0200 Subject: [PATCH 4/4] Update lib.sh --- lib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib.sh b/lib.sh index d49a6ea..ad5b8a5 100644 --- a/lib.sh +++ b/lib.sh @@ -239,7 +239,7 @@ fi # Install_if_not program install_if_not () { -if [[ "$(is_this_installed "${1}")" != "${1} is installed, it must be a clean server." ]] +if [[ "$(stop_if_installed "${1}")" != "${1} is installed, it must be a clean server." ]] then apt update -q4 & spinner_loading && apt install "${1}" -y fi