#!/bin/sh
root="${IPKG_INSTROOT:-}"
if [ -z "${root}" ] && ! id codex >/dev/null 2>&1; then
	. /lib/functions.sh
	gid="$(group_add_next codex)" || exit $?
	user_add codex "" "${gid}" "Codex CLI" /var/empty /bin/false || exit $?
fi
legacy="${root}/usr/share/linkeasefull/desktop-apps.d/35-codex.json"
if [ ! -e "${legacy}" ] && [ ! -L "${legacy}" ]; then
	mkdir -p "${legacy%/*}"
	ln -s /usr/share/codex/codex-plugin.json "${legacy}" || exit $?
fi
exit 0
