Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,28 @@ local PROMPT="$1"
whiptail --msgbox "${PROMPT}" "$WT_HEIGHT" "$WT_WIDTH"
}

# Check if program is installed (is_this_installed apache2)
is_this_installed() {
# 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"
then
return 0
else
return 1
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
Expand Down
12 changes: 6 additions & 6 deletions wordpress_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand Down