#!/bin/sh
# Runs as the package user (conf/privilege). The Relay's data lives in the
# package's private folder (var/), CREDENTIALS.txt in the viaalink-relay
# shared folder, which the data-share worker creates at WHEN_ENABLE, after
# this script; the container's relay-start.sh seeds both on the first
# start. This script only tells the user where to look, and what happens
# to the data on update and uninstall. DSM 7.4.1 kept the private folder on
# uninstall (README, Uninstalling), so never promise that uninstalling
# deletes it.
DATA_NOTE="The Relay keeps its keys, license and settings in the package's own folder, where only the Relay can read them. Updating the package keeps them. DSM can keep them after an uninstall too (DSM 7.4.1 does), so installing again brings back the same Relay. To carry settings to another NAS, use Settings > Backup and restore in the dashboard."
if [ -n "$SYNOPKG_TEMP_LOGFILE" ] && [ "$SYNOPKG_PKG_STATUS" = "INSTALL" ]; then
    cat > "$SYNOPKG_TEMP_LOGFILE" <<MSG
Viaalink Relay is installed.
After it has started, open File Station, shared folder viaalink-relay, file CREDENTIALS.txt. It has the dashboard address and your setup code.
$DATA_NOTE
MSG
elif [ -n "$SYNOPKG_TEMP_LOGFILE" ] && [ "$SYNOPKG_PKG_STATUS" = "UPGRADE" ]; then
    cat > "$SYNOPKG_TEMP_LOGFILE" <<MSG
Viaalink Relay is updated; your setup code, license and keys are kept.
MSG
fi
exit 0
