#!/bin/bash

# shellcheck source=/dev/null
[ -e /usr/share/univention-lib/ucr.sh ] && . /usr/share/univention-lib/ucr.sh


action="$1"
app_id="$2"  # intercom-service
app_version="$3"
error_file="$4"



if [ -n "$action" ] && [ "$action" = "remove" ]; then
    exit 0
fi


if [ "$action" = "update" ] || [ "$action" = "install" ]; then
    eval "$(ucr shell)"
    if ! [[ "$intercom_service_settings_proxy" =~ (true|false) ]]; then
        echo "UCR variable intercom-service/settings/proxy is neither 'true' or 'false'"
        exit 1
    fi
fi

if [ "$action" = "settings" ]; then
  univention-app reinitialize intercom-service
  exit 0
fi
