#!/bin/sh
#
# irc - tilde.town irc tunnel
# https://github.com/kiedtl/bin

PIDFILE="/tmp/irc_ssh_pid"

case "$1" in
  start)
    ssh -N town-irc -L localhost:6667:localhost:6667 &
    echo $! >"${PIDFILE}"
    ;;
  stop)
    if [ -f "${PIDFILE}" ]; then
      kill $(cat "${PIDFILE}")
      rm -f "${PIDFILE}"
    fi
    ;;
esac
