summaryrefslogtreecommitdiff
path: root/init.d/freeside-init
blob: a62b187aba901048d8cf1b2e36eb67e5bea81cf8 (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
74
75
76
77
78
79
#! /bin/sh
#
# chkconfig: 345 86 16
# description: Freeside daemons

QUEUED_USER=%%%QUEUED_USER%%%

SELFSERVICE_USER=%%%SELFSERVICE_USER%%%
SELFSERVICE_MACHINES="%%%SELFSERVICE_MACHINES%%%"

#INSTALLSCRIPT/INSTALLSITEBIN from Makefile.PL
PATH="$PATH:/usr/local/bin"
export PATH

case "$1" in
  start)
        # Start daemons.
        echo -n "Starting freeside-queued: "
        freeside-queued $QUEUED_USER
        echo "done."

        #echo -n "Starting freeside-sqlradius-radacctd: "
        #freeside-sqlradius-radacctd $QUEUED_USER
        #echo "done."

        echo -n "Starting freeside-prepaidd: "
        freeside-prepaidd $QUEUED_USER
        echo "done."

        for MACHINE in $SELFSERVICE_MACHINES; do
          echo -n "Starting freeside-selfservice-server to $MACHINE: "
          freeside-selfservice-server $SELFSERVICE_USER $MACHINE
          echo "done."
        done

        ;;
  stop)
        # Stop daemons.
        echo -n "Stopping freeside-queued: "
        kill `cat /var/run/freeside-queued.pid`
        echo "done."

        #and
        killall freeside-queued

        echo -n "Stopping freeside-sqlradius-radacctd: "
        kill `cat /var/run/freeside-sqlradius-radacctd.pid`
        echo "done."

        echo -n "Stopping freeside-prepaidd: "
        kill `cat /var/run/freeside-prepaidd.pid`
        echo "done."

        if [ -e /var/run/freeside-selfservice-server.$SELFSERVICE_USER.pid ]
        then
          echo -n "Stopping (old) freeside-selfservice-server: "
          kill `cat /var/run/freeside-selfservice-server.$SELFSERVICE_USER.pid`
          rm /var/run/freeside-selfservice-server.$SELFSERVICE_USER.pid
        fi

        for MACHINE in $SELFSERVICE_MACHINES; do
          echo -n "Stopping freeside-selfservice-server to $MACHINE: "
          kill `cat /var/run/freeside-selfservice-server.$SELFSERVICE_USER.$MACHINE.pid`
          echo "done."
        done

        ;;

  restart)
        $0 stop
        $0 start
        ;;
  *)
        echo "Usage: freeside {start|stop|restart}"
        exit 1
esac

exit 0