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.3 by eulisse, Mon Feb 26 13:01:18 2007 UTC vs.
Revision 1.24 by valya, Tue Feb 5 19:16:40 2008 UTC

# Line 1 | Line 1
1 < ### RPM cms dbs-web v00_00_06
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/Servers/JavaServer&export=DBS/Servers/JavaServer&tag=-r%{cvstag}&output=/dbs-server.tar.gz
5 < Requires: python dbs-client py2-sqlalchemy cherrypy mysql py2-mysqldb oracle py2-cx-oracle apache-tomcat
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/Servers/JavaServer )
13 > echo "PWD=$PWD"
14 > cd Servers/JavaServer
15 > # fix context.xml file
16 > 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
34 >
35 > mkdir -p bin/WEB-INF/lib
36 > echo "PWD=$PWD"
37 > source $JAVA_JDK_ROOT/etc/profile.d/init.sh
38 > export JAVA_HOME=$JAVA_JDK_ROOT
39 > ant --noconfig dist
40 > cd ../../
41  
42   %install
43 < mkdir -p %i/bin
44 < mkdir -p %i/lib/python
45 < cp -r Servers/JavaServer/* %i/lib/python
43 > mkdir -p %{i}/Servers/JavaServer/bin/WEB-INF/lib
44 > cp -r Servers/JavaServer/* %{i}/Servers/JavaServer
45 >
46 > # copy war file
47 > cp %{i}/Servers/JavaServer/DBS.war $APACHE_TOMCAT_ROOT/webapps
48 >
49 > # create dbs init script
50 > mkdir -p %{i}/Servers/JavaServer/bin
51 > cat > %{i}/Servers/JavaServer/bin/dbs_init.sh << DBS_INIT_EOF
52 > #!/bin/sh
53 > export MYAREA=rpm_install_area
54 > export SCRAM_ARCH=slc4_ia32_gcc345
55 > source \$MYAREA/\$SCRAM_ARCH/external/apt/0.5.15lorg3.2-CMS3/etc/profile.d/init.sh
56 > source \$DBS_SERVER_ROOT/etc/profile.d/init.sh
57 > # set DBS DBs
58 > MYSQL_PORT=3316
59 > MYSQL_PATH=\$MYSQL_ROOT/mysqldb
60 > MYSQL_SOCK=\$MYSQL_PATH/mysql.sock
61 > MYSQL_PID=\$MYSQL_PATH/mysqld.pid
62 > MYSQL_ERR=\$MYSQL_PATH/error.log
63 >
64 > function dbs_stop()
65 > {
66 >    echo $"Stop mysqld|tomcat running under `whoami` account..."
67 >    ps -w -w -f -u`whoami` | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "\$2""}'|/bin/sh
68 > }
69 > function dbs_start()
70 > {
71 >    echo "+++ Start up CMS MySQL daemon on port \${MYSQL_PORT} ..."
72 >    \$MYSQL_ROOT/bin/mysqld_safe --datadir=\$MYSQL_PATH --port=\$MYSQL_PORT \
73 >    --socket=\$MYSQL_SOCK --log-error=\$MYSQL_ERR --pid-file=\$MYSQL_PID &
74 >    echo "+++ Start tomcat server"
75 >    \$APACHE_TOMCAT_ROOT/bin/catalina.sh start
76 >    sleep 2
77 >    echo
78 >    echo "DBS service is ready ..."
79 > }
80 > function dbs_status()
81 > {
82 >    me=\`whoami\`
83 >    dbs_mysqld=\`ps -w -w -f -u\$me | egrep "mysqld" | grep -v egrep | wc -l\`
84 >    dbs_tomcat=\`ps -w -w -f -u\$me | egrep "tomcat" | grep -v egrep | wc -l\`
85 >    if [ \${dbs_tomcat} -ne 1 ]; then
86 >       echo "Tomcat server is not running"
87 >       exit 1
88 >    fi
89 >    if [ \${dbs_mysqld} -ne 2 ]; then
90 >       echo "MySQL server is not running"
91 >       exit 1
92 >    fi
93 >    ps -w -w -f -u`whoami` | egrep "mysqld" | grep -v egrep | awk '{print "MySQLd server running, pid="\$2""}'
94 >    ps -w -w -f -u`whoami` | egrep "tomcat" | grep -v egrep | awk '{print "Tomcat server running, pid="\$2""}'
95 >    echo "For more information please have a look at tomcat log:"
96 >    echo "\$APACHE_TOMCAT_ROOT/logs/catalina.out"
97 > }
98 >
99 > RETVAL=\$?
100 >
101 > case "\$1" in
102 > restart)
103 >        dbs_stop
104 >        dbs_start
105 >        ;;
106 > start)
107 >        dbs_start
108 >        ;;
109 > status)
110 >        dbs_status
111 >        ;;
112 > stop)
113 >        dbs_stop
114 >        ;;
115 > *)
116 >        echo \$"Usage: \$0 {start|stop|status|restart}"
117 >        exit 1
118 >        ;;
119 > esac
120 >
121 > exit \$RETVAL
122 > DBS_INIT_EOF
123 > chmod a+x %{i}/Servers/JavaServer/bin/dbs_init.sh
124 >
125 > mkdir -p %{i}/etc/profile.d
126 > (echo "#!/bin/sh"; \
127 > echo "source $ORACLE_ROOT/etc/profile.d/init.sh"; \
128 > echo "source $MYSQL_ROOT/etc/profile.d/init.sh"; \
129 > echo "source $MYSQL_DEPLOYMENT_ROOT/etc/profile.d/init.sh"; \
130 > echo "source $APACHE_TOMCAT_ROOT/etc/profile.d/init.sh"; \
131 > echo "source $APACHE_ANT_ROOT/etc/profile.d/init.sh"; \
132 > echo "source $DBS_SCHEMA_ROOT/etc/profile.d/init.sh"; \
133 > echo "source $JAVA_JDK_ROOT/etc/profile.d/init.sh"; \
134 > echo "export JAVA_HOME=$JAVA_JDK_ROOT"
135 > echo "export CATALINA_HOME=$APACHE_TOMCAT_ROOT"
136 > ) > %{i}/etc/profile.d/dependencies-setup.sh
137 >
138 > (echo "#!/bin/tcsh"; \
139 > echo "source $ORACLE_ROOT/etc/profile.d/init.csh"; \
140 > echo "source $MYSQL_ROOT/etc/profile.d/init.csh"; \
141 > echo "source $MYSQL_DEPLOYMENT_ROOT/etc/profile.d/init.csh"; \
142 > echo "source $APACHE_TOMCAT_ROOT/etc/profile.d/init.csh"; \
143 > echo "source $APACHE_ANT_ROOT/etc/profile.d/init.csh"; \
144 > echo "source $DBS_SCHEMA_ROOT/etc/profile.d/init.csh"; \
145 > echo "source $JAVA_JDK_ROOT/etc/profile.d/init.csh"; \
146 > echo "setenv JAVA_HOME $JAVA_JDK_ROOT"
147 > echo "setenv CATALINA_HOME $APACHE_TOMCAT_ROOT"
148 > ) > %{i}/etc/profile.d/dependencies-setup.csh
149 >
150 >
151 > %post
152 > %{relocateConfig}etc/profile.d/dependencies-setup.sh
153 > %{relocateConfig}etc/profile.d/dependencies-setup.csh
154 >
155 > # setup MySQL server
156 > . $RPM_INSTALL_PREFIX/%{pkgrel}/etc/profile.d/init.sh
157 > VO_CMS_SW_DIR=`echo $DBS_SERVER_ROOT | awk '{split($1,a,SCRAM_ARCH); print a[1]}' SCRAM_ARCH=$SCRAM_ARCH`
158 > export VO_CMS_SW_DIR
159 > $MYSQL_DEPLOYMENT_ROOT/bin/mysql-deployment.sh
160 >
161 > # set DBS DBs
162 > MYSQL_PORT=3316
163 > MYSQL_PATH=$MYSQL_ROOT/mysqldb
164 > MYSQL_SOCK=$MYSQL_PATH/mysql.sock
165 > MYSQL_PID=$MYSQL_PATH/mysqld.pid
166 > MYSQL_ERR=$MYSQL_PATH/error.log
167 > # grant permissions to CMS MySQL DBS account
168 > echo "+++ Grand permission to dbs account, DBS DB ${DBS_SCHEMA_VERSION} ..."
169 > echo "$MYSQL_ROOT/bin/mysql -udbs -pcmsdbs --socket=$MYSQL_SOCK"
170 > echo "$DBS_SCHEMA_ROOT/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql"
171 > # DBS uses trigger which requires to have SUPER priveleges, so we'll create DB using root
172 > # and delegate this to dbs account.
173 > $MYSQL_ROOT/bin/mysql -uroot -pcms --socket=$MYSQL_SOCK < $DBS_SCHEMA_ROOT/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql
174 > $MYSQL_ROOT/bin/mysql --socket=$MYSQL_SOCK -uroot -pcms mysql -e "GRANT ALL ON ${DBS_SCHEMA_VERSION}.* TO dbs@localhost;"
175 >
176 > # I need to copy/deploy DBS.war file into tomcat area
177 > cp $DBS_SERVER_ROOT/Servers/JavaServer/DBS.war $APACHE_TOMCAT_ROOT/webapps
178 >
179 > echo
180 > echo
181 > 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
187 > # Fix path in dbs_init.sh file since now we know install area
188 > cat $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh | sed "s,rpm_install_area,$RPM_INSTALL_PREFIX,g" > \
189 >    $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh.new
190 > mv  $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh.new $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh
191 > chmod a+x $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh
192 >
193 > # time to start up tomcat for user
194 > #$APACHE_TOMCAT_ROOT/bin/catalina.sh start
195  
196 + # kill running mysql|tomcat under my account since build is over
197 + ps -w -w -f -u`whoami` | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "$2""}' |/bin/sh

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines