From ec5a01380ae6462ba9dccb549209388aa67e4e39 Mon Sep 17 00:00:00 2001 From: CREATIVE_tg1 Date: Sun, 12 Apr 2026 13:41:40 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20cockpit/cockpit-installer.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cockpit/cockpit-installer.sh | 47 ++++++------------------------------ 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/cockpit/cockpit-installer.sh b/cockpit/cockpit-installer.sh index 77b5d9b..eb9c187 100644 --- a/cockpit/cockpit-installer.sh +++ b/cockpit/cockpit-installer.sh @@ -40,7 +40,6 @@ show_help() { } # ─── Parse arguments ────────────────────────────────────────────────────────── -readonly COCKPIT_PORT=12345 NEW_USER="user" USER_PASSWORD="" TIMEZONE="UTC" @@ -84,13 +83,6 @@ if ! command -v apt &>/dev/null; then fi log_ok "OS check passed" -# ─── Check port is not in use ───────────────────────────────────────────────── -if ss -tlnp | grep -q ":${COCKPIT_PORT} "; then - log_err "Port $COCKPIT_PORT is already in use. The script uses a fixed Cockpit port and cannot continue" - exit 1 -fi -log_ok "Cockpit will use fixed port $COCKPIT_PORT" - # ─── Validate timezone ──────────────────────────────────────────────────────── if ! timedatectl list-timezones | grep -qx "$TIMEZONE"; then log_err "Invalid timezone: '$TIMEZONE'" @@ -126,7 +118,6 @@ else log_info "Using provided password" fi -log_info "Cockpit port : $COCKPIT_PORT" log_info "Username : $NEW_USER" log_info "Timezone : $TIMEZONE" @@ -152,9 +143,9 @@ if ! ufw status | grep -q '22/tcp'; then ufw allow 22/tcp fi -ufw allow "${COCKPIT_PORT}/tcp" +ufw allow 9090/tcp ufw --force enable -log_ok "ufw enabled. Open ports: 22/tcp, ${COCKPIT_PORT}/tcp" +log_ok "ufw enabled. Open ports: 22/tcp, 9090/tcp" # ─── 4. Install fail2ban ────────────────────────────────────────────────────── log_ok "Installing fail2ban..." @@ -172,7 +163,7 @@ port = 22 [cockpit] enabled = true -port = ${COCKPIT_PORT} +port = 9090 filter = cockpit logpath = /var/log/auth.log maxretry = 5 @@ -218,31 +209,7 @@ apt install -y cockpit systemctl enable cockpit.socket systemctl start cockpit.socket -# ─── 7. Change Cockpit port ─────────────────────────────────────────────────── -log_ok "Configuring Cockpit on port $COCKPIT_PORT..." - -mkdir -p /etc/cockpit - -cat > /etc/cockpit/cockpit.conf < /etc/systemd/system/cockpit.socket.d/listen.conf < /etc/cron.d/selfcert-renew <