#!/bin/sh
# postinst script 
# see: dh_installdeb(1)

set -e

case "$1" in
    configure|upgrade|update|reconfigure|triggered)
        
        update-rc.d nguardian-system defaults
        
         # systemd 명령어 실행 부분을 chroot 환경에서 동작하지 않도록 구성 - ISO 빌드 환경에서 오류 발생
        if [ -z "$FAKEROOTKEY" ] && [ -d /run/systemd/system ]; then
            if which systemctl >/dev/null 2>&1 ; then
                systemctl enable nguardian-system.service
                systemctl daemon-reload
            fi
        fi

        /usr/lib/nguardian-system/nguardian-system.py

    ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;
    
    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

exit 0
