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.24 by valya, Tue Feb 5 19:16:40 2008 UTC vs.
Revision 1.55 by valya, Mon Jun 9 16:26:23 2008 UTC

# Line 1 | Line 1
1 < ### RPM cms dbs-server DBS_1_0_8
1 > ### RPM cms dbs-server DBS_1_1_6
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 mysql-deployment oracle apache-tomcat java-jdk dbs-schema
8 > Requires: apache-ant mysql mysql-deployment oracle apache-tomcat java-jdk dbs-schema dbs-libs
9  
10   %prep
11   %setup -n DBS
# Line 10 | Line 13 | Requires: apache-ant mysql mysql-deploym
13   ps -w -w -f -u`whoami` | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "$2""}' |/bin/sh
14  
15   %build
16 + # DBS wants to have LibValut attached to DBS top-level dir, required by build.xml file
17 + ln -s $DBS_LIBS_ROOT/lib LibValut
18   echo "PWD=$PWD"
19   cd Servers/JavaServer
20 +
21 + # retrieve which DBS schema to use
22 + #export DBS_SCHEMA=`grep "^use " $DBS_SCHEMA_ROOT/lib/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql | awk '{print $2}' | sed "s/;//g"`
23 + #export DBS_SCHEMA_VERSION=`cat  $DBS_SCHEMA_ROOT/lib/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql | grep "INSERT INTO SchemaVersion" | awk '{split($0,a,"\x27"); print a[2]}'`
24 +
25   # fix context.xml file
26 < 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
26 > cat etc/context.xml.tobe  | sed "s/__insert_username__/dbs/g" | sed "s/__insert_password__/cmsdbs/g" | sed "s/3306/3316/g" | sed "s/maxActive=\"0\"/maxActive=\"100\"/g" > etc/context.xml
27  
28 + # compile DBS server code
29   mkdir -p bin/WEB-INF/lib
30   echo "PWD=$PWD"
31   source $JAVA_JDK_ROOT/etc/profile.d/init.sh
# Line 42 | Line 36 | cd ../../
36   %install
37   mkdir -p %{i}/Servers/JavaServer/bin/WEB-INF/lib
38   cp -r Servers/JavaServer/* %{i}/Servers/JavaServer
39 + ln -s $DBS_LIBS_ROOT/lib %{i}/LibValut
40  
41   # copy war file
42   cp %{i}/Servers/JavaServer/DBS.war $APACHE_TOMCAT_ROOT/webapps
# Line 52 | Line 47 | cat > %{i}/Servers/JavaServer/bin/dbs_in
47   #!/bin/sh
48   export MYAREA=rpm_install_area
49   export SCRAM_ARCH=slc4_ia32_gcc345
50 < source \$MYAREA/\$SCRAM_ARCH/external/apt/0.5.15lorg3.2-CMS3/etc/profile.d/init.sh
51 < source \$DBS_SERVER_ROOT/etc/profile.d/init.sh
50 > source \$MYAREA/\$SCRAM_ARCH/external/apt/\$APT_VERSION/etc/profile.d/init.sh
51 > source \$MYAREA/%{pkgrel}/etc/profile.d/init.sh
52   # set DBS DBs
53   MYSQL_PORT=3316
54   MYSQL_PATH=\$MYSQL_ROOT/mysqldb
# Line 63 | Line 58 | MYSQL_ERR=\$MYSQL_PATH/error.log
58  
59   function dbs_stop()
60   {
61 <    echo $"Stop mysqld|tomcat running under `whoami` account..."
62 <    ps -w -w -f -u`whoami` | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "\$2""}'|/bin/sh
61 >    me=\`whoami\`
62 >    echo $"Stop mysqld|tomcat running under \$me account..."
63 >    ps -w -w -f -u\$me | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "\$2""}'|/bin/sh
64   }
65   function dbs_start()
66   {
67      echo "+++ Start up CMS MySQL daemon on port \${MYSQL_PORT} ..."
68      \$MYSQL_ROOT/bin/mysqld_safe --datadir=\$MYSQL_PATH --port=\$MYSQL_PORT \
69 <    --socket=\$MYSQL_SOCK --log-error=\$MYSQL_ERR --pid-file=\$MYSQL_PID &
69 >    --socket=\$MYSQL_SOCK --log-error=\$MYSQL_ERR --pid-file=\$MYSQL_PID --max_allowed_packet=32M &
70      echo "+++ Start tomcat server"
71      \$APACHE_TOMCAT_ROOT/bin/catalina.sh start
72      sleep 2
# Line 90 | Line 86 | function dbs_status()
86         echo "MySQL server is not running"
87         exit 1
88      fi
89 <    ps -w -w -f -u`whoami` | egrep "mysqld" | grep -v egrep | awk '{print "MySQLd server running, pid="\$2""}'
90 <    ps -w -w -f -u`whoami` | egrep "tomcat" | grep -v egrep | awk '{print "Tomcat server running, pid="\$2""}'
89 >    ps -w -w -f -u\$me | egrep "mysqld" | grep -v egrep | awk '{print "MySQLd server running, pid="\$2""}'
90 >    ps -w -w -f -u\$me | egrep "tomcat" | grep -v egrep | awk '{print "Tomcat server running, pid="\$2""}'
91      echo "For more information please have a look at tomcat log:"
92      echo "\$APACHE_TOMCAT_ROOT/logs/catalina.out"
93   }
# Line 130 | Line 126 | mkdir -p %{i}/etc/profile.d
126   echo "source $APACHE_TOMCAT_ROOT/etc/profile.d/init.sh"; \
127   echo "source $APACHE_ANT_ROOT/etc/profile.d/init.sh"; \
128   echo "source $DBS_SCHEMA_ROOT/etc/profile.d/init.sh"; \
129 + echo "source $DBS_LIBS_ROOT/etc/profile.d/init.sh"; \
130   echo "source $JAVA_JDK_ROOT/etc/profile.d/init.sh"; \
131   echo "export JAVA_HOME=$JAVA_JDK_ROOT"
132   echo "export CATALINA_HOME=$APACHE_TOMCAT_ROOT"
# Line 142 | Line 139 | mkdir -p %{i}/etc/profile.d
139   echo "source $APACHE_TOMCAT_ROOT/etc/profile.d/init.csh"; \
140   echo "source $APACHE_ANT_ROOT/etc/profile.d/init.csh"; \
141   echo "source $DBS_SCHEMA_ROOT/etc/profile.d/init.csh"; \
142 + echo "source $DBS_LIBS_ROOT/etc/profile.d/init.csh"; \
143   echo "source $JAVA_JDK_ROOT/etc/profile.d/init.csh"; \
144   echo "setenv JAVA_HOME $JAVA_JDK_ROOT"
145   echo "setenv CATALINA_HOME $APACHE_TOMCAT_ROOT"
# Line 165 | Line 163 | MYSQL_SOCK=$MYSQL_PATH/mysql.sock
163   MYSQL_PID=$MYSQL_PATH/mysqld.pid
164   MYSQL_ERR=$MYSQL_PATH/error.log
165   # grant permissions to CMS MySQL DBS account
166 < echo "+++ Grand permission to dbs account, DBS DB ${DBS_SCHEMA_VERSION} ..."
167 < echo "$MYSQL_ROOT/bin/mysql -udbs -pcmsdbs --socket=$MYSQL_SOCK"
168 < echo "$DBS_SCHEMA_ROOT/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql"
166 > echo "+++ Grand permission to dbs account, DBS schema %{dbs_version} ..."
167 > #echo "$MYSQL_ROOT/bin/mysql -udbs -pcmsdbs --socket=$MYSQL_SOCK"
168 > echo "$DBS_SCHEMA_ROOT/lib/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql"
169   # DBS uses trigger which requires to have SUPER priveleges, so we'll create DB using root
170   # and delegate this to dbs account.
171 < $MYSQL_ROOT/bin/mysql -uroot -pcms --socket=$MYSQL_SOCK < $DBS_SCHEMA_ROOT/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql
172 < $MYSQL_ROOT/bin/mysql --socket=$MYSQL_SOCK -uroot -pcms mysql -e "GRANT ALL ON ${DBS_SCHEMA_VERSION}.* TO dbs@localhost;"
171 > export DBS_SCHEMA=`grep "^use " $DBS_SCHEMA_ROOT/lib/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql | awk '{print $2}' | sed "s/;//g"`
172 > $MYSQL_ROOT/bin/mysql -uroot -pcms --port=$MYSQL_PORT --socket=$MYSQL_SOCK < $DBS_SCHEMA_ROOT/lib/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql
173 > $MYSQL_ROOT/bin/mysql --socket=$MYSQL_SOCK --port=$MYSQL_PORT -uroot -pcms mysql -e "GRANT ALL ON ${DBS_SCHEMA}.* TO dbs@localhost;"
174  
175   # I need to copy/deploy DBS.war file into tomcat area
176   cp $DBS_SERVER_ROOT/Servers/JavaServer/DBS.war $APACHE_TOMCAT_ROOT/webapps
177  
178 < echo
179 < echo
180 < echo "#####  IMPORTANT!!!  #####"
182 < echo "For your convinience we created"
183 < echo "$DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh"
184 < echo "init script file which can be placed into /etc/init.d/ to allow auto-startup of DBS service"
185 < echo "##### END OF README  #####"
186 < echo
178 > # Copy mysql jdbc driver to tomcat
179 > cp -f $DBS_LIBS_ROOT/lib/*.jar $APACHE_TOMCAT_ROOT/common/lib
180 >
181   # Fix path in dbs_init.sh file since now we know install area
182   cat $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh | sed "s,rpm_install_area,$RPM_INSTALL_PREFIX,g" > \
183      $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh.new
184 < mv  $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh.new $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh
184 > /bin/mv -f $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh.new $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh
185 > echo "+++ Fix path in dbs_init.sh"
186   chmod a+x $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh
187  
188   # time to start up tomcat for user
189   #$APACHE_TOMCAT_ROOT/bin/catalina.sh start
190  
191   # kill running mysql|tomcat under my account since build is over
192 < ps -w -w -f -u`whoami` | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "$2""}' |/bin/sh
192 > echo "+++ Clean-up mysqld|tomcat processes"
193 > #ps -w -w -f -u`whoami` | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "$2""}'
194 > #ps -w -w -f -u`whoami` | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "$2""}' |/bin/sh
195 > #killall -q mysqld
196 > #cat $MYSQL_ROOT/mysqldb/mysqld.pid
197 > $MYSQL_ROOT/bin/mysqladmin -uroot -pcms --socket=$MYSQL_SOCK --port=3316 shutdown
198 > killall -q tomcat
199 >
200 > # made correct link to LibValut
201 > rm -f $DBS_SERVER_ROOT/LibValut
202 > ln -s $DBS_LIBS_ROOT/lib $DBS_SERVER_ROOT/LibValut
203 >
204 > echo
205 > echo
206 > echo "#####  IMPORTANT!!!  #####"
207 > echo "To work with DBS you need to source init.sh file located at"
208 > echo "$DBS_SERVER_ROOT/etc/profile.d/init.sh"
209 > echo
210 > echo "OR use init script to start|stop|status DBS services:"
211 > echo "$DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh"
212 > echo "init script file can be placed into /etc/init.d/ to allow auto-startup of DBS service"
213 > echo "##########################"
214 > echo
215 >

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines