#!/bin/sh
set -e

# Earlier versions wrote /etc/profile.d/mx-packageinstaller-snap.sh without an init
# check, so it added /snap/bin to PATH for every login -- including when the same MX
# install was booted with sysvinit, where snapd does not run. Regenerate any such
# legacy file (now guarded with a systemd check) from the single source in mxpi-lib.
legacy_snap_profile=/etc/profile.d/mx-packageinstaller-snap.sh
if [ -f "$legacy_snap_profile" ] && ! grep -q '/run/systemd/system' "$legacy_snap_profile"; then
    /usr/lib/mx-packageinstaller/mxpi-lib snapd_add_session_paths >/dev/null 2>&1 || true
fi

#DEBHELPER#

exit 0
