Subversion Repositories DevTools

Rev

Rev 1044 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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