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.8 by valya, Wed Mar 28 23:31:43 2007 UTC vs.
Revision 1.61 by valya, Tue Nov 4 14:31:44 2008 UTC

# Line 1 | Line 1
1 < ### RPM cms dbs-server pre4_v01_00_00
1 > ### RPM cms dbs-server DBS_2_0_3
2 >
3 >
4 > %define cvstag %{realversion}
5 > # define version of DBS to use, it's schema version
6 > %define dbs_version %{realversion}
7  
3 %define cvstag %v
8   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
9 < Requires: apache-ant mysql oracle apache-tomcat
6 < #Requires: apache-ant mysql oracle apache-tomcat java-jdk
7 < #Requires: apache-ant apache-tomcat
9 > Requires: apache-ant mysql mysql-deployment oracle apache-tomcat java-jdk dbs-schema dbs-libs
10  
11   %prep
12   %setup -n DBS
13 + # kill running mysql|tomcat under my account since build is over
14 + ps -w -w -f -u`whoami` | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "$2""}' |/bin/sh
15 +
16   %build
17 + # DBS wants to have LibValut attached to DBS top-level dir, required by build.xml file
18 + ln -s $DBS_LIBS_ROOT/lib LibValut
19   echo "PWD=$PWD"
20   cd Servers/JavaServer
21 +
22 + # retrieve which DBS schema to use
23 + #export DBS_SCHEMA=`grep "^use " $DBS_SCHEMA_ROOT/lib/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql | awk '{print $2}' | sed "s/;//g"`
24 + #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]}'`
25 +
26 + # fix context.xml file
27 + 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
28 +
29 + # compile DBS server code
30 + mkdir -p bin/WEB-INF/lib
31   echo "PWD=$PWD"
32 + source $JAVA_JDK_ROOT/etc/profile.d/init.sh
33 + export JAVA_HOME=$JAVA_JDK_ROOT
34   ant --noconfig dist
35   cd ../../
36  
37   %install
38 < mkdir -p %{i}/Servers/JavaServer/
38 > mkdir -p %{i}/Servers/JavaServer/bin/WEB-INF/lib
39   cp -r Servers/JavaServer/* %{i}/Servers/JavaServer
40 + ln -s $DBS_LIBS_ROOT/lib %{i}/LibValut
41  
42   # copy war file
43   cp %{i}/Servers/JavaServer/DBS.war $APACHE_TOMCAT_ROOT/webapps
44  
45 + # create dbs init script
46 + mkdir -p %{i}/Servers/JavaServer/bin
47 + cat > %{i}/Servers/JavaServer/bin/dbs_init.sh << DBS_INIT_EOF
48 + #!/bin/sh
49 + export MYAREA=rpm_install_area
50 + export SCRAM_ARCH=slc4_ia32_gcc345
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 +    ps -w -w -f -u\$me | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "\$2""}'|/bin/sh
65 + }
66 + function dbs_start()
67 + {
68 +    echo "+++ Start up CMS MySQL daemon on port \${MYSQL_PORT} ..."
69 +    \$MYSQL_ROOT/bin/mysqld_safe --datadir=\$MYSQL_PATH --port=\$MYSQL_PORT \
70 +    --socket=\$MYSQL_SOCK --log-error=\$MYSQL_ERR --pid-file=\$MYSQL_PID --max_allowed_packet=32M &
71 +    echo "+++ Start tomcat server"
72 +    \$APACHE_TOMCAT_ROOT/bin/catalina.sh start
73 +    sleep 2
74 +    echo
75 +    echo "DBS service is ready ..."
76 + }
77 + function dbs_status()
78 + {
79 +    me=\`whoami\`
80 +    dbs_mysqld=\`ps -w -w -f -u\$me | egrep "mysqld" | grep -v egrep | wc -l\`
81 +    dbs_tomcat=\`ps -w -w -f -u\$me | egrep "tomcat" | grep -v egrep | wc -l\`
82 +    if [ \${dbs_tomcat} -ne 1 ]; then
83 +       echo "Tomcat server is not running"
84 +       exit 1
85 +    fi
86 +    if [ \${dbs_mysqld} -ne 2 ]; then
87 +       echo "MySQL server is not running"
88 +       exit 1
89 +    fi
90 +    ps -w -w -f -u\$me | egrep "mysqld" | grep -v egrep | awk '{print "MySQLd server running, pid="\$2""}'
91 +    ps -w -w -f -u\$me | egrep "tomcat" | grep -v egrep | awk '{print "Tomcat server running, pid="\$2""}'
92 +    echo "For more information please have a look at tomcat log:"
93 +    echo "\$APACHE_TOMCAT_ROOT/logs/catalina.out"
94 + }
95 +
96 + RETVAL=\$?
97 +
98 + case "\$1" in
99 + restart)
100 +        dbs_stop
101 +        dbs_start
102 +        ;;
103 + start)
104 +        dbs_start
105 +        ;;
106 + status)
107 +        dbs_status
108 +        ;;
109 + stop)
110 +        dbs_stop
111 +        ;;
112 + *)
113 +        echo \$"Usage: \$0 {start|stop|status|restart}"
114 +        exit 1
115 +        ;;
116 + esac
117 +
118 + exit \$RETVAL
119 + DBS_INIT_EOF
120 + chmod a+x %{i}/Servers/JavaServer/bin/dbs_init.sh
121 +
122   mkdir -p %{i}/etc/profile.d
123   (echo "#!/bin/sh"; \
124   echo "source $ORACLE_ROOT/etc/profile.d/init.sh"; \
125   echo "source $MYSQL_ROOT/etc/profile.d/init.sh"; \
126 + echo "source $MYSQL_DEPLOYMENT_ROOT/etc/profile.d/init.sh"; \
127   echo "source $APACHE_TOMCAT_ROOT/etc/profile.d/init.sh"; \
128   echo "source $APACHE_ANT_ROOT/etc/profile.d/init.sh"; \
129 + echo "source $DBS_SCHEMA_ROOT/etc/profile.d/init.sh"; \
130 + echo "source $DBS_LIBS_ROOT/etc/profile.d/init.sh"; \
131   echo "source $JAVA_JDK_ROOT/etc/profile.d/init.sh"; \
132 + echo "export JAVA_HOME=$JAVA_JDK_ROOT"
133 + echo "export CATALINA_HOME=$APACHE_TOMCAT_ROOT"
134   ) > %{i}/etc/profile.d/dependencies-setup.sh
135  
136   (echo "#!/bin/tcsh"; \
137   echo "source $ORACLE_ROOT/etc/profile.d/init.csh"; \
138   echo "source $MYSQL_ROOT/etc/profile.d/init.csh"; \
139 + echo "source $MYSQL_DEPLOYMENT_ROOT/etc/profile.d/init.csh"; \
140   echo "source $APACHE_TOMCAT_ROOT/etc/profile.d/init.csh"; \
141   echo "source $APACHE_ANT_ROOT/etc/profile.d/init.csh"; \
142 + echo "source $DBS_SCHEMA_ROOT/etc/profile.d/init.csh"; \
143 + echo "source $DBS_LIBS_ROOT/etc/profile.d/init.csh"; \
144   echo "source $JAVA_JDK_ROOT/etc/profile.d/init.csh"; \
145 + echo "setenv JAVA_HOME $JAVA_JDK_ROOT"
146 + echo "setenv CATALINA_HOME $APACHE_TOMCAT_ROOT"
147   ) > %{i}/etc/profile.d/dependencies-setup.csh
148  
149  
150   %post
151   %{relocateConfig}etc/profile.d/dependencies-setup.sh
152   %{relocateConfig}etc/profile.d/dependencies-setup.csh
153 +
154 + # setup MySQL server
155 + . $RPM_INSTALL_PREFIX/%{pkgrel}/etc/profile.d/init.sh
156 + VO_CMS_SW_DIR=`echo $DBS_SERVER_ROOT | awk '{split($1,a,SCRAM_ARCH); print a[1]}' SCRAM_ARCH=$SCRAM_ARCH`
157 + export VO_CMS_SW_DIR
158 + $MYSQL_DEPLOYMENT_ROOT/bin/mysql-deployment.sh
159 +
160 + # set DBS DBs
161 + MYSQL_PORT=3316
162 + MYSQL_PATH=$MYSQL_ROOT/mysqldb
163 + MYSQL_SOCK=$MYSQL_PATH/mysql.sock
164 + MYSQL_PID=$MYSQL_PATH/mysqld.pid
165 + MYSQL_ERR=$MYSQL_PATH/error.log
166 + # grant permissions to CMS MySQL DBS account
167 + echo "+++ Grand permission to dbs account, DBS schema %{dbs_version} ..."
168 + #echo "$MYSQL_ROOT/bin/mysql -udbs -pcmsdbs --socket=$MYSQL_SOCK"
169 + echo "$DBS_SCHEMA_ROOT/lib/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql"
170 + # DBS uses trigger which requires to have SUPER priveleges, so we'll create DB using root
171 + # and delegate this to dbs account.
172 + export DBS_SCHEMA=`grep "^use " $DBS_SCHEMA_ROOT/lib/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql | awk '{print $2}' | sed "s/;//g"`
173 + $MYSQL_ROOT/bin/mysql -uroot -pcms --port=$MYSQL_PORT --socket=$MYSQL_SOCK < $DBS_SCHEMA_ROOT/lib/Schema/NeXtGen/DBS-NeXtGen-MySQL_DEPLOYABLE.sql
174 + $MYSQL_ROOT/bin/mysql --socket=$MYSQL_SOCK --port=$MYSQL_PORT -uroot -pcms mysql -e "GRANT ALL ON ${DBS_SCHEMA}.* 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 + # Copy mysql jdbc driver to tomcat
180 + cp -f $DBS_LIBS_ROOT/lib/*.jar $APACHE_TOMCAT_ROOT/common/lib
181 +
182 + # Fix path in dbs_init.sh file since now we know install area
183 + cat $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh | sed "s,rpm_install_area,$RPM_INSTALL_PREFIX,g" > \
184 +    $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh.new
185 + /bin/mv -f $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh.new $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh
186 + echo "+++ Fix path in dbs_init.sh"
187 + chmod a+x $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh
188 +
189 + # time to start up tomcat for user
190 + #$APACHE_TOMCAT_ROOT/bin/catalina.sh start
191 +
192 + # kill running mysql|tomcat under my account since build is over
193 + echo "+++ Clean-up mysqld|tomcat processes"
194 + #ps -w -w -f -u`whoami` | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "$2""}'
195 + #ps -w -w -f -u`whoami` | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "$2""}' |/bin/sh
196 + #killall -q mysqld
197 + #cat $MYSQL_ROOT/mysqldb/mysqld.pid
198 + $MYSQL_ROOT/bin/mysqladmin -uroot -pcms --socket=$MYSQL_SOCK --port=3316 shutdown
199 + killall -q tomcat
200 +
201 + # made correct link to LibValut
202 + rm -f $DBS_SERVER_ROOT/LibValut
203 + ln -s $DBS_LIBS_ROOT/lib $DBS_SERVER_ROOT/LibValut
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