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.5 by valya, Wed Feb 28 16:02:33 2007 UTC vs.
Revision 1.45 by valya, Wed May 7 18:08:10 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines