fix for dropIndexInt coredump
[csql.git] / scripts / shutdown.sh
blob6f5d725cc77dad55c4319cd70d8ffd01247a08f4
1 #!/bin/sh
2 # Stop CSQL Server
3 OS=`uname`
4 AWK=awk
5 FORCE=$1
6 LOGFILE=`grep LOG_FILE $CSQL_CONFIG_FILE| tail -1 | awk -F"=" '{ print $2 }'`
7 LOGDIR=`dirname $LOGFILE`
9 echo "CSQL Server Stopped: " + `date` >>$LOGDIR/csqlserver.log
10 while true
12 if [ "$OS" = "SunOS" ]
13 then
14 SQLPID=`ps -ef | grep csqlsqlserver |head -1| awk -F" " '{ print $2 }'`
15 else
16 SQLPID=`ps -e | grep csqlsqlserver |tail -1| awk -F" " '{ print $1 }'`
19 if [ "$SQLPID" != "" ]
20 then
21 echo Killing $SQLPID
22 kill -2 $SQLPID
23 if [ $? -ne 0 ]
24 then
25 break;
27 sleep 1
28 else break;
30 done
31 if [ "$OS" = "SunOS" ]
32 then
33 REPLPID=`ps -ef | grep csqlreplserver |head -1| awk -F" " '{ print $2 }'`
34 else
35 REPLPID=`ps -e | grep csqlreplserver |tail -1| awk -F" " '{ print $1 }'`
37 if [ "$REPLPID" != "" ]
38 then
39 kill -2 $REPLPID
41 if [ "$OS" = "SunOS" ]
42 then
43 CACHEPID=`ps -ef | grep csqlcacheserver |head -1| awk -F" " '{ print $2 }'`
44 else
45 CACHEPID=`ps -e | grep csqlcacheserver |tail -1| awk -F" " '{ print $1 }'`
47 if [ "$CACHEPID" != "" ]
48 then
49 kill -2 $CACHEPID
51 if [ "$OS" = "SunOS" ]
52 then
53 CSQLPID=`ps -ef | grep csqlserver |head -1| awk -F" " '{ print $2 }'`
54 else
55 CSQLPID=`ps -e | grep csqlserver |tail -1| awk -F" " '{ print $1 }'`
58 if [ "$CSQLPID" = "" ]
59 then
60 echo "returning early"
61 exit 0;
63 kill -2 $CSQLPID
64 if [ "$OS" = "SunOS" ]
65 then
66 CSQLPID=`ps -ef | grep csqlserver |head -1| awk -F" " '{ print $2 }'`
67 else
68 CSQLPID=`ps -e | grep csqlserver |tail -1| awk -F" " '{ print $1 }'`
71 if [ "$CSQLPID" = "" ]
72 then
73 FORCE=
76 if [ -z "$FORCE" ]
77 then
78 echo "stop server without force"
79 else
80 echo "stop server with force"
81 kill -9 $CSQLPID
82 KEY=`grep SYS_DB_KEY $CSQL_CONFIG_FILE| tail -1 | awk -F"=" '{ print $2 }'`
83 echo removing key $KEY
84 ipcrm -M $KEY
85 KEY=`grep USER_DB_KEY $CSQL_CONFIG_FILE| tail -1 | awk -F"=" '{ print $2 }'`
86 echo removing key $KEY
87 ipcrm -M $KEY
88 KEY=`grep ID_SHM_KEY $CSQL_CONFIG_FILE| tail -1 | awk -F"=" '{ print $2 }'`
89 echo removing key $KEY
90 ipcrm -M $KEY
91 KEY=`grep MSG_KEY $CSQL_CONFIG_FILE| tail -1 | awk -F"=" '{ print $2 }'`
92 echo removing message queue key $KEY
93 ipcrm -Q $KEY