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.42 by valya, Sat May 3 22:12:39 2008 UTC

# Line 1 | Line 1
1   ### RPM cms dbs-server DBS_1_0_8
2  
3 < %define cvstag %v
3 > %define cvstag %realversion
4 > # define version of DBS to use, it's schema version
5 > %define dbs_version DBS_1_0_8
6 >
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
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"
# Line 13 | Line 18 | 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 <     <SupportedSchemaVersion schemaversion="DBS_1_0_8" />
22 <     <SupportedClientVersions clientversions="DBS_1_0_1, DBS_1_0_5, DBS_1_0_7, DBS_1_0_8, DBS_1_0_9"/>
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"
# Line 26 | Line 32 | cat > etc/context.xml << EOF_CONTEXT
32                username="dbs"
33                password="cmsdbs"
34                driverClassName="org.gjt.mm.mysql.Driver"
35 <              url="jdbc:mysql://localhost:3316/%{cvstag}?autoReconnect=true"/>
35 >              url="jdbc:mysql://localhost:3316/%{dbs_version}?autoReconnect=true"/>
36   </Context>
37   EOF_CONTEXT
38  
# Line 44 | Line 50 | cp -r Servers/JavaServer/* %{i}/Servers/
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"; \
# Line 53 | Line 136 | mkdir -p %{i}/etc/profile.d
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"; \
# Line 63 | Line 148 | mkdir -p %{i}/etc/profile.d
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  
# Line 83 | Line 170 | 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 DB ${DBS_SCHEMA_VERSION} ..."
174 < echo "$MYSQL_ROOT/bin/mysql -udbs -pcmsdbs --socket=$MYSQL_SOCK"
175 < echo "$DBS_SCHEMA_ROOT/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql"
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/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/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql
179 < $MYSQL_ROOT/bin/mysql --socket=$MYSQL_SOCK -uroot -pcms mysql -e "GRANT ALL ON ${DBS_SCHEMA_VERSION}.* TO dbs@localhost;"
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