Subversion Repositories DevTools

Rev

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

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