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.23 by valya, Tue Feb 5 16:39:04 2008 UTC vs.
Revision 1.75 by valya, Tue Mar 3 01:52:46 2009 UTC

# Line 1 | Line 1
1 < ### RPM cms dbs-server DBS_1_0_8
1 > ### RPM cms dbs-server DBS_2_0_6_pre2
2 >
3 > %define cvstag %{realversion}
4 > # define version of DBS to use, it's schema version
5 > %define dbs_version %{realversion}
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 mysql-deployment oracle apache-tomcat java-jdk dbs-schema
8 > Requires: apache-ant mysql mysql-deployment oracle apache-tomcat java-jdk dbs-schema dbs-libs
9  
10   %prep
11   %setup -n DBS
12   # kill running mysql|tomcat under my account since build is over
13 < ps -u`whoami` | grep mysqld | awk '{print "kill -9 "$1""}' |/bin/sh
11 < ps -u`whoami` | grep tomcat | awk '{print "kill -9 "$1""}' |/bin/sh
13 > ps -w -w -f -u`whoami` | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "$2""}' |/bin/sh
14  
15   %build
16 + # DBS wants to have LibValut attached to DBS top-level dir, required by build.xml file
17 + ln -s $DBS_LIBS_ROOT/lib LibValut
18   echo "PWD=$PWD"
19   cd Servers/JavaServer
20 +
21 + # retrieve which DBS schema to use
22 + #export DBS_SCHEMA=`grep "^use " $DBS_SCHEMA_ROOT/lib/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql | awk '{print $2}' | sed "s/;//g"`
23 + #export DBS_SCHEMA_VERSION=`cat  $DBS_SCHEMA_ROOT/lib/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql | grep "INSERT INTO SchemaVersion" | awk '{split($0,a,"\x27"); print a[2]}'`
24 +
25   # fix context.xml file
26 < cat > etc/context.xml << EOF_CONTEXT
18 < <Context path="/servlet/DBSServlet" docBase="DBSServlet" debug="5" reloadable="true" crossContext="true">
19 <     <SupportedSchemaVersion schemaversion="DBS_1_0_8" />
20 <     <SupportedClientVersions clientversions="DBS_1_0_1, DBS_1_0_5, DBS_1_0_7, DBS_1_0_8, DBS_1_0_9"/>
21 <     <DBSBlockConfig maxBlockSize="2000000000000" maxBlockFiles="100" />
22 <                        
23 <     <Resource name="jdbc/dbs"
24 <              auth="Container"
25 <              type="javax.sql.DataSource"
26 <              maxActive="30"
27 <              maxIdle="10"
28 <              maxWait="10000"
29 <              username="dbs"
30 <              password="cmsdbs"
31 <              driverClassName="org.gjt.mm.mysql.Driver"
32 <              url="jdbc:mysql://localhost:3316/%{cvstag}?autoReconnect=true"/>
33 < </Context>
34 < EOF_CONTEXT
26 > cat etc/context.xml.tobe  | sed "s/__insert_username__/dbs/g" | sed "s/__insert_password__/cmsdbs/g" | sed "s/3306/3316/g" | sed "s/maxActive=\"0\"/maxActive=\"100\"/g" > etc/context.xml
27  
28 + # compile DBS server code
29   mkdir -p bin/WEB-INF/lib
30   echo "PWD=$PWD"
31   source $JAVA_JDK_ROOT/etc/profile.d/init.sh
# Line 43 | Line 36 | cd ../../
36   %install
37   mkdir -p %{i}/Servers/JavaServer/bin/WEB-INF/lib
38   cp -r Servers/JavaServer/* %{i}/Servers/JavaServer
39 + ln -s $DBS_LIBS_ROOT/lib %{i}/LibValut
40  
41   # copy war file
42   cp %{i}/Servers/JavaServer/DBS.war $APACHE_TOMCAT_ROOT/webapps
43  
44 + # create dbs init script
45 + mkdir -p %{i}/Servers/JavaServer/bin
46 + cat > %{i}/Servers/JavaServer/bin/dbs_init.sh << DBS_INIT_EOF
47 + #!/bin/sh
48 + export MYAREA=rpm_install_area
49 + export SCRAM_ARCH=slc4_ia32_gcc345
50 + export APT_VERSION=0.5.15lorg3.2-cmp
51 + source \$MYAREA/\$SCRAM_ARCH/external/apt/\$APT_VERSION/etc/profile.d/init.sh
52 + source \$MYAREA/%{pkgrel}/etc/profile.d/init.sh
53 + # set DBS DBs
54 + MYSQL_PORT=3316
55 + MYSQL_PATH=\$MYSQL_ROOT/mysqldb
56 + MYSQL_SOCK=\$MYSQL_PATH/mysql.sock
57 + MYSQL_PID=\$MYSQL_PATH/mysqld.pid
58 + MYSQL_ERR=\$MYSQL_PATH/error.log
59 +
60 + function dbs_stop()
61 + {
62 +    me=\`whoami\`
63 +    echo $"Stop mysqld|tomcat running under \$me account..."
64 +    $MYSQL_ROOT/bin/mysqladmin -uroot -pcms --socket=$MYSQL_SOCK --port=$MYSQL_PORT shutdown
65 +    ps -w -w -f -u\$me | grep mysqld | grep $MYSQL_PORT | grep -v grep | awk '{print "kill -9 "\$2""}'|/bin/sh
66 +    killall -q tomcat
67 + }
68 + function dbs_start()
69 + {
70 +    echo "+++ Start up CMS MySQL daemon on port \${MYSQL_PORT} ..."
71 +    \$MYSQL_ROOT/bin/mysqld_safe --datadir=\$MYSQL_PATH --port=\$MYSQL_PORT \
72 +    --socket=\$MYSQL_SOCK --log-error=\$MYSQL_ERR --pid-file=\$MYSQL_PID --max_allowed_packet=32M &
73 +    echo "+++ Start tomcat server"
74 +    \$APACHE_TOMCAT_ROOT/bin/catalina.sh start
75 +    sleep 2
76 +    echo
77 +    echo "DBS service is ready ..."
78 + }
79 + function dbs_status()
80 + {
81 +    me=\`whoami\`
82 +    dbs_mysqld=\`ps -w -w -f -u\$me | egrep "mysqld" | grep $MYSQL_PORT| grep -v egrep | wc -l\`
83 +    dbs_tomcat=\`ps -w -w -f -u\$me | egrep "tomcat" | grep -v egrep | wc -l\`
84 +    if [ \${dbs_tomcat} -ne 1 ]; then
85 +       echo "Tomcat server is not running"
86 +       exit 1
87 +    fi
88 +    if [ \${dbs_mysqld} -ne 2 ]; then
89 +       echo "MySQL server is not running"
90 +       exit 1
91 +    fi
92 +    ps -w -w -f -u\$me | egrep "mysqld" | grep -v egrep | awk '{print "MySQLd server running, pid="\$2""}'
93 +    ps -w -w -f -u\$me | egrep "tomcat" | grep -v egrep | awk '{print "Tomcat server running, pid="\$2""}'
94 +    echo "For more information please have a look at tomcat log:"
95 +    echo "\$APACHE_TOMCAT_ROOT/logs/catalina.out"
96 + }
97 +
98 + RETVAL=\$?
99 +
100 + case "\$1" in
101 + restart)
102 +        dbs_stop
103 +        dbs_start
104 +        ;;
105 + start)
106 +        dbs_start
107 +        ;;
108 + status)
109 +        dbs_status
110 +        ;;
111 + stop)
112 +        dbs_stop
113 +        ;;
114 + *)
115 +        echo \$"Usage: \$0 {start|stop|status|restart}"
116 +        exit 1
117 +        ;;
118 + esac
119 +
120 + exit \$RETVAL
121 + DBS_INIT_EOF
122 + chmod a+x %{i}/Servers/JavaServer/bin/dbs_init.sh
123 +
124   mkdir -p %{i}/etc/profile.d
125   (echo "#!/bin/sh"; \
126   echo "source $ORACLE_ROOT/etc/profile.d/init.sh"; \
# Line 55 | Line 129 | mkdir -p %{i}/etc/profile.d
129   echo "source $APACHE_TOMCAT_ROOT/etc/profile.d/init.sh"; \
130   echo "source $APACHE_ANT_ROOT/etc/profile.d/init.sh"; \
131   echo "source $DBS_SCHEMA_ROOT/etc/profile.d/init.sh"; \
132 + echo "source $DBS_LIBS_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"
# Line 67 | Line 142 | mkdir -p %{i}/etc/profile.d
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 $DBS_LIBS_ROOT/etc/profile.d/init.csh"; \
146   echo "source $JAVA_JDK_ROOT/etc/profile.d/init.csh"; \
147   echo "setenv JAVA_HOME $JAVA_JDK_ROOT"
148   echo "setenv CATALINA_HOME $APACHE_TOMCAT_ROOT"
# Line 90 | Line 166 | MYSQL_SOCK=$MYSQL_PATH/mysql.sock
166   MYSQL_PID=$MYSQL_PATH/mysqld.pid
167   MYSQL_ERR=$MYSQL_PATH/error.log
168   # grant permissions to CMS MySQL DBS account
169 < echo "+++ Grand permission to dbs account, DBS DB ${DBS_SCHEMA_VERSION} ..."
170 < echo "$MYSQL_ROOT/bin/mysql -udbs -pcmsdbs --socket=$MYSQL_SOCK"
171 < echo "$DBS_SCHEMA_ROOT/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql"
169 > echo "+++ Grand permission to dbs account, DBS schema %{dbs_version} ..."
170 > #echo "$MYSQL_ROOT/bin/mysql -udbs -pcmsdbs --socket=$MYSQL_SOCK"
171 > echo "$DBS_SCHEMA_ROOT/lib/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql"
172   # DBS uses trigger which requires to have SUPER priveleges, so we'll create DB using root
173   # and delegate this to dbs account.
174 < $MYSQL_ROOT/bin/mysql -uroot -pcms --socket=$MYSQL_SOCK < $DBS_SCHEMA_ROOT/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql
175 < $MYSQL_ROOT/bin/mysql --socket=$MYSQL_SOCK -uroot -pcms mysql -e "GRANT ALL ON ${DBS_SCHEMA_VERSION}.* TO dbs@localhost;"
174 > export DBS_SCHEMA=`grep "^use " $DBS_SCHEMA_ROOT/lib/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql | awk '{print $2}' | sed "s/;//g"`
175 > $MYSQL_ROOT/bin/mysql -uroot -pcms --port=$MYSQL_PORT --socket=$MYSQL_SOCK < $DBS_SCHEMA_ROOT/lib/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql
176 > $MYSQL_ROOT/bin/mysql --socket=$MYSQL_SOCK --port=$MYSQL_PORT -uroot -pcms mysql -e "GRANT ALL ON ${DBS_SCHEMA}.* TO dbs@localhost;"
177  
178   # I need to copy/deploy DBS.war file into tomcat area
179   cp $DBS_SERVER_ROOT/Servers/JavaServer/DBS.war $APACHE_TOMCAT_ROOT/webapps
180  
181 + # Copy mysql jdbc driver to tomcat
182 + cp -f $DBS_LIBS_ROOT/lib/*.jar $APACHE_TOMCAT_ROOT/common/lib
183 +
184 + # Fix path in dbs_init.sh file since now we know install area
185 + cat $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh | sed "s,rpm_install_area,$RPM_INSTALL_PREFIX,g" > \
186 +    $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh.new
187 + /bin/mv -f $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh.new $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh
188 + echo "+++ Fix path in dbs_init.sh"
189 + chmod a+x $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh
190 +
191 + # time to start up tomcat for user
192 + #$APACHE_TOMCAT_ROOT/bin/catalina.sh start
193 +
194 + # kill running mysql|tomcat under my account since build is over
195 + echo "+++ Clean-up mysqld|tomcat processes"
196 + #ps -w -w -f -u`whoami` | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "$2""}'
197 + #ps -w -w -f -u`whoami` | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "$2""}' |/bin/sh
198 + #killall -q mysqld
199 + #cat $MYSQL_ROOT/mysqldb/mysqld.pid
200 + $MYSQL_ROOT/bin/mysqladmin -uroot -pcms --socket=$MYSQL_SOCK --port=$MYSQL_PORT shutdown
201 + killall -q tomcat
202 +
203 + # made correct link to LibValut
204 + rm -f $DBS_SERVER_ROOT/LibValut
205 + ln -s $DBS_LIBS_ROOT/lib $DBS_SERVER_ROOT/LibValut
206 +
207   echo
208   echo
209 < echo "In order to run DBS server you need to setup the following environment"
210 < echo
211 < echo "#############################################################"
109 < echo "export MYAREA=$RPM_INSTALL_PREFIX"
110 < echo "export SCRAM_ARCH=slc4_ia32_gcc345"
111 < echo "source $MYAREA/slc4_ia32_gcc345/external/apt/0.5.15lorg3.2-CMS3/etc/profile.d/init.sh"
112 < echo "source $DBS_SERVER_ROOT/etc/profile.d/init.sh"
113 < 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 "For your convinience we created setup_dbs.sh file with this settings"
214 < echo "It should be executed each time when you need to start DBS"
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  
119 # create setup file for users convenience
120 if [ -e $RPM_INSTALL_PREFIX/setup_dbs.sh ]; then
121    echo "+++ Found $RPM_INSTALL_PREFIX/setup_dbs.sh, will keep it as $RPM_INSTALL_PREFIX/setup_dbs.sh.bak"
122    /bin/mv -f $RPM_INSTALL_PREFIX/setup_dbs.sh $RPM_INSTALL_PREFIX/setup_dbs.sh.bak
123 else
124    echo "+++ File $RPM_INSTALL_PREFIX/setup_dbs.sh not found, will create"
125 cat > $RPM_INSTALL_PREFIX/setup_dbs.sh << EOF2
126 #!/bin/sh
127 export MYAREA=$RPM_INSTALL_PREFIX
128 export SCRAM_ARCH=slc4_ia32_gcc345
129 source $MYAREA/slc4_ia32_gcc345/external/apt/0.5.15lorg3.2-CMS3/etc/profile.d/init.sh
130 source $DBS_SERVER_ROOT/etc/profile.d/init.sh
131 ps -u`whoami` | egrep "mysqld|tomcat" | awk '{print "kill -9 "$1""}' |/bin/sh
132 echo "+++ Start up CMS MySQL daemon on port ${MYSQL_PORT} ..."
133 $MYSQL_ROOT/bin/mysqld_safe --datadir=$MYSQL_PATH --port=$MYSQL_PORT \
134 --socket=$MYSQL_SOCK --log-error=$MYSQL_ERR --pid-file=$MYSQL_PID &
135 echo "+++ Start tomcat server"
136 $APACHE_TOMCAT_ROOT/bin/catalina.sh start
137 EOF2
138    chmod a+x $RPM_INSTALL_PREFIX/setup_dbs.sh
139 fi
140
141 # time to start up tomcat for user
142 $APACHE_TOMCAT_ROOT/bin/catalina.sh start
143

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines