#屏幕的大小SCREEN=`stty -F /dev/console size` 2>/dev/null #默认显示的是横排为25 竖排为80COLUMNS=${SCREEN#* }[ -z $COLUMNS ] && COLUMNS=80 #当不存在/dev/console文件时候,直接设置COLUMNS为80SPA_COL=$[$COLUMNS-14] #总长度-尾部显示字符的大小(由于显示为[ OK ]或者[ FAILED ]最大值为14)#颜色的设置和选择RED='\033[31m' #红GREEN='\033[32m' #绿 YELLOW='\033[33m' #黄BLUE='\033[34m' #蓝NORMAL='\033[0m' #正常#当服务启动成功后显示OKsuccess() { string=$1 RT_SPA=$[$SPA_COL-${#string}] echo -n "$string" for I in `seq 1 $RT_SPA`;do echo -n " " done echo -e "[ ${GREEN}OK${NORMAL} ]" #显示为绿色的OK字体}#当服务启动失败后显示failurefailure() { string=$1 RT_SPA=$[$SPA_COL-${#string}] echo -n "$string" for I in `seq 1 $RT_SPA`;do echo -n " " done echo -e "[ ${RED}FAILED${NORMAL} ]" #显示为红色的FAILED}