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.21 by valya, Wed Jan 16 19:23:40 2008 UTC vs.
Revision 1.26 by valya, Tue Feb 5 21:16:30 2008 UTC

# Line 6 | Line 6 | Requires: apache-ant mysql mysql-deploym
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   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"
# Line 22 | Line 29 | cat > etc/context.xml << EOF_CONTEXT
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
# Line 38 | Line 46 | cp -r Servers/JavaServer/* %{i}/Servers/
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 \$MYAREA/%{pkgrel}/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"; \
# Line 47 | Line 131 | mkdir -p %{i}/etc/profile.d
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"; \
# Line 57 | Line 143 | mkdir -p %{i}/etc/profile.d
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  
# Line 78 | Line 166 | 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"
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