日期:2014-05-16  浏览次数:21044 次

jdk+mysql+nginx+resin一步安装脚本
#!/bin/bash
#作者:duanyunxi
#版本:v2.0

touch /var/installserver.tmp

##开始准备工作##
echo "##开始准备工作!##"
if [ -f /var/installserver.tmp ]; then
  RETVAL=`grep 'ready' /var/installserver.tmp`
  if [ "$RETVAL" == "" ]; then
      echo "##确认server_2.0的路径!##"
      echo "请输入server_2.0所在的位置,例如:/home/server_2.0.tar.gz"
      INPUT="n"
      until [ "$INPUT" == "Y" ] || [ "$INPUT" == "y" ]
      do
      read SERVERPATH
      echo "您输入server_2.0所在的位置是:$SERVERPATH,请确认(y|n)?"
      read INPUT
      if [ "$INPUT" != "Y" ] && [ "$INPUT" != "y" ]; then
        echo "请确认server_2.0所在的位置后,重新输入:"
      else
        echo "server_2.0所在的位置为:$SERVERPATH"
      fi
      done
      echo "##解压server_2.0!##"
      cd /home
      cp $SERVERPATH /home/server_2.0.tar.gz
      tar xzf server_2.0.tar.gz
      chmod 755 -R server_2.0
      echo "ready  ok!" >> /var/installserver.tmp
      echo "准备工作已经完成!"
      sleep 10
      else
      echo "准备工作已经做过!"
  fi
fi



##开始安装JDK##
echo "##开始安装JDK!##"
if [ -f /var/installserver.tmp ]; then
  RETVAL=`cat /var/installserver.tmp|grep 'jdk'|grep 'successfully'`
  if [ "$RETVAL" == "" ]; then
      cd /home/server_2.0
      chmod u+x ./jdk-6u19-linux-i586.bin
      ./jdk-6u19-linux-i586.bin
      mv jdk1.6.0_19 /usr/local/jdk
      ln -s /usr/local/jdk/bin/java /usr/bin/java
      ln -s /usr/local/jdk/bin/javac /usr/bin/javac
      ln -s /usr/local/jdk/jre /usr/local/jre
      echo "jdk has installed successfully!" >> /var/installserver.tmp
      echo "JDK安装完成!"
      sleep 10
    else
      echo "JDK已经安装过了!"
  fi
fi

##开始配置JDK环境变量##
echo "##开始配置JDK环境变量!##"
if [ -f /var/installserver.tmp ]; then
  RETVAL=`cat /etc/profile|grep 'JAVA_HOME'`
  if [ "$RETVAL" == "" ]; then
      echo "" >> /etc/profile
      echo 'JAVA_HOME=/usr/local/jdk' >> /etc/profile
      echo 'JRE_HOME=/usr/local/jre' >> /etc/profile
      echo 'PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin' >> /etc/profile
      echo 'CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:' >> /etc/profile
      echo 'export JAVA_HOME JRE_HOME PATH CLASSPATH' >> /etc/profile
      source /etc/profile
      echo "JDK环境变量配置完成!"
    else
      echo "JDK环境变量已经配置过了!"
  fi 
  java -version
fi



##开始安装resin##
echo "##开始安装resin!##"
if [ -f /var/installserver.tmp ]; then