fix: app update

This commit is contained in:
Piotr Dec 2026-04-08 23:05:33 +02:00
parent ef6f58b4e5
commit e30218354d
Signed by: stawros
GPG key ID: 74B18A3F0F1E99C0

View file

@ -60,8 +60,29 @@ usermod -aG docker karl
# --- 6. Pobranie i rozpakowanie archiwum --- # --- 6. Pobranie i rozpakowanie archiwum ---
APP_URL="${1:?Podaj URL archiwum ZIP jako pierwszy argument}" APP_URL="${1:?Podaj URL archiwum ZIP jako pierwszy argument}"
APP_DIR="/opt/karl/app" APP_DIR="/home/karl/app"
# --- Backup i czyszczenie istniejącego katalogu ---
if [[ -d "$APP_DIR" ]] && [[ -n "$(ls -A "$APP_DIR" 2>/dev/null)" ]]; then
log "Katalog $APP_DIR istnieje i nie jest pusty — tworzenie backupu..."
CONFIG_DIR="$APP_DIR/config"
if [[ -d "$CONFIG_DIR" ]]; then
BACKUP_DIR="/home/karl/backups"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
BACKUP_PATH="$BACKUP_DIR/config_backup_$TIMESTAMP"
mkdir -p "$BACKUP_DIR"
cp -r "$CONFIG_DIR" "$BACKUP_PATH"
chown -R karl:karl "$BACKUP_DIR"
log "Backup utworzony: $BACKUP_PATH"
else
log "Katalog config nie istnieje — pomijam backup."
fi
log "Usuwanie katalogu $APP_DIR..."
rm -rf "$APP_DIR"
log "Katalog $APP_DIR usunięty."
fi
# --- Instalacja / aktualizacja ---
log "Pobieranie archiwum z: $APP_URL" log "Pobieranie archiwum z: $APP_URL"
mkdir -p "$APP_DIR" mkdir -p "$APP_DIR"
TMPZIP=$(mktemp /tmp/karl-app-XXXXXX.zip) TMPZIP=$(mktemp /tmp/karl-app-XXXXXX.zip)