# old version (without -$pkgrel): ${1%%-*}
# new version (without -$pkgrel): ${2%%-*}

PKGNAME="jacartauc"

# arg 1:  the new package version
pre_install() {
    pre_upgrade $@
}

# arg 1:  the new package version
post_install() {
    post_upgrade $@
}

# arg 1:  the new package version
# arg 2:  the old package version
pre_upgrade() {
    true
}

# arg 1:  the new package version
# arg 2:  the old package version
post_upgrade() {
    if which systemctl &>/dev/null; then
	systemctl --quiet enable pcscd.socket &>/dev/null
        systemctl --quiet restart pcscd.socket pcscd.service &>/dev/null
    elif [[ -f /etc/init.d/pcscd ]]; then
        /etc/init.d/pcscd enable &>/dev/null
        /etc/init.d/pcscd restart &>/dev/null
    fi
    return 0
}

# arg 1:  the old package version
pre_remove() {
    NAME_APP=JaCartaUC
    pkill -x --signal KILL ${NAME_APP} 2>/dev/null
    return 0
}

# arg 1:  the old package version
post_remove() {
    true
}
