aboutsummaryrefslogtreecommitdiff
path: root/network/ircd-hybrid/rc.ircd.new
blob: 9011ea85335c64c6251a15ab6734c7d890e3bd1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh
#
# ircd-hybrid startup script for Slackware Linux

NAME=ircd
DAEMON=/usr/bin/$NAME
PIDFILE=/var/run/$NAME/${NAME}.pid
LOGFILE=/var/log/$NAME/${NAME}.log
CONF=/etc/$NAME/${NAME}.conf
DAEMON_ARGS="-pidfile $PIDFILE -logfile $LOGFILE"

ircd_start() {
  if [! -r $CONF ]; then
    echo "$CONF does not appear to exist.  Abort."
    exit 1
  fi

  if [ -s $PIDFILE ]; then
    echo "$NAME appears to already be running?"
    exit 1
  fi

  echo "Starting IRC daemon ..."
  sudo -u $NAME $DAEMON $DAEMON_ARGS
}

ircd_stop() {
  if [ ! -s $PIDFILE ]; then
    echo "$PIDFILE does not exist or is empty."
    exit 1
  fi

  echo -n "Stopping IRC daemon..."
  if [ -r $PIDFILE ]; then
    kill $(cat $PIDFILE)
    rm -f $PIDFILE
  else
    pkill ircd
  fi
  echo " done"
}

ircd_restart() {
  ircd_stop
  sleep 1
  ircd_start
}

ircd_status() {
  if [ -e $PIDFILE ]; then
    echo "ircd is running."
  else
    echo "ircd is stopped."
    exit 1
  fi
}

case "$1" in
'start')
  ircd_start
  ;;
'stop')
  ircd_stop
  ;;
'restart')
  ircd_restart
  ;;
'status')
  ircd_status
  ;;
*)
  echo "usage $0 start|stop|restart|status"
esac