ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CMSDIST/dbs-server.spec
(Generate patch)

Comparing COMP/CMSDIST/dbs-server.spec (file contents):
Revision 1.7 by valya, Fri Mar 2 14:55:50 2007 UTC vs.
Revision 1.49 by valya, Fri May 23 15:00:47 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines