#!/bin/bash
# Detect an existing Videostream tree BEFORE unpack (mode C), including first
# time the host gains the videostream-terminal package over a lab/manual install.
set -e
MARKER_DIR=/var/lib/videostream-terminal
MARKER="${MARKER_DIR}/pre-existing"
case "$1" in
  install|upgrade)
    mkdir -p "${MARKER_DIR}"
    rm -f "${MARKER}"
    if [ -d /home/pi/videostream/terminalserver ] \
      || [ -f /home/pi/videostream/configure/ssl/https.enabled ] \
      || [ -f /home/pi/videostream/terminalserver/.vs-install-version ]; then
      touch "${MARKER}"
    fi
    ;;
esac
exit 0
