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.22 by valya, Tue Jan 29 18:21:07 2008 UTC vs.
Revision 1.52 by valya, Fri May 30 19:41:59 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines