package update
build-and-publish / build (Raccoon, ubuntu:26.04, NEXUS_PASS_RACCOON, NEXUS_REPO_RACCOON, NEXUS_USER_RACCOON, raccoon) (push) Successful in 4m23s
build-and-publish / build (Trixie, debian:13, NEXUS_PASS_TRIXIE, NEXUS_REPO_TRIXIE, NEXUS_USER_TRIXIE, trixie) (push) Successful in 3m22s

This commit is contained in:
theraw
2026-06-09 03:10:11 +00:00
parent a999551d22
commit 6dfd126a85
2 changed files with 63 additions and 14 deletions
+48
View File
@@ -0,0 +1,48 @@
#!/bin/sh
# postinst — shared by the twiy and twiy-raweb packages.
#
# Pristine configs and the default site ship under /usr/share/twiy/defaults
# (owned/tracked by dpkg), NOT under the live /nginx and /hostdata trees. We
# seed the live trees from the stash here:
# - target missing -> install the packaged copy
# - target present -> leave it untouched; drop our copy as <file>.new
# Because dpkg does not track the live files, an install or upgrade never
# overwrites a config the admin has edited (e.g. you get nginx.conf.new, not a
# clobbered nginx.conf).
set -e
# nginx runtime user (idempotent).
useradd -r -s /bin/false nginx 2>/dev/null || true
seed_tree() {
stash="$1"
target="$2"
[ -d "$stash" ] || return 0
find "$stash" -type f | while IFS= read -r src; do
rel=${src#$stash/}
dst="$target/$rel"
install -d "$(dirname "$dst")"
if [ -e "$dst" ]; then
cp -p "$src" "$dst.new" # keep admin's file; offer ours as .new
else
cp -p "$src" "$dst"
fi
done
}
seed_tree /usr/share/twiy/defaults/nginx /nginx
seed_tree /usr/share/twiy/defaults/hostdata /hostdata
# Empty include dirs referenced by nginx.conf (`include conf.d/*;`) that ship
# with no files of their own.
install -d /nginx/conf.d /nginx/config
install -d -o nginx -g nginx -m 0755 /var/log/nginx
chown -R nginx:nginx /var/log/nginx /nginx 2>/dev/null || true
systemctl daemon-reload 2>/dev/null || true
systemctl enable nginx.service 2>/dev/null || true
systemctl restart nginx.service 2>/dev/null || true
exit 0