#!/bin/sh
set -eu

root="${SANEFISH_ROOT:-}"
source_entry="${root}/usr/share/sanefish/runtime/sanefish.json"
target_entry="${root}/usr/share/jolla-settings/entries/sanefish.json"
state_directory="${root}/var/lib/sanefish-patches"
hidden_marker="${state_directory}/sanefish-hidden"

[ -r "${source_entry}" ] || {
    echo "SaneFish Settings entry source is missing" >&2
    exit 1
}
install -d -m0755 "$(dirname "${target_entry}")"
install -p -m0644 "${source_entry}" "${target_entry}"
install -d -m0755 "${state_directory}"
rm -f -- "${hidden_marker}"
