mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
deploy-nginx: add recipe, upload scripts to /tmp, print sudo instructions
This commit is contained in:
@@ -2,17 +2,24 @@
|
||||
# One-time server setup for Post-ERG
|
||||
# Run this before the first deploy (or after a permission reset).
|
||||
#
|
||||
# Usage: ssh posterg "sudo bash /tmp/setup-server.sh"
|
||||
# Or: just setup-server
|
||||
#
|
||||
# What it does:
|
||||
# 1. Creates /var/www/posterg with correct ownership and permissions
|
||||
# 2. Ensures the deploy user is in the posterg group
|
||||
# 3. Sets sticky group bit (setgid) on all directories so new files
|
||||
# inherit the posterg group — required for rsync --chown to work
|
||||
# Usage: just setup-server
|
||||
# or: sudo DEPLOY_USER=youruser bash /tmp/setup-server.sh
|
||||
|
||||
set -e
|
||||
|
||||
# ── Colors / helpers ──────────────────────────────────────────────────────────
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
ok() { printf "${GREEN}✓${NC} %s\n" "$*"; }
|
||||
warn() { printf "${YELLOW}!${NC} %s\n" "$*"; }
|
||||
die() { printf "${RED}✗${NC} %s\n" "$*" >&2; exit 1; }
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
[ "$EUID" -eq 0 ] || die "Run as root (sudo)"
|
||||
|
||||
# ── Config ────────────────────────────────────────────────────────────────────
|
||||
# DEPLOY_USER is passed explicitly by the justfile (read from ~/.ssh/config via
|
||||
# `ssh -G posterg`). Falls back to $SUDO_USER if run manually with sudo.
|
||||
@@ -23,20 +30,8 @@ APP_GROUP="posterg"
|
||||
WEB_USER="www-data"
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
ok() { echo -e "${GREEN}✓${NC} $*"; }
|
||||
warn() { echo -e "${YELLOW}!${NC} $*"; }
|
||||
die() { echo -e "${RED}✗${NC} $*" >&2; exit 1; }
|
||||
|
||||
[ "$EUID" -eq 0 ] || die "Run as root (sudo)"
|
||||
|
||||
echo "🔧 Post-ERG Server Setup"
|
||||
echo "========================"
|
||||
echo ""
|
||||
printf "🔧 Post-ERG Server Setup\n"
|
||||
printf "========================\n\n"
|
||||
|
||||
# ── 1. Create posterg group ───────────────────────────────────────────────────
|
||||
if ! getent group "$APP_GROUP" >/dev/null; then
|
||||
@@ -87,14 +82,12 @@ if [ -d "$APP_DIR/storage" ]; then
|
||||
ok "Storage: 2775, databases: 660"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ Setup complete.${NC}"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Log out and back in as '$DEPLOY_USER' so group membership takes effect"
|
||||
echo " (or run: newgrp $APP_GROUP)"
|
||||
echo " 2. Run: just deploy"
|
||||
echo ""
|
||||
printf "\n"
|
||||
ok "Setup complete."
|
||||
printf "\nNext steps:\n"
|
||||
printf " 1. Log out and back in as '%s' so group membership takes effect\n" "$DEPLOY_USER"
|
||||
printf " (or run: newgrp %s)\n" "$APP_GROUP"
|
||||
printf " 2. Run: just deploy\n\n"
|
||||
warn "If this is a fresh server, also run after first deploy:"
|
||||
echo " just deploy-db # push initial database"
|
||||
echo " just deploy-nginx # apply nginx config"
|
||||
printf " just deploy-db # push initial database\n"
|
||||
printf " just deploy-nginx # install nginx config\n"
|
||||
|
||||
Reference in New Issue
Block a user