diff --git a/bench.sh b/bench.sh index 12f33de..805ef2f 100644 --- a/bench.sh +++ b/bench.sh @@ -81,7 +81,7 @@ io_test() { calc_disk() { local total_size=0 local array=$@ - for size in ${array[@]} + for size in "${array[@]}" do [ "${size}" == "0" ] && size_t=0 || size_t=`echo ${size:0:${#size}-1}` [ "`echo ${size:(-1)}`" == "K" ] && size=0 @@ -109,8 +109,8 @@ kern=$( uname -r ) ipv6=$( wget -qO- -t1 -T2 ipv6.icanhazip.com ) disk_size1=($( LANG=C df -hPl | grep -wvE '\-|none|tmpfs|devtmpfs|by-uuid|chroot|Filesystem' | awk '{print $2}' )) disk_size2=($( LANG=C df -hPl | grep -wvE '\-|none|tmpfs|devtmpfs|by-uuid|chroot|Filesystem' | awk '{print $3}' )) -disk_total_size=$( calc_disk ${disk_size1[@]} ) -disk_used_size=$( calc_disk ${disk_size2[@]} ) +disk_total_size=$( calc_disk "${disk_size1[@]}" ) +disk_used_size=$( calc_disk "${disk_size2[@]}" ) clear next diff --git a/kms.sh b/kms.sh index 3e9bbea..ea03aed 100644 --- a/kms.sh +++ b/kms.sh @@ -19,17 +19,17 @@ cur_dir=$(pwd) if [ -f /etc/redhat-release ]; then release="centos" -elif cat /etc/issue | grep -Eqi "debian"; then +elif grep -Eqi "debian" /etc/issue; then release="debian" -elif cat /etc/issue | grep -Eqi "ubuntu"; then +elif grep -Eqi "ubuntu" /etc/issue; then release="ubuntu" -elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then +elif grep -Eqi "centos|red hat|redhat" /etc/issue; then release="centos" -elif cat /proc/version | grep -Eqi "debian"; then +elif grep -Eqi "debian" /proc/version; then release="debian" -elif cat /proc/version | grep -Eqi "ubuntu"; then +elif grep -Eqi "ubuntu" /proc/version; then release="ubuntu" -elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then +elif grep -Eqi "centos|red hat|redhat" /proc/version; then release="centos" else release="" @@ -37,19 +37,19 @@ fi boot_start(){ if [[ x"${release}" == x"debian" || x"${release}" == x"ubuntu" ]]; then - update-rc.d -f ${1} defaults + update-rc.d -f "${1}" defaults elif [[ x"${release}" == x"centos" ]]; then - chkconfig --add ${1} - chkconfig ${1} on + chkconfig --add "${1}" + chkconfig "${1}" on fi } boot_stop(){ if [[ x"${release}" == x"debian" || x"${release}" == x"ubuntu" ]]; then - update-rc.d -f ${1} remove + update-rc.d -f "${1}" remove elif [[ x"${release}" == x"centos" ]]; then - chkconfig ${1} off - chkconfig --del ${1} + chkconfig "${1}" off + chkconfig --del "${1}" fi } @@ -85,13 +85,13 @@ get_opsy() { } get_char() { - SAVEDSTTY=`stty -g` + SAVEDSTTY=$(stty -g) stty -echo stty cbreak dd if=/dev/tty bs=1 count=1 2> /dev/null stty -raw stty echo - stty $SAVEDSTTY + stty "$SAVEDSTTY" } set_firewall() { @@ -157,7 +157,7 @@ install_main() { exit 1 fi - cd ${cur_dir} + cd "${cur_dir}" || exit git clone https://github.com/teddysun/vlmcsd.git > /dev/null 2>&1 [ -d vlmcsd ] && cd vlmcsd || echo -e "[${red}Error:${plain}] Failed to git clone vlmcsd." make @@ -176,7 +176,7 @@ install_main() { if [[ x"${release}" == x"centos" ]]; then set_firewall fi - cd ${cur_dir} + cd "${cur_dir}" || exit rm -rf vlmcsd echo echo "Install KMS Server success" @@ -187,7 +187,7 @@ install_main() { install_kms() { - install_main 2>&1 | tee ${cur_dir}/install_kms.log + install_main 2>&1 | tee "${cur_dir}"/install_kms.log } # Uninstall KMS Server @@ -195,7 +195,7 @@ uninstall_kms() { printf "Are you sure uninstall KMS Server? (y/n) " printf "\n" read -p "(Default: n):" answer - [ -z ${answer} ] && answer="n" + [ -z "${answer}" ] && answer="n" if [ "${answer}" == "y" ] || [ "${answer}" == "Y" ]; then /etc/init.d/kms status > /dev/null 2>&1 if [ $? -eq 0 ]; then @@ -216,14 +216,13 @@ uninstall_kms() { # Initialization step action=$1 -[ -z $1 ] && action=install +[ -z "$1" ] && action=install case "$action" in install|uninstall) ${action}_kms ;; *) echo "Arguments error! [${action}]" - echo "Usage: `basename $0` [install|uninstall]" + echo "Usage: $(basename $0) [install|uninstall]" ;; esac -