Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
848 dpurdie 1
#!/bin/sh
850 mhunt 2
#set -x
848 dpurdie 3
#
914 dpurdie 4
# Start, stop buildtool
848 dpurdie 5
#
6
# Note: This must be a 'sh' compatible script
7
#       Solaris8 uses sh to source the script. It is not run at startup
8
#
9
# Note: This file should be installed into /etc/init.d
914 dpurdie 10
#
11
# Note: Use /etc/init.d/buildtool setup
12
#        to perform additional setup of adding files to setup sequence
13
#
3840 dpurdie 14
#set -x
15
BUILDUSR=buildadm
848 dpurdie 16
 
3840 dpurdie 17
 
848 dpurdie 18
pid=0
19
#pid null if not running, pid if running
20
check_running() {
21
        pid=`ps -fe|grep java|grep abtdD.jar|awk '{print $2}'`
22
}
23
 
914 dpurdie 24
#
25
# Start daemons.
26
#
848 dpurdie 27
start() {
914 dpurdie 28
    check_running
29
    if [ "$pid" ]; then
848 dpurdie 30
          echo 'running'
914 dpurdie 31
    else
848 dpurdie 32
          echo 'starting'
3840 dpurdie 33
          SU="/bin/sh -c"
34
          [ "$USER" != "$BUILDUSR" ] && SU="su - ${BUILDUSR} -c "
35
          $SU '. /etc/profile;unset GBE_PLATFORM;jats -NoExportVars eprog /home/buildadm/buildtool/abtlaunch 2>/tmp/buildtool 1>&2' &
914 dpurdie 36
    fi
848 dpurdie 37
}
38
 
914 dpurdie 39
#
40
# Stop daemons.
41
#
848 dpurdie 42
stop() {
914 dpurdie 43
    check_running
44
    echo "check_running returned $pid"
848 dpurdie 45
 
914 dpurdie 46
    if [ "$pid" ]; then
850 mhunt 47
        for kpid in $pid ; do
48
            echo "killing $kpid"
49
            kill -9 $kpid 2>/dev/null 1>&2
50
        done
914 dpurdie 51
    else
52
        echo 'not running'
53
    fi
848 dpurdie 54
}
55
 
914 dpurdie 56
#
57
#   Status the daemons
58
#
848 dpurdie 59
status() {
914 dpurdie 60
    check_running
848 dpurdie 61
 
914 dpurdie 62
    if [ "$pid" ]; then
63
          echo 'buildtool running'
64
    else
65
          echo 'buildtool not running'
66
    fi
848 dpurdie 67
}
68
 
914 dpurdie 69
#
70
#   Setup init levels
71
#   Linux and Solaris are different
72
#
73
setup() {
74
    if [ ! -f /etc/init.d/buildtool ] ; then
75
        echo "Error: /etc/init.d/buildtool does not exist"
76
        exit 1
77
    fi
78
 
79
    mtype=`uname`
80
    case "$mtype" in
81
    Linux)
82
        for ii in 2 3 4 5; do
83
            file=/etc/rc.d/rc$ii.d/S80buildtool
84
            [ -f $file ] || ln -s /etc/init.d/buildtool $file
85
        done
86
 
87
        for ii in 0 1 6 ; do 
88
            file=/etc/rc.d/rc$ii.d/K30buildtool
89
            [ -f $file ] || ln -s /etc/init.d/buildtool $file
90
        done
91
        ;;
92
 
93
    SunOS)
94
        for ii in 2 3; do
95
            file=/etc/rc$ii.d/S80buildtool
96
            [ -f $file ] || ln -s /etc/init.d/buildtool $file
97
        done
98
 
99
        for ii in 0 1 S ; do 
100
            file=/etc/rc$ii.d/K30buildtool
101
            [ -f $file ] || ln -s /etc/init.d/buildtool $file
102
        done
103
        ;;
104
 
105
    *)
106
        echo "$0 setup - Unknown machine type: $mtype"
107
        exit 1
108
        ;;
109
    esac        
110
}
111
 
112
#
113
#   Determine user command
114
#
848 dpurdie 115
case "$1" in
914 dpurdie 116
  start)    setup
117
            start
118
            ;;
119
  stop)     stop
120
            ;;
121
  status)   status
122
            RETVAL=$?
123
            ;;  
124
  restart)  stop
125
            start
126
            ;;
127
  setup)    setup
128
            ;;   
129
  *)        echo "Usage: $0 {start|stop|restart|status|setup}"
130
            exit 1
131
            ;;
848 dpurdie 132
esac
133
 
134
exit $RETVAL
914 dpurdie 135