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.26 by valya, Tue Feb 5 21:16:30 2008 UTC

# Line 7 | Line 7 | Requires: apache-ant mysql mysql-deploym
7   %prep
8   %setup -n DBS
9   # kill running mysql|tomcat under my account since build is over
10 < 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
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"
# Line 47 | 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 91 | 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.
# Line 103 | Line 178 | cp $DBS_SERVER_ROOT/Servers/JavaServer/D
178  
179   echo
180   echo
181 < echo "In order to run DBS server you need to setup the following environment"
182 < echo
183 < echo "#############################################################"
184 < echo "export MYAREA=$RPM_INSTALL_PREFIX"
185 < 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 "#############################################################"
114 < echo
115 < echo "For your convinience we created setup_dbs.sh file with this settings"
116 < echo "It should be executed each time when you need to start DBS"
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 <
188 < # create setup file for users convenience
189 < if [ -e $RPM_INSTALL_PREFIX/setup_dbs.sh ]; then
190 <    echo "+++ Found $RPM_INSTALL_PREFIX/setup_dbs.sh, will keep it as $RPM_INSTALL_PREFIX/setup_dbs.sh.bak"
191 <    /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
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
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