Subversion Repositories DevTools

Rev

Rev 1038 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1044 dpurdie 1
#!/bin/sh
2
#
3
# Note: Solaris init.d scripts are run under a 'sh' shell at system startup
4
#       The above line has does not control this.
5
#       The script MUST be 'sh' complient
1038 dpurdie 6
 
7
#set -x
8
BLATUSR=releasem
9
BLATBIN=/home/${BLATUSR}/blat
10
PID="${BLATBIN}/run/blat.pid"
11
 
12
 
13
ARG=$1
14
cd "$BLATBIN"
15
 
1044 dpurdie 16
start () {
1038 dpurdie 17
        echo Starting blat daemon now...
1044 dpurdie 18
        SU="bash -c "
19
        [ "$USER" != "$BLATUSR" ] && SU="su - ${BLATUSR} -c "
20
        $SU "perl $BLATBIN/blat.pl -pid=$PID 2>/tmp/blat.log 1>&2"
1038 dpurdie 21
}
22
 
1044 dpurdie 23
 
1038 dpurdie 24
stop () { 
25
        if [ -f $PID ]; then
26
                echo Stopping daemon now...
1044 dpurdie 27
                kill `cat $PID`;
1038 dpurdie 28
        else
29
                echo "No pidfile found (not running?)"
30
        fi
31
}
32
 
33
logrotate () {
34
        echo Triggering a logrotate
1044 dpurdie 35
        kill -HUP `cat $PID`
1038 dpurdie 36
}
37
 
38
#
39
#   Setup init levels
40
#   Linux and Solaris are different
41
#
42
setup() {
43
    if [ ! -f /etc/init.d/blatdaemon ] ; then
44
        echo "Error: /etc/init.d/blatdaemon does not exist"
45
        exit 1
46
    fi
47
 
48
    mtype=`uname`
49
    case "$mtype" in
50
    Linux)
51
        for ii in 2 3 4 5; do
52
            file=/etc/rc.d/rc$ii.d/S80blatdaemon
53
            [ -f $file ] || ln -s /etc/init.d/blatdaemon $file
54
        done
55
 
56
        for ii in 0 1 6 ; do 
57
            file=/etc/rc.d/rc$ii.d/K30blatdaemon
58
            [ -f $file ] || ln -s /etc/init.d/blatdaemon $file
59
        done
60
        ;;
61
 
62
    SunOS)
63
        for ii in 2 3; do
64
            file=/etc/rc$ii.d/S80blatdaemon
65
            [ -f $file ] || ln -s /etc/init.d/blatdaemon $file
66
        done
67
 
68
        for ii in 0 1 S ; do 
69
            file=/etc/rc$ii.d/K30blatdaemon
70
            [ -f $file ] || ln -s /etc/init.d/blatdaemon $file
71
        done
72
        ;;
73
 
74
    *)
75
        echo "$0 setup - Unknown machine type: $mtype"
76
        exit 1
77
        ;;
78
    esac        
79
}
80
 
81
 
82
case $ARG in
83
	start)
84
                start
85
	;;
86
 
87
	stop)
88
                stop
89
	;;
90
 
91
	restart)
92
                stop
93
                start
94
	;;
95
 
96
	logrotate)
97
                logrotate
98
	;;
99
 
100
    setup)    
101
                setup
102
    ;;   
103
 
104
	*)
105
                echo "Usage: $0 <start|stop|restart|logrotate|setup>"
106
                exit 1
107
	;;
108
esac