Fix CLEAN_INSTALL to wipe dotfiles too

CLEAN_INSTALL now removes dotfiles (e.g. .env) along with other files, using `find -mindepth 1 -delete` instead of `rm -rf *`. Update scripts for affine, nametag, and postiz are updated to explicitly back up and restore .env (via create_backup/restore_backup or cp) BEFORE the build step that sources it, rather than relying on the wipe preserving dotfiles.
This commit is contained in:
MickLesk
2026-07-20 20:23:05 +02:00
parent a5a0b90643
commit bd834f690a
4 changed files with 26 additions and 15 deletions
+10 -3
View File
@@ -38,10 +38,19 @@ function update_script() {
ensure_dependencies cmake
create_backup /root/.affine/config /root/.affine/storage
create_backup /opt/affine/.env /root/.affine/config /root/.affine/storage
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "affine_app" "toeverything/AFFiNE" "tarball" "${RELEASE}" "/opt/affine"
# Restore BEFORE the build: CLEAN_INSTALL wiped /opt/affine including .env,
# and the build below sources it
restore_backup
if [[ ! -f /opt/affine/.env ]]; then
msg_error "/opt/affine/.env is missing (lost by an earlier update). Recreate it before retrying — see the AFFiNE install script for the expected variables."
exit 1
fi
msg_info "Rebuilding Application (Patience ~25 mins, don't close the console!)"
cd /opt/affine
source /root/.profile
@@ -111,8 +120,6 @@ TURBO
set -a && source /opt/affine/.env && set +a
$STD node ./scripts/self-host-predeploy.js
restore_backup
msg_info "Starting Services"
systemctl start affine-web affine-worker
msg_ok "Started Services"
+3
View File
@@ -42,6 +42,9 @@ function update_script() {
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "nametag" "mattogodoy/nametag" "tarball" "latest" "/opt/nametag"
# Restore .env BEFORE the build: CLEAN_INSTALL wiped it and the build sources it
cp /opt/nametag.env.bak /opt/nametag/.env
msg_info "Rebuilding Application"
cd /opt/nametag
$STD npm ci
+4 -2
View File
@@ -41,9 +41,12 @@ function update_script() {
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "postiz" "gitroomhq/postiz-app" "tarball"
# Restore BEFORE the build: CLEAN_INSTALL wiped /opt/postiz including .env,
# and the build below sources it
restore_backup
msg_info "Building Application"
cd /opt/postiz
cp /opt/postiz_env.bak /opt/postiz/.env
set -a && source /opt/postiz/.env && set +a
export NODE_OPTIONS="--max-old-space-size=4096"
$STD pnpm install
@@ -57,7 +60,6 @@ function update_script() {
msg_ok "Ran Database Migrations"
mkdir -p /opt/postiz/uploads
restore_backup
msg_info "Starting Services"
systemctl start postiz-backend postiz-frontend postiz-orchestrator
+9 -10
View File
@@ -2523,9 +2523,9 @@ _download_source_tarball() {
# directory). Extracts <tarball_path> into <workdir>, then copies the contents
# of that top-level directory into <target>.
#
# - Honors CLEAN_INSTALL=1 (wipes <target> first, but PRESERVES dotfiles
# like .env — update scripts rely on config dotfiles surviving the wipe;
# deleting them broke every "backup → deploy → source .env" update flow).
# - Honors CLEAN_INSTALL=1 (wipes <target> first, dotfiles included — back
# up config dotfiles like .env via create_backup and call restore_backup
# BEFORE any build step that sources them).
# - Does NOT own <workdir>: the caller creates it and is responsible for its
# cleanup (typically via a RETURN trap on its tmpdir).
# - cp failures are non-fatal here, matching the previous inline behavior.
@@ -2537,7 +2537,7 @@ _deploy_source_tarball() {
mkdir -p "$target"
if [[ "${CLEAN_INSTALL:-0}" == "1" ]]; then
rm -rf "${target:?}/"*
find "${target:?}" -mindepth 1 -delete
fi
tar --no-same-owner -xzf "$tarball" -C "$workdir" || {
@@ -2563,8 +2563,9 @@ _deploy_source_tarball() {
# a single top-level directory, that directory is stripped (its contents land
# directly in <target>); otherwise the archive contents are copied as-is.
#
# - Honors CLEAN_INSTALL=1 (wipes <target> first, but PRESERVES dotfiles
# like .env — update scripts rely on config dotfiles surviving the wipe).
# - Honors CLEAN_INSTALL=1 (wipes <target> first, dotfiles included — back
# up config dotfiles like .env via create_backup and call restore_backup
# BEFORE any build step that sources them).
# - Does NOT own <workdir>: the caller creates it and cleans it up.
#
# Returns: 0 on success, 65 on unsupported format, 251 on extraction failure,
@@ -2576,7 +2577,7 @@ _deploy_unpacked_archive() {
mkdir -p "$target"
if [[ "${CLEAN_INSTALL:-0}" == "1" ]]; then
rm -rf "${target:?}/"*
find "${target:?}" -mindepth 1 -delete
fi
if [[ "$filename" == *.zip ]]; then
@@ -9269,10 +9270,8 @@ fetch_and_deploy_from_url() {
mkdir -p "$directory"
# CLEAN_INSTALL wipe PRESERVES dotfiles (.env etc.) — update scripts rely on
# config dotfiles surviving the wipe
if [[ "${CLEAN_INSTALL:-0}" == "1" ]]; then
rm -rf "${directory:?}/"*
find "${directory:?}" -mindepth 1 -delete
fi
local unpack_tmp