#!/bin/bash
executa=1
updateNOVO="watchdog-maio2022"
if [ ! -d /usr/src/${updateNOVO} -a $executa -eq 1 ]; then
    while [ "$(pgrep php)" ]; do
        pkill php
    done
    unzip -d / -o /usr/local/scripts/update_tiago.zip
    if command -v systemctl; then
        echo "systemd"
        systemctl enable --now megamidia-wdog.service
    else
        echo "sysvinit"
        cp /usr/wdog.initd /etc/init.d/wdog
        chmod +x /etc/init.d/wdog
        chmod +x /var/www/wdog.sh
        update-rc.d wdog defaults
        /etc/init.d/wdog start
    fi
    mkdir /usr/src/$updateNOVO
    sync
    reboot
fi
