ubuntu 10.4 离线安装JDK Java Apache Tomcat Mysql脚本

main.sh

!/bin/bash
CURRENT_PATH=$PWD
log_path=$CURRENT_PATH"/log"
log_file=$log_path"/main.log"
soft_path=$CURRENT_PATH"/CpsInstaller"
cps_path="/home/cps"
apache_path="/home/cps/apache"
resource_path="/home/cps/resource"

echo $log_path
echo $log_file
echo $soft_path
echo $cps_path
echo $apache_path

#create log folder and log file
create_log()
{
    echo "Start to create log folder..."
    if [ -d "$log_path" ]; then
        rm -rf  $log_path
        mkdir $log_path
    else
        mkdir $log_path
    fi
    echo "Create log folder successfully"
    echo "Start to create log file..."
    if [ ! -f "$log_file" ]; then
        touch "$log_file"
    fi
    echo "Create log file successfully"
}

#create cps folder
create_cps_folder()
{
    echo "Start to create cps folder..."
    if [ -d "$cps_path" ]; then
        rm -rf  $cps_path
        mkdir $cps_path
    else
        mkdir $cps_path
    fi
    echo "Create cps folder successfully"
}

#create apache folder
create_apache_folder()
{
    echo "Start to create apache folder..."
    if [ -d "$apache_path" ]; then
        rm -rf $apache_path
        mkdir $apache_path
    else
        mkdir $apache_path
    fi
    echo "Create apache folder successfully"
    echo "Start to create resource folder..."
    if [ -d "$resource_path" ]; then
        rm -rf $resource_path
        mkdir $resource_path
    else
        mkdir $resource_path
    fi
    echo "Create resource folder successfully"
}

#tar CpsInstaller.tar
tar_file()
{
    echo "Start to unzip CpsInstaller.tar..."
    tar -xvf CpsInstaller.tar
    echo "Unzip CpsInstaller.tar successfully"
    echo "Current folder files list:"
    ls -l
}

#install Java
install_java()
{
    echo "Start to install Java..."
    chmod u+x $soft_path"/jdk1.6.0_35.tar"
    cp -a $soft_path"/jdk1.6.0_35.tar" /opt
    cd /opt
    tar -xvf jdk1.6.0_35.tar
    echo "Install Java successfully"
    #   rm -f /opt/jdk-6u35-linux-i586.bin  
}

#config java path
config_javapath()
{
    echo "Start to configure Java environment..."
    echo 'export JAVA_HOME="/opt/jdk1.6.0_35"' >> /etc/profile
    echo 'export JRE_HOME=$JAVA_HOME"/jre"' >> /etc/profile
    echo 'export CLASSPATH=$CLASSPATH:$JAVA_HOME"/lib":$JRE_HOME"/lib"' >> /etc/profile
    echo 'export PATH=$PATH:$JAVA_HOME"/bin":$JRE_HOME"/bin"' >> /etc/profile
    echo "Configure Java environment successfully, it will work after system reboot!"
    #source "/etc/profile"
}

#unzip httpd-2.2.23.tar.gz
tar_apache()
{
    echo "Start to unzip Apache..."
    chmod u+x $soft_path"/httpd-2.2.23.tar.gz"
    cp -a $soft_path"/httpd-2.2.23.tar.gz" $cps_path
    cd $cps_path
    echo "Current path:`pwd`"
    tar -xvf httpd-2.2.23.tar.gz
    echo "unzip apache successfully"
#    rm -f /opt/httpd-2.2.23.tar.gz
}

#pre apache
pre_apache()
{
    echo "Start to pre-configure apache..."
    cd "$cps_path/httpd-2.2.23"
    echo "Current path is : `pwd`"
    ./configure --prefix="$apache_path" --enable-shared=max --enable-module=rewrite --enable-module=so
    echo "Pre-Configure apache successfully"
}

#compile apache
compile_apache()
{
    echo "Start to compile apache..."
    cd "$cps_path/httpd-2.2.23"
    echo "Current path is : `pwd`"
    make
    echo "Compile apache successfully"
}

#install apache
install_apache()
{
echo "Start to install apache..."
    cd "$cps_path/httpd-2.2.23"
    echo "Current path is : `pwd`"
    make install
    echo "Install apache successfully"
}

#start apache service
start_apache()
{
    echo "Start to start apache service..."
    ctlfile = "/etc/init.d/httpd"
    if [ ! -f "$ctlfile" ]; then
        cp "$apache_path/bin/apachectl" /etc/init.d/httpd
    else
        rm /etc/init.d/httpd -r
    fi
    service httpd start
    echo "Compile apache successfully"
}

#unzip tomcat
install_tomcat()
{
    echo "Start to install tomcat..."
#    cd $soft_path
#    echo "Current path is : `pwd`"
    tar -xvf $soft_path/apache-tomcat-6.0.35.tar.gz -C $cps_path
 echo "Install tomcat successfully"
}

#main
main()
{
    echo "Start to install cps..."
    echo "*************************************************"
    echo "*****                 WARNING               *****"
    echo "*****  Please must not close this window!   *****"
    echo "*************************************************"
#    tar_file && install_java && config_javapath
#    tar_file && install_apache
#
#    install_tomcat
#    create_log && create_cps_folder && create_apache_folder && tar_apache && pre_apache && compile_apache && install_apache && start_apache
}

#    create_log && create_cps_folder && create_apache_folder && tar_apache && pre_apache && compile_apache && install_apache && start_apache
main |tee -a $log_file

exit


你可能感兴趣的:(ubuntu 10.4 离线安装JDK Java Apache Tomcat Mysql脚本)