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.1 by eulisse, Fri Dec 15 14:49:23 2006 UTC vs.
Revision 1.43 by valya, Tue May 6 16:40:47 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines