系统升级shell

  1 #!/bin/sh
  2 #3.0.2.2->
  3 
  4 updatefiledir=$1 #/home/temp
  5 tomcatdir=$2    #/home/eduyun/eduyun
  6 
  7 
  8 
  9 
 10 backup="/home/eduyunbackup/$(date +%Y%m%d%H%M)"
 11 
 12 if [ ! -d $backup ]; then
 13    mkdir -p $backup
 14 fi
 15 
 16 logfile=$backup"/update.log"
 17 
 18 echo "shell input value1="$1 >> $logfile
 19 echo "shell input value2="$2 >> $logfile
 20 
 21 if [ "$updatefiledir" =  "" ]; then
 22  echo "shell input is null,shell exit" >> $logfile
 23  exit 0
 24 fi
 25 
 26 if [ "$tomcatdir" =  "" ]; then
 27  echo "shell input is null,shell exit" >> $logfile
 28 
 29  exit 0
 30 
 31 fi
 32 
 33 echo "start update ,stop sevices">> $logfile
 34 
 35 kill -9 `ps -A  | grep svr_timer.sh | awk '{print $1}'`
 36 kill -9 $(pidof java)
 37 echo "stoped tomcat ">>$logfile
 38 
 39 #update tomcat
 40 if [  -d "$updatefiledir/tomcat" ]; then
 41        echo "tomcat need update,begin to update">>$logfile
 42         #tomcat exist  update tomcat
 43         mkdir -p $backup/eduyunbak
 44     cp -rf $tomcatdir/*   $backup/eduyunbak
 45        echo "$tomcatdir backup finish">>$logfile
 46         rm -r $tomcatdir/*
 47         echo "delete $tomcatdir">>$logfile
 48     cp -rf $updatefiledir/tomcat/*  $tomcatdir/
 49         echo "tomcat update finish...........">>$logfile
 50         cp -rf $backup/eduyunbak/webapps/*  $tomcatdir/webapps/
 51      echo "chmod tomcat shell...........">>$logfile
 52      chmod 777 $tomcatdir/bin/*.sh     
 53      if [  -d "$tomcatdir/jre" ]; then
 54          chmod 777 $tomcatdir/jre/bin/* 
 55      fi
 56 fi
 57 
 58 #delete /home/eduyun/eduyun/webapps/ROOT/WEB-INF/lib/*
 59 rm -rf $tomcatdir/webapps/ROOT/WEB-INF/lib/*
 60 
 61 #update ROOT
 62 if [  -d "$updatefiledir/ROOT" ]; then
 63 
 64      echo "eduyun-java need to  update,begin to update">>$logfile
 65         #ROOT  exist  update tomcat
 66         cp -rf $updatefiledir/ROOT/*  $tomcatdir/webapps/ROOT/
 67         #copy libso
 68 
 69         #cp -rf $tomcatdir/webapps/ROOT/WEB-INF/classes/libso/centercontrol/linux/*  /usr/lib/
 70         #chmod -R 777 /usr/lib/*.bin
 71         #chmod -R 777 /usr/lib/ffserver
 72         #cp -rf /usr/lib/servercnfg.xml /usr/etc/servercnfg.xml
 73 
 74 fi
 75 
 76 #update /usr/etc/servercnfg.xml
 77  if [ -d "/usr/etc" ];then
 78     echo "update /usr/etc/servercnfg.xml">>$logfile
 79     if [ $(getconf WORD_BIT) = '32' ] && [ $(getconf LONG_BIT) = '64' ] ; then
 80         if [ ! `grep "cc1path" /usr/etc/servercnfg.xml` ];then
 81             sed -i '11i <cc1path>/home/eduyun/eduyun/webapps/ROOT/WEB-INF/classes/libso/centercontrol/linux/x64</cc1path>' /usr/etc/servercnfg.xml
 82         else
 83             sed -i 's!<cc1path>/usr/lib</cc1path>!<cc1path>/home/eduyun/eduyun/webapps/ROOT/WEB-INF/classes/libso/centercontrol/linux/x64</cc1path>!g' /usr/etc/servercnfg.xml
 84         fi
 85     else
 86         if [ ! `grep "cc1path" /usr/etc/servercnfg.xml` ];then
 87             sed -i '11i <cc1path>/home/eduyun/eduyun/webapps/ROOT/WEB-INF/classes/libso/centercontrol/linux/x86</cc1path>' /usr/etc/servercnfg.xml
 88         else
 89             sed -i 's!<cc1path>/usr/lib</cc1path>!<cc1path>/home/eduyun/eduyun/webapps/ROOT/WEB-INF/classes/libso/centercontrol/linux/x86</cc1path>!g' /usr/etc/servercnfg.xml 
 90         fi
 91 
 92     fi
 93     
 94  
 95  fi
 96 
 97 #update /etc/environment
 98 if [ -d "/etc" ];then
 99     echo "update /etc/environment">>$logfile
100     if [ $(getconf WORD_BIT) = '32' ] && [ $(getconf LONG_BIT) = '64' ] ; then
101         sed -i 's!/convert/linux!/centercontrol/linux/x64!g' /etc/environment
102         if [ ! `grep "RECSVR_APP_PATH" /etc/environment` ];then
103             echo 'RECSVR_APP_PATH="/home/eduyun/eduyun/webapps/ROOT/WEB-INF/classes/libso/centercontrol/linux/x64"'>>/etc/environment
104         fi
105     else
106         sed -i 's!/convert/linux!/centercontrol/linux/x86!g' /etc/environment
107         if [ ! `grep "RECSVR_APP_PATH" /etc/environment` ];then
108             echo 'RECSVR_APP_PATH="/home/eduyun/eduyun/webapps/ROOT/WEB-INF/classes/libso/centercontrol/linux/x86"'>>/etc/environment
109         fi
110     fi
111 fi
112 
113 
114 
115     
116     
117 echo "update completed ,start tomcat ">>$logspath$logfile
118 
119 
120 
121 sudo reboot
122 #cd $tomcatdir/bin
123 #./svr_timer.sh &

 

posted @ 2018-04-18 12:01  Againn  阅读(376)  评论(0编辑  收藏  举报