Skip to main content

The linux shell scripts made by me which help saving lots of time everyday

#!/bin/bash


# Crude address database


# clear # Clear the screen.


echo "          Command List"
echo "          ------- ----"
echo "Choose one of the following persons:"
echo
echo "[j]update classes and jar to server2"
echo "[r]update reports to server2"
echo "[m]mount server1 and server2"
echo "[u]umount server1 and server2"
echo "[c]commit the codes"
echo




case "$1" in
# Note variable is quoted.
  "j" )
  echo
  echo "copying classes and jar to server2"
  ssh sxu@server1 " make -C /home/sxu/build/presentation/src/"
  cp -f /home/sxu/server1/java/*.jar ~/server2/www/presentation/WEB-INF/lib/
  cp -r /home/sxu/server1/presentation/build/classes ~/server2/www/presentation/WEB-INF/
  cp -r /home/sxu/server1/presentation/config/WEB-INF/ ~/server2/www/presentation/
  ssh root@server2 " rm -rf /usr/local/tomcat/work/Catalina/localhost/* ; /etc/init.d/tu_tomcat restart"
  ;;
# Note double semicolon to terminate each option.


"r" )
  echo
  echo "coping reports to server2"
  ssh sxu@server1 " make -C /home/sxu/build/reports/src/"
  cp -u /home/sxu/server1/reports/build/reports/* /home/sxu/server2/www/presentation/reports/
  
  ssh root@server2 " rm -rf /usr/local/tomcat/work/Catalina/localhost/* ; /etc/init.d/tu_tomcat restart"
  ;;


"m" )
  echo
  echo "mounting server1 and server2"
  sshfs server2:/usr/local /home/sxu/server2
  sshfs server1:/home/sxu/build /home/sxu/server1


  ;;
 
"um" )
  echo
  echo "umounting server1 and server2"
  umount server2
  umount server1
  ;;


  "cdcust13" )
  echo
  echo "changing datasource to tpm on cust13"
  cp -f /home/sxu/server2/tomcat/conf/Catalina/localhost/ROOT.xml-CUST13 /home/sxu/server2/tomcat/conf/Catalina/localhost/ROOT.xml
  ssh root@server2 " /etc/init.d/tu_tomcat restart"
  ;;
 
  "cdsxu" )
  echo
  echo "changing datasource to sxu on dev"
  cp -f /home/sxu/server2/tomcat/conf/Catalina/localhost/ROOT.xml-SXU /home/sxu/server2/tomcat/conf/Catalina/localhost/ROOT.xml
  ssh root@server2 " /etc/init.d/tu_tomcat restart"
  ;;
 
  "c" )
  echo
  echo "unlocking the codes"
  rm -f /home/sxu/server1/.hg/wlock
  echo "commiting codes"
  ssh sxu@server1 " cd build/; hg commit"
  ;;
 
esac


echo


#  Exercise:
#  --------
#  Change the script so it accepts multiple inputs,
#+ instead of terminating after displaying just one address.


exit 0

Comments

Popular posts from this blog

Stretch a row if data overflows in jasper reports

It is very common that some columns of the report need to stretch to show all the content in that column. But  if you just specify the property " stretch with overflow' to that column(we called text field in jasper report world) , it will just stretch that column and won't change other columns, so the row could be ridiculous. Haven't find the solution from internet yet. So I just review the properties in iReport one by one and find two useful properties(the bold highlighted in example below) which resolve the problems.   example:
<band height="20" splitType="Stretch"> <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true"> <reportElement stretchType="RelativeToTallestObject" mode="Opaque" x="192" y="0" width="183" height="20"/> <box leftPadding="2"> <pen lineWidth="0.25"/> …

JasperReports - Configuration Reference

Spring - Operations with jdbcTemplate

This class manages all the database communication and exception handling using a java.sql.Connection that is obtained from the provided DataSource. JdbcTemplate is a stateless and threadsafe class and you can safely instantiate a single instance to be used for each DAO.


Use of Callback Methods
JdbcTemplate is based on a template style of programming common to many other parts of Spring. Some method calls are handled entirely by the JdbcTemplate, while others require the calling class to provide callback methods that contain the implementation for parts of the JDBC workflow. This is another form of Inversion of Control. Your application code hands over the responsibility of managing the database access to the template class. The template class in turn calls back to your application code when it needs some detail processing filled in. These callback methods are allowed to throw a java.sql.SQLException, since the framework will be able to catch this exception and use its built-in excepti…