#!/bin/sh
# Run before payload replacement so an old config in target can be preserved.
# New-version upgrade hook does not scan volumes or stop unrelated processes.
set -eu
root=/var/apps/nastunnel
if [ -x "$root/target/scripts/application" ]; then
    "$root/target/ui/index.cgi" --migrate
fi
if [ ! -e "$root/etc/config.json" ] && [ -f "$root/target/config/config.json" ]; then
    umask 077
    cp -p "$root/target/config/config.json" "$root/etc/config.json"
    chmod 600 "$root/etc/config.json"
fi
exit 0
