function post_install() {
#!/bin/sh
if command -v setcap >/dev/null 2>&1; then
    for core in /opt/rynet/bin/rynet-core /opt/rynet/bin/rynet-cli; do
        setcap cap_net_admin,cap_net_raw+ep "$core" || true
    done
fi
if command -v firewall-cmd >/dev/null 2>&1 && firewall-cmd --state >/dev/null 2>&1; then
    firewall-cmd --permanent --zone=trusted --add-interface=rynet0 >/dev/null 2>&1 && firewall-cmd --reload >/dev/null 2>&1 || true
fi
if command -v ufw >/dev/null 2>&1 && ufw status 2>/dev/null | grep -q 'Status: active'; then
    ufw allow in on rynet0 >/dev/null 2>&1 || true
fi
command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database -q /usr/share/applications 2>/dev/null || true
command -v gtk-update-icon-cache >/dev/null 2>&1 && gtk-update-icon-cache -q -t -f /usr/share/icons/hicolor 2>/dev/null || true
exit 0

}

function post_upgrade() {
#!/bin/sh
if command -v setcap >/dev/null 2>&1; then
    for core in /opt/rynet/bin/rynet-core /opt/rynet/bin/rynet-cli; do
        setcap cap_net_admin,cap_net_raw+ep "$core" || true
    done
fi
if command -v firewall-cmd >/dev/null 2>&1 && firewall-cmd --state >/dev/null 2>&1; then
    firewall-cmd --permanent --zone=trusted --add-interface=rynet0 >/dev/null 2>&1 && firewall-cmd --reload >/dev/null 2>&1 || true
fi
if command -v ufw >/dev/null 2>&1 && ufw status 2>/dev/null | grep -q 'Status: active'; then
    ufw allow in on rynet0 >/dev/null 2>&1 || true
fi
command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database -q /usr/share/applications 2>/dev/null || true
command -v gtk-update-icon-cache >/dev/null 2>&1 && gtk-update-icon-cache -q -t -f /usr/share/icons/hicolor 2>/dev/null || true
exit 0

}

