diff --git a/install.sh b/install.sh index bde71cb..659c3de 100644 --- a/install.sh +++ b/install.sh @@ -314,55 +314,23 @@ echo ""; EOF } -if ! curl -f -s --max-time 10 --head "$DOWNLOAD_URL" >/dev/null 2>&1; then - create_fallback_index -else - find "$WEBROOT" -type f ! -name "db_config.php" -delete 2>/dev/null || true - - if curl -f -L --max-time 30 -o "$TEMP_DOWNLOAD" "$DOWNLOAD_URL" 2>/dev/null; then - - FILE_TYPE=$(file -b "$TEMP_DOWNLOAD" 2>/dev/null || echo "unknown") - - if file "$TEMP_DOWNLOAD" | grep -qi "zip\|archive"; then - if unzip -q "$TEMP_DOWNLOAD" -d "$WEBROOT" 2>/dev/null; then - true - else - unzip -o "$TEMP_DOWNLOAD" -d "$WEBROOT" >/dev/null 2>&1 || create_fallback_index - fi - - elif file "$TEMP_DOWNLOAD" | grep -qi "gzip"; then - if gunzip -c "$TEMP_DOWNLOAD" > "$WEBROOT/index.php" 2>/dev/null; then - true - else - create_fallback_index - fi - - elif head -n 1 "$TEMP_DOWNLOAD" | grep -q "/dev/null; then - cp "$TEMP_DOWNLOAD" "$WEBROOT/downloaded_file" - rm -f "$TEMP_DOWNLOAD" - fi - +find "$WEBROOT" -type f ! -name "db_config.php" -delete 2>/dev/null || true + +if curl -f -L --max-time 30 -o "$WEBROOT/index.php" "$DOWNLOAD_URL" 2>/dev/null; then + if ! head -n 1 "$WEBROOT/index.php" | grep -q "/dev/null; then create_fallback_index + log_error "Скачанный файл не является PHP-скриптом, создана резервная страница" + else + log_success "Файл index.php успешно загружен" fi +else + create_fallback_index + log_error "Не удалось загрузить файл с $DOWNLOAD_URL, создана резервная страница" fi +chown $WEBSERVER_USER:$WEBSERVER_USER "$WEBROOT/index.php" +chmod 644 "$WEBROOT/index.php" + cat > "$WEBROOT/.htaccess" << 'EOF' Require all denied