ensure that the trainwreck which was 1.9.2 does not happen again
[freeside.git] / init.d / freeside-init
1 #!/bin/sh
2 #
3 # chkconfig: 345 86 16
4 # description: Freeside daemons
5
6 QUEUED_USER=%%%QUEUED_USER%%%
7
8 SELFSERVICE_USER=%%%SELFSERVICE_USER%%%
9 SELFSERVICE_MACHINES="%%%SELFSERVICE_MACHINES%%%"
10
11 IF=eth0
12
13 #INSTALLSCRIPT/INSTALLSITEBIN from Makefile.PL
14 PATH="$PATH:/usr/local/bin"
15 export PATH
16
17 [ -r /etc/default/freeside ] && . /etc/default/freeside
18
19 case "$1" in
20   start)
21         # Start daemons.
22         echo -n "Starting freeside-queued: "
23         #perl -MDBIx::Profile /usr/local/bin/freeside-queued $QUEUED_USER
24         freeside-queued $QUEUED_USER
25         #export NYTPROF="file=/usr/local/etc/freeside/nytprof.out"
26         #PERL5OPT="-d:NYTProf" freeside-queued $QUEUED_USER
27         echo "done."
28
29         echo -n "Starting freeside-sqlradius-radacctd: "
30         freeside-sqlradius-radacctd $QUEUED_USER
31         echo "done."
32
33         echo -n "Starting freeside-prepaidd: "
34         freeside-prepaidd $QUEUED_USER
35         echo "done."
36
37         echo -n "Starting freeside-cdrrewrited: "
38         freeside-cdrrewrited $QUEUED_USER
39         echo "done."
40
41         echo -n "Starting freeside-cdrd: "
42         freeside-cdrd $QUEUED_USER
43         echo "done."
44
45         for MACHINE in $SELFSERVICE_MACHINES; do
46           echo -n "Starting freeside-selfservice-server to $MACHINE: "
47           freeside-selfservice-server $SELFSERVICE_USER $MACHINE
48           echo "done."
49         done
50
51         #ip=`/sbin/ifconfig $IF | grep 'inet addr:' | cut -d: -f2- | cut -d' ' -f1`
52         #cp /opt/rt3/etc/RT_SiteConfig.pm.ORIG /opt/rt3/etc/RT_SiteConfig.pm
53         #perl -pi -e "s/localhost/$ip/" /opt/rt3/etc/RT_SiteConfig.pm
54
55         ;;
56   stop)
57         # Stop daemons.
58         echo -n "Stopping freeside-queued: "
59         [ -e /var/run/freeside-queued.pid ] && kill `cat /var/run/freeside-queued.pid`
60         #and
61         sleep 2;
62         killall freeside-queued
63         echo "done."
64
65         if [ -e /var/run/freeside-sqlradius-radacctd.pid ]; then
66           echo -n "Stopping freeside-sqlradius-radacctd: "
67           kill `cat /var/run/freeside-sqlradius-radacctd.pid`
68           echo "done."
69         fi
70
71         if [ -e /var/run/freeside-prepaidd.pid ]; then
72           echo -n "Stopping freeside-prepaidd: "
73           kill `cat /var/run/freeside-prepaidd.pid`
74           echo "done."
75         fi
76
77         if [ -e /var/run/freeside-cdrd.pid ]; then
78           echo -n "Stopping freeside-cdrd: "
79           kill `cat /var/run/freeside-cdrd.pid`
80           echo "done."
81         fi
82
83         if [ -e /var/run/freeside-cdrrewrited.pid ]; then
84           echo -n "Stopping freeside-cdrrewrited: "
85           kill `cat /var/run/freeside-cdrrewrited.pid`
86           echo "done."
87         fi
88
89         if [ -e /var/run/freeside-selfservice-server.$SELFSERVICE_USER.pid ]
90         then
91           echo -n "Stopping (old) freeside-selfservice-server: "
92           kill `cat /var/run/freeside-selfservice-server.$SELFSERVICE_USER.pid`
93           rm /var/run/freeside-selfservice-server.$SELFSERVICE_USER.pid
94           echo "done."
95         fi
96
97         if [ -z "$SELFSERVICE_MACHINES" ]; then SELFSERVICE_MACHINES='localhost'; fi
98         for MACHINE in $SELFSERVICE_MACHINES; do
99           if [ -e /var/run/freeside-selfservice-server.$SELFSERVICE_USER.$MACHINE.pid ]
100           then
101             echo -n "Stopping freeside-selfservice-server to $MACHINE: "
102             kill `cat /var/run/freeside-selfservice-server.$SELFSERVICE_USER.$MACHINE.pid`
103             echo "done."
104           fi
105         done
106
107         ;;
108
109   restart)
110         $0 stop
111         $0 start
112         ;;
113   *)
114         echo "Usage: freeside {start|stop|restart}"
115         exit 1
116 esac
117
118 exit 0
119