#!/bin/bash

set -x

SERVICE="filewave"

DATA_DIR="/var/lib/univention-appcenter/apps/${SERVICE}/data"

restored=0
if [[ -e "${DATA_DIR}/etc" ]]; then
  restored=1
  rm -rf /usr/local/etc/*
  cp -Ra "${DATA_DIR}"/etc/* /usr/local/etc/
fi

if [[ -f "${DATA_DIR}/settings_custom.py" ]]; then
  restored=1
  cp -a "${DATA_DIR}/settings_custom.py" "/usr/local/filewave/django/filewave/settings_custom.py "
fi

if [[ "${restored}" -eq 1 ]]; then
  /etc/init.d/fw-server restart
fi