Untrack runtime sqlite DB files and harden idempotent install updates

This commit is contained in:
2026-09-13 07:23:40 +01:00
parent 432203d8ed
commit 94dfcf6e43
4 changed files with 20 additions and 1 deletions
+2
View File
@@ -39,6 +39,8 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
/.bunext
/db/.backups
/db/.exports
/db/wgui
/db/bmp
.bun-sqlite
/assets
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+17
View File
@@ -16,6 +16,7 @@ REPO_URL="${REPO_URL:-}"
BRANCH="${BRANCH:-main}"
BUN_INSTALL_DIR="${BUN_INSTALL_DIR:-/opt/bun}"
BUN_BIN="/usr/local/bin/bun"
UPDATE=false
log() { echo "==> $*"; }
fail() { echo "error: $*" >&2; exit 1; }
@@ -99,9 +100,17 @@ setup_service_user() {
clone_or_update() {
mkdir -p "$(dirname "$INSTALL_DIR")"
if [ -d "$INSTALL_DIR/.git" ]; then
UPDATE=true
log "updating existing install at $INSTALL_DIR ..."
git -C "$INSTALL_DIR" fetch --depth 1 origin "$BRANCH"
local db_backup="$INSTALL_DIR/db/.wgui-pre-update.db"
if [ -f "$INSTALL_DIR/db/wgui" ]; then
cp -a "$INSTALL_DIR/db/wgui" "$db_backup"
fi
git -C "$INSTALL_DIR" reset --hard "origin/$BRANCH"
if [ -f "$db_backup" ]; then
mv -f "$db_backup" "$INSTALL_DIR/db/wgui"
fi
else
log "cloning wg-ui ($REPO_URL, branch $BRANCH) ..."
git clone --depth 1 --branch "$BRANCH" "$REPO_URL" "$INSTALL_DIR"
@@ -180,6 +189,10 @@ EOF
systemctl daemon-reload
log "enabling and starting $SERVICE_NAME ..."
systemctl enable --now "$SERVICE_NAME.service"
if [ "$UPDATE" = true ]; then
log "restarting $SERVICE_NAME to load updated code ..."
systemctl restart "$SERVICE_NAME.service"
fi
}
install_openrc_unit() {
@@ -209,7 +222,11 @@ EOF
chmod +x "$init_script"
log "adding $SERVICE_NAME to default runlevel and starting ..."
rc-update add "$SERVICE_NAME" default
if [ "$UPDATE" = true ]; then
rc-service "$SERVICE_NAME" restart
else
rc-service "$SERVICE_NAME" start
fi
}
grab_port() {