#屏幕的大小SCREEN = ' stty -f /dev/console size ' 2>/dev/null #默认显示的是横排为25 Vertical row for 80columns=${screen#* }[ -z $COLUMNS ] && COLUMNS=80 #当不存在/ Dev/console file, directly set COLUMNS to 80spa_col=$[$COLUMNS -14] #总长度-the size of the trailing display character (as shown as [ ok ] or [  FAILED&NBSP] (max.) #颜色的设置和选择RED = ' \033[31m ' #红GREEN = ' \033[32m ' #绿 yellow= ' \033[33m ' #黄BLUE = ' \033[34m ' #蓝NORMAL = ' \033[0m ' #正常 # displays oksuccess () when the service starts successfully () { string=$1 rt_spa=$[$SPA _col-${# string}] echo -n "$string" for I in ' seq 1 $RT _spa ';d o echo -n " " done echo -e "[ ${green}ok${normal} ]" # OK font shown as green} #当服务启动失败后显示failurefailure () { string=$1 rt_spa=$[$SPA _col-${#string}] echo -n "$string" for i in ' seq 1 $RT _spa ';d o echo -n " " done echo -e "[ ${red}failed${normal} ]" # Failed} shown in red
This article is from the "World Road Line World" blog, please be sure to keep this source http://enochline.blog.51cto.com/9390497/1617709
OK alignment display (function call) after start service successful