#!/bin/bash nginx_config="/etc/nginx/sites-enabled/default" printmsg () { echo $1 | systemd-cat -p $2 -t "appliance-bootstrap" } # Проверка наличия файла конфигурации if [[ ! -f "$nginx_config" ]]; then printmsg "Error: File does not exist: $nginx_config" "err" exit 1 fi port=$(grep -oP 'listen \[::\]:\K[0-9]+(?= default_server;)' "$nginx_config") if [[ -n "$port" ]]; then echo $port else echo 0 fi