diff --git a/Stats32 b/Stats32 index a589c57..8ca755a 100755 --- a/Stats32 +++ b/Stats32 @@ -33,11 +33,13 @@ nbconnected="$(users | wc -w)" #printf " Kernel Info :\t%s\t \t%s\t IP Address:\t%s\n" $DISTRIB_DESCRIPTION $ip #printf " Shell :\t%s\tSystem uptime:\t%s\n" $SHELL "$time" #printf " Last SSH :\t%s\tSwap usage:\t%s\n" "$(tput setab 1) $(users | wc -w) $(tput sgr0) connected" - - -#printf " Last SSH\t%s\t \t%s connected\t%s\n" ":" "$(tput setab 1) $(users | wc -w) $(tput sgr0)" #echo -e "\e[1;30m" ; last -a -n $nbconnected | grep pts ; echo -e "\e[0m" +sys_load_c="$(tput setab 34)$(tput setaf 0)" +usage_color="$(tput setaf 202)" +ssh_c="$(tput setab 124)" +NC="$(tput sgr0)" + load=`cat /proc/loadavg | awk '{print $1}'` root_usage=`df -h / | awk '/\// {print $(NF-1)}'` memory_usage=`free -m | awk '/Mem:/ { total=$2 } /buffers\/cache/ { used=$3 } END { printf("%3.1f%%", used/total*100)}'` @@ -50,12 +52,17 @@ ip=`hostname -i` # ip=`hostname -i | awk '{ printf $2 }'` printf "Kernel Info [ $DISTRIB_DESCRIPTION ]\n" printf "%s------------\t---\t-------------\t----------\n" -printf "System load :\t%s\tIP Address :\t%s\n" "$(tput setab 34)$(tput setaf 0) $load $(tput sgr0)" $ip +printf "System load :\t%s\tIP Address :\t%s\n" "${sys_load_c} $load ${NC}" $ip printf "Memory usage :\t%s\tSystem uptime:\t%s\n" $memory_usage "$time" -printf "Usage on / :\t%s\tenv LANGAUAGE:\t%s\n" "$(tput setaf 202)$root_usage $(tput sgr0)" "$(env | grep LANG=)" +printf "Usage on / :\t%s\tenv LANGAUAGE:\t%s\n" "${usage_color}$root_usage ${NC}" "$(env | grep LANG=)" printf "Swap usage :\t%s\tProcesses :\t%s\n" $swap_usage $processes -printf "Last User SSH:\t%s\tShell :\t%s\n" "$(tput setab 1) $(users | wc -w) $(tput sgr0)" $SHELL +printf "User SSH :\t%s\tShell :\t%s\n" "${ssh_c} $(users | wc -w) ${NC}" $SHELL printf "%s------------\t---\t-------------\t----------\n" -echo -e "\n Conected Users $(users | wc -w) \e[1;30m" ; last -a -n $nbconnected | grep pts ; echo -e "\e[0m" -echo -e "\n\e[93m Generated by MOTDs32\e[0m" +echo -e "\n Conected Users $(users | wc -w) \e[1;30m" ; [[ -z "$nbconnected" ]] && last -a -n $nbconnected | grep pts | head -3 || last -a -n $nbconnected | grep pts +echo -e "\e[0m" +#[[ -z "$nbconnected" ]] && echo "Empty" || echo "Not empty" + + +echo -e "\e[93m Generated by MOTDs32\e[0m" +echo -e " Welcome $USER" diff --git a/install.sh b/install.sh index 08843fe..92e9cbc 100755 --- a/install.sh +++ b/install.sh @@ -156,9 +156,9 @@ tput cup 11 0 if [ -f "/etc/motds32/Stats32" ] then echo -e " -->\e[34m Stats32 \e[92mOK\e[0m" - cp Stats32 /etc/motds32/Stats32 -Rf + cp Stats32 /etc/motds32/Stats32 else - cp Stats32 /etc/motds32/Stats32 -Rf + cp -f Stats32 /etc/motds32/Stats32 echo -e " -->\e[34m Stats32 \e[92mINSTALLED\e[0m" fi