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.29 by valya, Wed Feb 6 20:38:27 2008 UTC

# Line 1 | Line 1
1 < ### RPM cms dbs-server DBS_1_0_8
1 > ### RPM cms dbs-server DBS_1_0_9
2  
3   %define cvstag %v
4   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
# 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 +    me=\`whoami\`
67 +    echo $"Stop mysqld|tomcat running under \$me account..."
68 +    ps -w -w -f -u\$me | egrep "mysqld|tomcat" | grep -v egrep | awk '{print "kill -9 "\$2""}'|/bin/sh
69 + }
70 + function dbs_start()
71 + {
72 +    echo "+++ Start up CMS MySQL daemon on port \${MYSQL_PORT} ..."
73 +    \$MYSQL_ROOT/bin/mysqld_safe --datadir=\$MYSQL_PATH --port=\$MYSQL_PORT \
74 +    --socket=\$MYSQL_SOCK --log-error=\$MYSQL_ERR --pid-file=\$MYSQL_PID &
75 +    echo "+++ Start tomcat server"
76 +    \$APACHE_TOMCAT_ROOT/bin/catalina.sh start
77 +    sleep 2
78 +    echo
79 +    echo "DBS service is ready ..."
80 + }
81 + function dbs_status()
82 + {
83 +    me=\`whoami\`
84 +    dbs_mysqld=\`ps -w -w -f -u\$me | egrep "mysqld" | grep -v egrep | wc -l\`
85 +    dbs_tomcat=\`ps -w -w -f -u\$me | egrep "tomcat" | grep -v egrep | wc -l\`
86 +    if [ \${dbs_tomcat} -ne 1 ]; then
87 +       echo "Tomcat server is not running"
88 +       exit 1
89 +    fi
90 +    if [ \${dbs_mysqld} -ne 2 ]; then
91 +       echo "MySQL server is not running"
92 +       exit 1
93 +    fi
94 +    ps -w -w -f -u\$me | egrep "mysqld" | grep -v egrep | awk '{print "MySQLd server running, pid="\$2""}'
95 +    ps -w -w -f -u\$me | egrep "tomcat" | grep -v egrep | awk '{print "Tomcat server running, pid="\$2""}'
96 +    echo "For more information please have a look at tomcat log:"
97 +    echo "\$APACHE_TOMCAT_ROOT/logs/catalina.out"
98 + }
99 +
100 + RETVAL=\$?
101 +
102 + case "\$1" in
103 + restart)
104 +        dbs_stop
105 +        dbs_start
106 +        ;;
107 + start)
108 +        dbs_start
109 +        ;;
110 + status)
111 +        dbs_status
112 +        ;;
113 + stop)
114 +        dbs_stop
115 +        ;;
116 + *)
117 +        echo \$"Usage: \$0 {start|stop|status|restart}"
118 +        exit 1
119 +        ;;
120 + esac
121 +
122 + exit \$RETVAL
123 + DBS_INIT_EOF
124 + chmod a+x %{i}/Servers/JavaServer/bin/dbs_init.sh
125 +
126   mkdir -p %{i}/etc/profile.d
127   (echo "#!/bin/sh"; \
128   echo "source $ORACLE_ROOT/etc/profile.d/init.sh"; \
# Line 91 | Line 167 | 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"
170 > #echo "$MYSQL_ROOT/bin/mysql -udbs -pcmsdbs --socket=$MYSQL_SOCK"
171   echo "$DBS_SCHEMA_ROOT/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.
# Line 103 | Line 179 | cp $DBS_SERVER_ROOT/Servers/JavaServer/D
179  
180   echo
181   echo
182 < echo "In order to run DBS server you need to setup the following environment"
183 < echo
184 < echo "#############################################################"
185 < echo "export MYAREA=$RPM_INSTALL_PREFIX"
186 < 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"
182 > echo "#####  IMPORTANT!!!  #####"
183 > echo "For your convinience we created"
184 > echo "$DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh"
185 > echo "init script file which can be placed into /etc/init.d/ to allow auto-startup of DBS service"
186 > echo "##### END OF README  #####"
187   echo
188 <
189 < # create setup file for users convenience
190 < if [ -e $RPM_INSTALL_PREFIX/setup_dbs.sh ]; then
191 <    echo "+++ Found $RPM_INSTALL_PREFIX/setup_dbs.sh, will keep it as $RPM_INSTALL_PREFIX/setup_dbs.sh.bak"
192 <    /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
188 > # Fix path in dbs_init.sh file since now we know install area
189 > cat $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh | sed "s,rpm_install_area,$RPM_INSTALL_PREFIX,g" > \
190 >    $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh.new
191 > mv  $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh.new $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh
192 > chmod a+x $DBS_SERVER_ROOT/Servers/JavaServer/bin/dbs_init.sh
193  
194   # time to start up tomcat for user
195 < $APACHE_TOMCAT_ROOT/bin/catalina.sh start
195 > #$APACHE_TOMCAT_ROOT/bin/catalina.sh start
196  
197 + # kill running mysql|tomcat under my account since build is over
198 + 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