forked from CUBRID/cubrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstop_cubrid
executable file
·130 lines (105 loc) · 1.61 KB
/
stop_cubrid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/sh
# Shut down the server for a given database.
#
# $Revision: 1.6 $
# set -x
RootDir="CUBRID"
usage() {
echo "usage: $0 database" 1>&2
echo " $0 -a : stop all databases in this host" 1>&2
exit 1
}
db=
stop_all=0
while [ $# -ne 0 ]
do
case $1 in
-a|-all)
stop_all=1
;;
-*)
usage
;;
*)
if [ -z "${db}" ]
then
db=$1
else
usage
fi
;;
esac
shift
done
if [ -z "${db}" -a $stop_all -eq 0 ]
then
usage
fi
# Checking prefix
for i in $RootDir
do
seevar="echo \$$i"
#echo $seevar
dir=`eval $seevar`
if [ "$dir" != "" ]
then
title=$dir
fi
seevar="echo \$${i}_DATABASES"
dir=`eval $seevar`
if [ "$dir" != "" ]
then
databases=$dir/databases.txt
fi
if [ "$title" != "" ]
then
break
fi
done
if [ "$title" = "" ]
then
echo "Database Root Directory is not set or is set to NULL\n"
fi
if [ "$databases" = "" ]
then
echo "Environment variable for database location is not set"
exit 1
fi
# CUBRID commands that we'll be using.
commdb=${title}/bin/cub_commdb
# Exits 0 if the master server is up and running.
ping_master() {
if ${commdb} -P 2>&1 | egrep "Could not connect to master server on" >/dev/null
then
return 1
else
return 0
fi
}
ping_server() {
${commdb} -P 2>&1 | egrep " Server ${db}[ ,]" >/dev/null
}
stop_a_server() {
if [ -z "${db}" ]
then
return 1
fi
echo "Stoping server for database $db ..."
${commdb} -S ${db}
}
if ping_master
then
:
else
echo "$0: master process is not running" 1>&2
exit 1
fi
if [ $stop_all -eq 1 ]
then
for db in `cut -d\ -f1 $databases`
do
stop_a_server
done
else
stop_a_server
fi