#!/bin/sh
# description: tarpit
# chkconfig: 2345 99 99

# do not use systemctl on C7
SYSTEMCTL_SKIP_REDIRECT=1

case "$1" in
'start')
        /usr/local/bin/tarpit
        exit $?
        ;;
'stop')
        [[ -f /var/run/tarpit.pid ]] && perl -lne 'kill 9, $_ if $_ > 1' < /var/run/tarpit.pid
        exit 0
        ;;
'restart')
        [[ -f /var/run/tarpit.pid ]] && perl -lne 'kill 9, $_ if $_ > 1' < /var/run/tarpit.pid
        /usr/local/bin/tarpit
        exit $?
        ;;
*)
        echo "Usage: $0 { start | stop | restart }"
        exit 1
        ;;
esac
