#!/bin/sh

if [ "$1" = "configure" ]; then
    systemctl --system stop imunify360-php-daemon.socket >/dev/null 2>&1 || :
    systemctl --system stop imunify360-php-daemon.service >/dev/null 2>&1 || :

    rm -rf /var/lib/imunify360/events.db >/dev/null 2>&1 || :

    # deprive other users access to app data for releases upto 2.0.2-5
    chmod -R o-rwx /var/lib/imunify360-php-daemon
    mkdir -vp /var/lib/imunify360/events.db

    systemctl --system unmask imunify360-php-daemon.service
    systemctl --system unmask imunify360-php-daemon.socket
    systemctl --system restart imunify360-php-daemon.socket
fi

exit 0
