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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines