Skip to content

Commit 0ee09ee

Browse files
authored
change is_this_installed (#52)
1 parent ccce665 commit 0ee09ee

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

lib.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,18 +218,28 @@ local PROMPT="$1"
218218
whiptail --msgbox "${PROMPT}" "$WT_HEIGHT" "$WT_WIDTH"
219219
}
220220

221-
# Check if program is installed (is_this_installed apache2)
222-
is_this_installed() {
221+
# Check if program is installed (stop_if_installed apache2)
222+
stop_if_installed() {
223223
if [ "$(dpkg-query -W -f='${Status}' "${1}" 2>/dev/null | grep -c "ok installed")" == "1" ]
224224
then
225225
print_text_in_color "$IRed" "${1} is installed, it must be a clean server."
226226
exit 1
227227
fi
228228
}
229229

230+
# Check if program is installed (is_this_installed apache2)
231+
is_this_installed() {
232+
if dpkg-query -W -f='${Status}' "${1}" | grep -q "ok installed"
233+
then
234+
return 0
235+
else
236+
return 1
237+
fi
238+
}
239+
230240
# Install_if_not program
231241
install_if_not () {
232-
if [[ "$(is_this_installed "${1}")" != "${1} is installed, it must be a clean server." ]]
242+
if [[ "$(stop_if_installed "${1}")" != "${1} is installed, it must be a clean server." ]]
233243
then
234244
apt update -q4 & spinner_loading && apt install "${1}" -y
235245
fi

wordpress_install.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ if ! version 18.04 "$DISTRO" 18.04.4; then
5454
fi
5555

5656
# Check if it's a clean server
57-
is_this_installed postgresql
58-
is_this_installed apache2
59-
is_this_installed nginx
60-
is_this_installed php
61-
is_this_installed mysql-common
62-
is_this_installed mariadb-server
57+
stop_if_installed postgresql
58+
stop_if_installed apache2
59+
stop_if_installed nginx
60+
stop_if_installed php
61+
stop_if_installed mysql-common
62+
stop_if_installed mariadb-server
6363

6464
# Create $SCRIPTS dir
6565
if [ ! -d "$SCRIPTS" ]

0 commit comments

Comments
 (0)