diff --git a/installer.sh b/installer.sh index 8ba8e14..6937d0e 100644 --- a/installer.sh +++ b/installer.sh @@ -100,11 +100,21 @@ gen() { head -c 512 /dev/urandom | tr -dc 'A-Za-z0-9' | head -c "${1:-28}" || pw() { gen 28; } short() { gen 16; } +# ===== Argument-Parsing ===== +while [[ $# -gt 0 ]]; do + case "$1" in + -dev) APP_ENV="local"; APP_DEBUG="true" ;; + -stag|-staging) APP_ENV="staging"; APP_DEBUG="false" ;; + esac + shift +done + # ===== Start ===== require_root header SERVER_IP="$(detect_ip)" +APP_PW="${APP_PW:-$(pw)}" MAIL_HOSTNAME="${MAIL_HOSTNAME:-"bootstrap.local"}" # Wizard setzt später FQDN TZ="${TZ:-""}" # leer; Wizard setzt final @@ -383,8 +393,9 @@ systemctl enable --now redis-server log "Nginx konfigurieren…" rm -f /etc/nginx/sites-enabled/default /etc/nginx/sites-available/default || true -PHP_FPM_SOCK="/run/php/php-fpm.sock" -[ -S "/run/php/php8.2-fpm.sock" ] && PHP_FPM_SOCK="/run/php/php8.2-fpm.sock" +PHPV=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;') +PHP_FPM_SOCK="/run/php/php${PHPV}-fpm.sock" +[ -S "$PHP_FPM_SOCK" ] || PHP_FPM_SOCK="/run/php/php-fpm.sock" cat > ${NGINX_SITE} </dev/null 2>&1; then adduser --disabled-password --gecos "" "$APP_USER" - echo "${APP_USER}:${APP_PW}" | chpasswd fi +echo "${APP_USER}:${APP_PW}" | chpasswd usermod -a -G "$APP_GROUP" "$APP_USER" # Besitz & Rechte @@ -575,25 +567,13 @@ if command -v setfacl >/dev/null 2>&1; then "${APP_DIR}/storage" "${APP_DIR}/bootstrap/cache" || true fi -echo -e "${YELLOW}[i] App-User: ${APP_USER} Passwort: ${APP_PW}${NC}" - - -# Optional: ACLs, falls verfügbar (robuster bei gemischten Schreibzugriffen) -if command -v setfacl >/dev/null 2>&1; then - setfacl -R -m u:${APP_USER}:rwX,g:${APP_GROUP}:rwX \ - "${APP_DIR}/storage" "${APP_DIR}/bootstrap/cache" || true - setfacl -dR -m u:${APP_USER}:rwX,g:${APP_GROUP}:rwX \ - "${APP_DIR}/storage" "${APP_DIR}/bootstrap/cache" || true -fi - grep -q 'umask 002' /home/${APP_USER}/.profile 2>/dev/null || echo 'umask 002' >> /home/${APP_USER}/.profile grep -q 'umask 002' /home/${APP_USER}/.bashrc 2>/dev/null || echo 'umask 002' >> /home/${APP_USER}/.bashrc # 7) npm respektiert umask – zur Sicherheit direkt setzen (für APP_USER) sudo -u "$APP_USER" -H bash -lc "npm config set umask 0002" >/dev/null 2>&1 || true -# 8) PHP-FPM-Worker laufen als www-data (Standard). Stelle sicher, dass der FPM-Socket group-writable ist: -PHPV=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;') +# PHP-FPM-Socket group-writable machen FPM_POOL="/etc/php/${PHPV}/fpm/pool.d/www.conf" if [ -f "$FPM_POOL" ]; then sed -i 's/^;*listen\.owner.*/listen.owner = www-data/' "$FPM_POOL"