#!/usr/bin/env bash # # Update Daynivo Kiosk OS from this checkout (or an extracted release). # # sudo ./update.sh # git pull --ff-only, back up config, install --upgrade # sudo ./update.sh --no-pull # install the code as it is in this directory # # The configuration in /etc/daynivo-kiosk is backed up first and never overwritten. set -euo pipefail SRC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PULL=1 [[ ${1:-} == "--no-pull" ]] && PULL=0 [[ ${1:-} == "-h" || ${1:-} == "--help" ]] && { sed -n '3,9p' "$0" | sed 's/^# \{0,1\}//'; exit 0; } [[ $EUID -eq 0 ]] || { echo "Voer dit script uit met sudo." >&2; exit 1; } BEFORE="$(cat /usr/share/daynivo-kiosk/VERSION 2>/dev/null || cat /usr/share/voxip-kiosk/VERSION 2>/dev/null || echo 'niet geïnstalleerd')" if [[ $PULL -eq 1 && -d "$SRC/.git" ]]; then echo "==> Laatste versie ophalen" OWNER="$(stat -c %U "$SRC")" sudo -u "$OWNER" git -C "$SRC" pull --ff-only fi # Before the rename to Daynivo (up to 1.2.x) the configuration lived in /etc/voxip-kiosk. CONF_DIR=daynivo-kiosk if [[ ! -d /etc/daynivo-kiosk && -d /etc/voxip-kiosk ]]; then CONF_DIR=voxip-kiosk; fi if [[ -d /etc/$CONF_DIR ]]; then BACKUP="/var/backups/daynivo-kiosk-$(date +%Y%m%d-%H%M%S).tar.gz" echo "==> Configuratie back-uppen naar $BACKUP" install -d -m 0700 /var/backups tar -C /etc -czf "$BACKUP" "$CONF_DIR" chmod 0600 "$BACKUP" # keep the five most recent backups ls -1t /var/backups/daynivo-kiosk-*.tar.gz 2>/dev/null | tail -n +6 | xargs -r rm -f fi "$SRC/install.sh" --upgrade echo "==> Bijgewerkt: $BEFORE → $(cat /usr/share/daynivo-kiosk/VERSION)"