@@ -5,6 +5,14 @@ REPO="ilyakooo0/skrepka"
5INSTALL_BIN="/usr/local/bin/skrepka-server"
5INSTALL_BIN="/usr/local/bin/skrepka-server"
6UNIT_DEST="/etc/systemd/system/skrepka.service"
6UNIT_DEST="/etc/systemd/system/skrepka.service"
8+DOMAIN="${DOMAIN:-${1:-}}"
10+if [ -z "$DOMAIN" ]; then
11+ echo "error: DOMAIN is required" >&2
12+ echo "usage: DOMAIN=skrepka.example.com sh install.sh" >&2
8if [ "$(id -u)" -ne 0 ]; then
16if [ "$(id -u)" -ne 0 ]; then
9 echo "error: must be run as root" >&2
17 echo "error: must be run as root" >&2
@@ -76,12 +84,30 @@ NoNewPrivileges=yes
76WantedBy=multi-user.target
84WantedBy=multi-user.target
87+ if ! command -v caddy >/dev/null 2>&1; then
88+ echo "Installing Caddy..."
89+ apt-get install -y debian-keyring debian-archive-keyring apt-transport-https curl
90+ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
91+ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
93+ apt-get install -y caddy
97+ cat > /etc/caddy/Caddyfile <<CADDYEOF
99+ reverse_proxy localhost:8080
79 if command -v ufw >/dev/null 2>&1 && ufw status | grep -q "active"; then
103 if command -v ufw >/dev/null 2>&1 && ufw status | grep -q "active"; then
80− echo "Opening port 8080 (ufw)..."
104+ echo "Opening ports 80, 443 (ufw)..."
81− ufw allow 8080/tcp
105+ ufw allow 80/tcp
82 elif command -v firewall-cmd >/dev/null 2>&1 && systemctl is-active --quiet firewalld; then
107 elif command -v firewall-cmd >/dev/null 2>&1 && systemctl is-active --quiet firewalld; then
83− echo "Opening port 8080 (firewalld)..."
108+ echo "Opening ports 80, 443 (firewalld)..."
84− firewall-cmd --add-port=8080/tcp --permanent
109+ firewall-cmd --add-port=80/tcp --permanent
110+ firewall-cmd --add-port=443/tcp --permanent
85 firewall-cmd --reload
111 firewall-cmd --reload
@@ -94,6 +120,9 @@ EOF
94 systemctl enable --now skrepka
120 systemctl enable --now skrepka
95 echo "Service enabled and started."
121 echo "Service enabled and started."
124+ systemctl restart caddy
125+ echo "Caddy configured for https://${DOMAIN}"
97 echo "Check status with: systemctl status skrepka"
126 echo "Check status with: systemctl status skrepka"