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

PKGNAME="ubl-config-overlay"

# arg 1:  the new package version
pre_install() {
    true
}

# 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() {
    cd /usr/share/${PKGNAME}
    find * -type d -exec install -dm0755 /{} \;
    find * -type f -exec install -Dm0644 {} /{} \;
    find * -type l -exec cp -af --no-preserve=ownership {} /{} \;

    find etc/tor/* -type f -name "torrc" -exec chmod root:474 "/{}" \;
    find etc/ddclient/* -type f -name "ddclient.conf" -exec chmod 0600 "/{}" \;
    find usr/lib/mc/extfs.d/* -type f -exec chmod 0755 "/{}" \;
}

# arg 1:  the old package version
pre_remove() {
    cat << EOF 

==> IMPORTANT!!!
==> The configuration files will not be deleted from the system:
EOF
    cd /usr/share/${PKGNAME}/
    find * -type f -exec echo "==>   /{}" \;
}

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