post_install() {
    getent group icecream &>/dev/null || groupadd -r icecream >/dev/null
    getent passwd icecream &>/dev/null || useradd -r -g icecream -s /bin/false \
	    -c "Icecream Daemon" -d /var/cache/icecream icecream 2>/dev/null
    mkdir -p /var/cache/icecream
    mkdir -p /var/log/icecream
    touch /var/log/icecream/scheduler
    touch /var/log/icecream/iceccd
    chown -R icecream:icecream /var/cache/icecream /var/log/icecream/scheduler /var/log/icecream/iceccd
    echo ""
    echo "If you use a firewall, you need to open the following ports:"
    echo "    * 10245/tcp"
    echo "    * 8765/tcp"
    echo "    * 8766/tcp"
    echo ""
    echo "If your scheduler is running on another machine, you also need a special rule to allow broadcasts:"
    echo "    * source network: 0/0"
    echo "    * source port: 8765/udp"
    echo ""
    echo "UFW Example: "
    echo "* sudo ufw allow proto tcp from any to any port 10245"
    echo "* sudo ufw allow proto tcp from any to any port 8765"
    echo "* sudo ufw allow proto tcp from any to any port 8766"
    echo "* sudo ufw allow proto udp from any to any port 8765"
    echo "* sudo ufw allow proto udp from any port 8765 to any"
    echo ""
    echo "See https://github.com/icecc/icecream#firewall for further information."
    echo ""
}

post_upgrade() {
    post_install
}

post_remove() {
    getent passwd icecream &>/dev/null && userdel icecream >/dev/null
    getent group icecream &>/dev/null && groupdel icecream >/dev/null
    true
}
