可以借鉴的脚本函数
输出颜色
Color_Text() { echo -e " \e[0;$2m$1\e[0m" } Echo_Red() { echo $(Color_Text "$1" "31") } Echo_Green() { echo $(Color_Text "$1" "32") } Echo_Yellow() { echo $(Color_Text "$1" "33") } Echo_Blue() { echo $(Color_Text "$1" "34") }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stty命令,调用
Press_Install() { echo "" Echo_Green "Press any key to install...or Press Ctrl+c to cancel" OLDCONFIG=`stty -g` stty -icanon -echo min 1 time 0 dd count=1 2>/dev/null stty ${OLDCONFIG} . include/version.sh Kill_PM }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
从网上下载资源
Download_Mirror='http://soft.vpser.net' Autoconf_Ver='autoconf-2.13' Download_Files ${Download_Mirror}/lib/autoconf/${Autoconf_Ver}.tar.gz ${Autoconf_Ver}.tar.gz Download_Files() { local URL=$1 local FileName=$2 if [ -s "${FileName}" ]; then echo "${FileName} [found]" else echo "Notice: ${FileName} not found!!!download now..." #-c, --continue 接着下载没下载完的文件 #--progress=TYPE 设定进程条标记 wget -c --progress=bar:force ${URL} fi }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
解压缩并且进入目录
Tar_Cd() { local FileName=$1 local DirName=$2 cd ${cur_dir}/src [[ -d "${DirName}" ]] && rm -rf ${DirName} echo "Uncompress ${FileName}..." tar zxf ${FileName} echo "cd ${DirName}..." cd ${DirName} }
#----------All efforts I have paid today...