ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CMSDIST/dbs-server.spec
Revision: 1.27
Committed: Tue Feb 5 22:00:01 2008 UTC (17 years, 2 months ago) by valya
Branch: MAIN
Changes since 1.26: +3 -2 lines
Log Message:
Fix stop script

File Contents

# Content
1 ### RPM cms dbs-server DBS_1_0_8
2
3 %define cvstag %v
4 Source: cvs://:pserver:anonymous@cmscvs.cern.ch:2401/cvs_server/repositories/CMSSW?passwd=AA_:yZZ3e&module=DBS/Servers/JavaServer&export=DBS&tag=-r%{cvstag}&output=/dbs-server.tar.gz
5 Requires: apache-ant mysql mysql-deployment oracle apache-tomcat java-jdk dbs-schema
6
7 %prep
8 %setup -n DBS
9 # kill running mysql|tomcat under my account since build is over
10 ps -w -w -f -u`whoami` | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "$2""}' |/bin/sh
11
12 %build
13 echo "PWD=$PWD"
14 cd Servers/JavaServer
15 # fix context.xml file
16 cat > etc/context.xml << EOF_CONTEXT
17 <Context path="/servlet/DBSServlet" docBase="DBSServlet" debug="5" reloadable="true" crossContext="true">
18 <SupportedSchemaVersion schemaversion="DBS_1_0_8" />
19 <SupportedClientVersions clientversions="DBS_1_0_1, DBS_1_0_5, DBS_1_0_7, DBS_1_0_8, DBS_1_0_9"/>
20 <DBSBlockConfig maxBlockSize="2000000000000" maxBlockFiles="100" />
21
22 <Resource name="jdbc/dbs"
23 auth="Container"
24 type="javax.sql.DataSource"
25 maxActive="30"
26 maxIdle="10"
27 maxWait="10000"
28 username="dbs"
29 password="cmsdbs"
30 driverClassName="org.gjt.mm.mysql.Driver"
31 url="jdbc:mysql://localhost:3316/%{cvstag}?autoReconnect=true"/>
32 </Context>
33 EOF_CONTEXT
34
35 mkdir -p bin/WEB-INF/lib
36 echo "PWD=$PWD"
37 source $JAVA_JDK_ROOT/etc/profile.d/init.sh
38 export JAVA_HOME=$JAVA_JDK_ROOT
39 ant --noconfig dist
40 cd ../../
41
42 %install
43 mkdir -p %{i}/Servers/JavaServer/bin/WEB-INF/lib
44 cp -r Servers/JavaServer/* %{i}/Servers/JavaServer
45
46 # copy war file
47 cp %{i}/Servers/JavaServer/DBS.war $APACHE_TOMCAT_ROOT/webapps
48
49 # create dbs init script
50 mkdir -p %{i}/Servers/JavaServer/bin
51 cat > %{i}/Servers/JavaServer/bin/dbs_init.sh << DBS_INIT_EOF
52 #!/bin/sh
53 export MYAREA=rpm_install_area
54 export SCRAM_ARCH=slc4_ia32_gcc345
55 source \$MYAREA/\$SCRAM_ARCH/external/apt/0.5.15lorg3.2-CMS3/etc/profile.d/init.sh
56 source \$MYAREA/%{pkgrel}/etc/profile.d/init.sh
57 # set DBS DBs
58 MYSQL_PORT=3316
59 MYSQL_PATH=\$MYSQL_ROOT/mysqldb
60 MYSQL_SOCK=\$MYSQL_PATH/mysql.sock
61 MYSQL_PID=\$MYSQL_PATH/mysqld.pid
62 MYSQL_ERR=\$MYSQL_PATH/error.log
63
64 function dbs_stop()
65 {
66 me=\`whoami\`
67 echo $"Stop mysqld|tomcat running under \$me account..."
68 ps -w -w -f -u\$me | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "\$2""}'|/bin/sh
69 }
70 function dbs_start()
71 {
72 echo "+++ Start up CMS MySQL daemon on port \${MYSQL_PORT} ..."
73 \$MYSQL_ROOT/bin/mysqld_safe --datadir=\$MYSQL_PATH --port=\$MYSQL_PORT \
74 --socket=\$MYSQL_SOCK --log-error=\$MYSQL_ERR --pid-file=\$MYSQL_PID &
75 echo "+++ Start tomcat server"
76 \$APACHE_TOMCAT_ROOT/bin/catalina.sh start
77 sleep 2
78 echo
79 echo "DBS service is ready ..."
80 }
81 function dbs_status()
82 {
83 me=\`whoami\`
84 dbs_mysqld=\`ps -w -w -f -u\$me | egrep "mysqld" | grep -v egrep | wc -l\`
85 dbs_tomcat=\`ps -w -w -f -u\$me | egrep "tomcat" | grep -v egrep | wc -l\`
86 if [ \${dbs_tomcat} -ne 1 ]; then
87 echo "Tomcat server is not running"
88 exit 1
89 fi
90 if [ \${dbs_mysqld} -ne 2 ]; then
91 echo "MySQL server is not running"
92 exit 1
93 fi
94 ps -w -w -f -u`whoami` | egrep "mysqld" | grep -v egrep | awk '{print "MySQLd server running, pid="\$2""}'
95 ps -w -w -f -u`whoami` | egrep "tomcat" | grep -v egrep | awk '{print "Tomcat server running, pid="\$2""}'
96 echo "For more information please have a look at tomcat log:"
97 echo "\$APACHE_TOMCAT_ROOT/logs/catalina.out"
98 }
99
100 RETVAL=\$?
101
102 case "\$1" in
103 restart)
104 dbs_stop
105 dbs_start
106 ;;
107 start)
108 dbs_start
109 ;;
110 status)
111 dbs_status
112 ;;
113 stop)
114 dbs_stop
115 ;;
116 *)
117 echo \$"Usage: \$0 {start|stop|status|restart}"
118 exit 1
119 ;;
120 esac
121
122 exit \$RETVAL
123 DBS_INIT_EOF
124 chmod a+x %{i}/Servers/JavaServer/bin/dbs_init.sh
125
126 mkdir -p %{i}/etc/profile.d
127 (echo "#!/bin/sh"; \
128 echo "source $ORACLE_ROOT/etc/profile.d/init.sh"; \
129 echo "source $MYSQL_ROOT/etc/profile.d/init.sh"; \
130 echo "source $MYSQL_DEPLOYMENT_ROOT/etc/profile.d/init.sh"; \
131 echo "source $APACHE_TOMCAT_ROOT/etc/profile.d/init.sh"; \
132 echo "source $APACHE_ANT_ROOT/etc/profile.d/init.sh"; \
133 echo "source $DBS_SCHEMA_ROOT/etc/profile.d/init.sh"; \
134 echo "source $JAVA_JDK_ROOT/etc/profile.d/init.sh"; \
135 echo "export JAVA_HOME=$JAVA_JDK_ROOT"
136 echo "export CATALINA_HOME=$APACHE_TOMCAT_ROOT"
137 ) > %{i}/etc/profile.d/dependencies-setup.sh
138
139 (echo "#!/bin/tcsh"; \
140 echo "source $ORACLE_ROOT/etc/profile.d/init.csh"; \
141 echo "source $MYSQL_ROOT/etc/profile.d/init.csh"; \
142 echo "source $MYSQL_DEPLOYMENT_ROOT/etc/profile.d/init.csh"; \
143 echo "source $APACHE_TOMCAT_ROOT/etc/profile.d/init.csh"; \
144 echo "source $APACHE_ANT_ROOT/etc/profile.d/init.csh"; \
145 echo "source $DBS_SCHEMA_ROOT/etc/profile.d/init.csh"; \
146 echo "source $JAVA_JDK_ROOT/etc/profile.d/init.csh"; \
147 echo "setenv JAVA_HOME $JAVA_JDK_ROOT"
148 echo "setenv CATALINA_HOME $APACHE_TOMCAT_ROOT"
149 ) > %{i}/etc/profile.d/dependencies-setup.csh
150
151
152 %post
153 %{relocateConfig}etc/profile.d/dependencies-setup.sh
154 %{relocateConfig}etc/profile.d/dependencies-setup.csh
155
156 # setup MySQL server
157 . $RPM_INSTALL_PREFIX/%{pkgrel}/etc/profile.d/init.sh
158 VO_CMS_SW_DIR=`echo $DBS_SERVER_ROOT | awk '{split($1,a,SCRAM_ARCH); print a[1]}' SCRAM_ARCH=$SCRAM_ARCH`
159 export VO_CMS_SW_DIR
160 $MYSQL_DEPLOYMENT_ROOT/bin/mysql-deployment.sh
161
162 # set DBS DBs
163 MYSQL_PORT=3316
164 MYSQL_PATH=$MYSQL_ROOT/mysqldb
165 MYSQL_SOCK=$MYSQL_PATH/mysql.sock
166 MYSQL_PID=$MYSQL_PATH/mysqld.pid
167 MYSQL_ERR=$MYSQL_PATH/error.log
168 # grant permissions to CMS MySQL DBS account
169 echo "+++ Grand permission to dbs account, DBS DB ${DBS_SCHEMA_VERSION} ..."
170 #echo "$MYSQL_ROOT/bin/mysql -udbs -pcmsdbs --socket=$MYSQL_SOCK"
171 echo "$DBS_SCHEMA_ROOT/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql"
172 # DBS uses trigger which requires to have SUPER priveleges, so we'll create DB using root
173 # and delegate this to dbs account.
174 $MYSQL_ROOT/bin/mysql -uroot -pcms --socket=$MYSQL_SOCK < $DBS_SCHEMA_ROOT/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql
175 $MYSQL_ROOT/bin/mysql --socket=$MYSQL_SOCK -uroot -pcms mysql -e "GRANT ALL ON ${DBS_SCHEMA_VERSION}.* TO dbs@localhost;"
176
177 # I need to copy/deploy DBS.war file into tomcat area
178 cp $DBS_SERVER_ROOT/Servers/JavaServer/DBS.war $APACHE_TOMCAT_ROOT/webapps
179
180 echo
181 echo
182 echo "##### IMPORTANT!!! #####"
183 echo "For your convinience we created"
184 echo "$DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh"
185 echo "init script file which can be placed into /etc/init.d/ to allow auto-startup of DBS service"
186 echo "##### END OF README #####"
187 echo
188 # Fix path in dbs_init.sh file since now we know install area
189 cat $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh | sed "s,rpm_install_area,$RPM_INSTALL_PREFIX,g" > \
190 $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh.new
191 mv $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh.new $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh
192 chmod a+x $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh
193
194 # time to start up tomcat for user
195 #$APACHE_TOMCAT_ROOT/bin/catalina.sh start
196
197 # kill running mysql|tomcat under my account since build is over
198 ps -w -w -f -u`whoami` | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "$2""}' |/bin/sh