• JDK一键部署, 新添加进度条


    JDK部署, 脚本与JDK安装包放在同一目录

    然后执行

    source ./jdk.sh

    稍等进度条100%即可

    #*************************************************************************
    #         > File Name: jdk.sh
    #         > Author: chenglee
    #         > Main : chengkenlee@sina.com
    #         > Blog : http://www.cnblogs.com/chenglee/
    #         > Created Time : 2019年03月07日 星期四 18时08分59秒
    #*************************************************************************
    #!/bin/bash
    jdk_path="/usr/local"
    jdk_targ=`basename *jdk-*`
    
    function Cheng_flash(){
        i=0;
        str=""
        arr=("|" "/" "-" "\")
        while [ $i -le 100 ]
        do
        let index=i%4
        let indexcolor=i%8
        let color=30+indexcolor
        printf "e[0;$color;1m[%-100s][%d%%]%c
    " "$str" "$i" "${arr[$index]}"
        sleep ${sleeptime2}
        let i++
        str+='='
        done
        printf "
    "
    }
    function Time_test(){
        echo "please wait a moment ... "
        starttime=`date +'%Y-%m-%d %H:%M:%S'`
        tar tvvf ${jdk_targ} > /dev/null
        endtime=`date +'%Y-%m-%d %H:%M:%S'`
        start_seconds=$(date --date="$starttime" +%s);
        end_seconds=$(date --date="$endtime" +%s);
        sleeptime=$((end_seconds-start_seconds))
        sleeptime2=`awk 'BEGIN{printf "%0.2f",'${sleeptime}'/100}'`
    }
    function tar_gz(){
        Time_test
        tar xvvf ${jdk_targ} -C ${jdk_path} > /dev/null | Cheng_flash
    }
    function profile(){
        jdk_Path=`find ${jdk_path} -maxdepth 1 | grep jdk`
    (
    cat <<EOF
    #java jdk
    export JAVA_HOME=${jdk_Path}
    export JRE_HOME=${JAVA_HOME}/jre
    export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
    export PATH=${JAVA_HOME}/bin:$PATH
    EOF
    ) >> /etc/profile
    }
    function Source(){
        source /etc/profile
    }
    
    function main(){
        tar_gz
        profile
        Source
    }
    main
  • 相关阅读:
    python定位一组元素并打印出文本
    python+selenium自动化报告HTMLTestRunner增加饼图展示
    PyCharm链接Oracle数据库
    python+selenium自动化鼠标事件之封装
    python学习记录--默认字典defaultdict()
    python学习记录--有序字典OrderedDict()
    python学习记录--Counter()类
    python学习记录--集合
    python学习记录--字典
    python学习记录--列表
  • 原文地址:https://www.cnblogs.com/chenglee/p/10495747.html
Copyright © 2020-2023  润新知