• 写个自动下载安装Ant的shell脚本【二】


    #!/bin/bash

    ######################################################
    # file name: install_ant.sh
    #
    # function:
    # To quickly install ant automatically
    # in linux system...
    #
    # author: jeffzhao
    # date: 2013.6.19
    #
    #
    #
    ######################################################
    ant_package_path="./"
    ant_install_path="/opt/test/ant"
    ant_package_name="apache-ant-1.9.1-bin.tar.gz"
    ant_download_url="http://www.apache.org/dist/ant/binaries"/${ant_package_name}
    antMD5_download_url="http://www.apache.org/dist/ant/binaries"/${ant_package_name}.md5

    ######################################################
    # download from wen ftp
    #
    ######################################################
    function download_ant()
    {
    wget ${ant_download_url} >/dev/null
    wget ${antMD5_download_url} >/dev/null
    }

    ######################################################
    # check package and package path
    #
    ######################################################
    function check_env()
    {
    # To Make Sure Ant Pakcage Path is Ok
    if [ ! -d ${ant_package_path} ]
    then
    mkdir -p ${ant_package_path}
    fi

    # To Make Sure Ant Pakcage is OK

    ls ${ant_package_path}| grep .tar.gz$ | grep ant >/dev/null

    if [ $? == 1 ]
    then
    download_ant
    check_md5
    if [ $? != 0 ]
    then
    check_env
    fi
    else
    ant_package_name= ls ${ant_package_path}| grep .tar.gz$
    fi
    }

    ######################################################
    # check package md5
    #
    ######################################################
    function check_md5()
    {
    grep `md5sum ${ant_package_name} | cut -c 1-32` ${ant_package_name}.md5 >/dev/null
    return $?
    }


    ######################################################
    # unzip package and copy files to install path
    #
    ######################################################
    function install_ant()
    {
    if [ ! -d ${ant_install_path} ]
    then
    mkdir -p ${ant_install_path}
    fi

    ### clear env
    rm -rf ${ant_install_path}/*

    ###
    tar -xzvf ${ant_package_name}
    mv `ls -l | grep ^d | grep ant | awk '{print$8}'` ${ant_install_path}
    }

    ######################################################
    # main
    #
    ######################################################
    function main()
    {
    ## check root right
    if [ `whoami` != 'root' ]
    then
    exit
    fi

    echo "Preinstall Checking start"
    check_env
    install_ant
    }

    main

  • 相关阅读:
    为何要对URL进行编码
    关于GreenPlum的一些整理
    Greenplum入门——基础知识、安装、常用函数
    PyGreSQL入门,pg模块,pgdb模块
    MySQL Test Suite使用
    MySQL到Greenplum迁移分析
    Method overrides should not change parameter defaults
    Why use a public method in an internal class?
    Git Submodules vs Git Subtrees
    To Allow App through Windows Defender Firewall in Command Prompt
  • 原文地址:https://www.cnblogs.com/unixshell/p/3147553.html
Copyright © 2020-2023  润新知