diff --git a/install.sh b/install.sh index 168ad81..cea364d 100644 --- a/install.sh +++ b/install.sh @@ -64,33 +64,63 @@ check_component() { check_existing_installation() { log_step "Проверка существующей установки..." - local apache_status php_status mariadb_status redis_status + local apache_status=2 php_status=2 mariadb_status=2 redis_status=2 local need_reinstall=false # Проверка Apache + log_info "Проверка Apache..." if [ "$DISTRO_FAMILY" = "debian" ]; then - check_component "Apache2" "apache2" "apache2" - apache_status=$? + if command -v apache2 >/dev/null 2>&1; then + if systemctl is-active --quiet apache2 2>/dev/null; then + apache_status=0 + else + apache_status=1 + fi + else + apache_status=2 + fi else - check_component "Apache (httpd)" "httpd" "httpd" - apache_status=$? + if command -v httpd >/dev/null 2>&1; then + if systemctl is-active --quiet httpd 2>/dev/null; then + apache_status=0 + else + apache_status=1 + fi + else + apache_status=2 + fi fi # Проверка PHP - check_component "PHP" "php" "" - php_status=$? + log_info "Проверка PHP..." + if command -v php >/dev/null 2>&1; then + php_status=0 + else + php_status=2 + fi # Проверка MariaDB - check_component "MariaDB" "mysql" "mariadb" - mariadb_status=$? + log_info "Проверка MariaDB..." + if command -v mysql >/dev/null 2>&1; then + if systemctl is-active --quiet mariadb 2>/dev/null; then + mariadb_status=0 + else + mariadb_status=1 + fi + else + mariadb_status=2 + fi # Проверка Redis - check_component "Redis" "redis-server" "redis-server" - if [ $? -eq 2 ]; then - check_component "Redis" "redis-cli" "redis" - redis_status=$? + log_info "Проверка Redis..." + if command -v redis-cli >/dev/null 2>&1; then + if systemctl is-active --quiet redis-server 2>/dev/null || systemctl is-active --quiet redis 2>/dev/null; then + redis_status=0 + else + redis_status=1 + fi else - redis_status=$? + redis_status=2 fi echo "" @@ -104,7 +134,7 @@ check_existing_installation() { case $php_status in 0) - php_version=$(php -v 2>/dev/null | head -1 | cut -d' ' -f2 | cut -d'.' -f1,2) + php_version=$(php -v 2>/dev/null | head -1 | cut -d' ' -f2 | cut -d'.' -f1,2 2>/dev/null || echo "неизвестно") if [[ "$php_version" == "8.3" ]]; then echo -e "PHP: ${GREEN}Установлен (версия $php_version)${NC}" else @@ -752,7 +782,8 @@ log_success "Учетные данные сохранены в $DB_CREDENTIALS_F IP_ADDR=$(hostname -I | awk '{print $1}') -log_success "Установка Altcor успешно завершена" +echo "" +log_success "Установка Altcor успешно завершена." echo "" echo "🌐 Доступ к сайту:" echo " • http://localhost/"