Skip to content

Commit 1979fab

Browse files
committed
task: set conditional check if php is already installed
1 parent ab26f35 commit 1979fab

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
## Script status
1212

13-
Version: v3.1.1.884
14-
Build: 884
13+
Version: v3.1.1.885
14+
Build: 885
1515

1616
[![MIT License](https://img.shields.io/badge/license-MIT%20License-blue.svg?style=flat-square)](https://github.com/JMSDOnline/vstacklet/blob/main/LICENSE)
1717

docs/setup/vstacklet-server-stack.sh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# vstacklet-server-stack.sh - v3.1.2177
1+
# vstacklet-server-stack.sh - v3.1.2180
22

33

44
---

setup/vstacklet-server-stack.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
##################################################################################
33
# <START METADATA>
44
# @file_name: vstacklet-server-stack.sh
5-
# @version: 3.1.2177
5+
# @version: 3.1.2180
66
# @description: Lightweight script to quickly install a LEMP stack with Nginx,
77
# Varnish, PHP7.4/8.1/8.3 (PHP-FPM), OPCode Cache, IonCube Loader, MariaDB, Sendmail
88
# and more on a fresh Ubuntu 20.04/22.04 or Debian 11/12 server for
@@ -483,17 +483,19 @@ vstacklet::args::process() {
483483
if [[ -n ${domain_ssl} ]]; then
484484
# @script-note: check if nginx and/or php is installed
485485
nginx_installed=$(dpkg-query -W -f='${Status}' nginx 2>/dev/null | grep -c "ok installed")
486-
php_installed=$(ls -d /etc/php/* 2>/dev/null | wc -l)
486+
php_installed=$(find /etc/php -maxdepth 1 -type d -name "*" | wc -l)
487487
[[ -z ${email} ]] && vstacklet::shell::text::error "please provide an email address with \`-e\`." && exit 1
488488
[[ -z ${nginx} && ${nginx_installed} -eq 0 ]] && vstacklet::shell::text::error "nginx is required to install an SSL certificate. please install nginx with \`-nginx\`." && exit 1
489489
[[ -z ${php} && ${php_installed} -eq 0 ]] && vstacklet::shell::text::error "php is required to install an SSL certificate. please install php with \`-php \"7.4\"\`, \`-php \"8.1\"\` or \`-php \"8.3\"\`." && exit 1
490490
fi
491-
[[ ${php} == *"7"* ]] && declare -g php="7.4"
492-
[[ ${php} == *"8.1"* ]] && declare -g php="8.1"
493-
[[ ${php} == *"8.3"* ]] && declare -g php="8.3"
494-
declare -a allowed_php=("7.4" "8.1" "8.3")
495-
if ! vstacklet::array::contains "${php}" "supported php versions" ${allowed_php[@]}; then
496-
vstacklet::shell::text::error "please provide a valid php version. supported versions are: ${allowed_php[*]}" && exit 1
491+
if [[ ${php_installed} -eq 0 ]]; then
492+
[[ ${php} == *"7"* ]] && declare -g php="7.4"
493+
[[ ${php} == *"8.1"* ]] && declare -g php="8.1"
494+
[[ ${php} == *"8.3"* ]] && declare -g php="8.3"
495+
declare -a allowed_php=("7.4" "8.1" "8.3")
496+
if ! vstacklet::array::contains "${php}" "supported php versions" ${allowed_php[@]}; then
497+
vstacklet::shell::text::error "please provide a valid php version. supported versions are: ${allowed_php[*]}" && exit 1
498+
fi
497499
fi
498500
[[ ${#invalid_option[@]} -gt 0 ]] && vstacklet::shell::text::error "invalid option(s): ${invalid_option[*]}" && exit 1
499501
# @script-note: set default arguments on options

0 commit comments

Comments
 (0)