diff --git a/update-motd.sh b/update-motd.sh index bccf2c1..721c5d3 100755 --- a/update-motd.sh +++ b/update-motd.sh @@ -1,5 +1,5 @@ #!/bin/bash -PATH="${PATH}:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" +PATH="${PATH}:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin/" COLOR_LIGHT_GREEN='\033[0;32m' COLOR_LIGHT_BLUE='\033[0;34m' @@ -23,10 +23,20 @@ nb_cores="$(echo "$cores" | awk -F" " '{print $1}') cores" type_cores=$(echo "$cores" | cut -f2- -d' ') core="$nb_cores ""$type_cores" -diskSize=$(diskutil info /dev/disk3s1 | grep Total | awk '{ print int($4) }') -diskFree=$(diskutil info /dev/disk3s1 | grep Free | awk '{ print int($4) }') + +# Container Total Space: 2.0 TB (1995218165760 Bytes) (exactly 3896910480 512-Byte-Units) +diskSize=$(diskutil info /dev/disk3s1 | grep Total | awk -F" " '{print $6}' | sed 's/(//') + +# Container Free Space: 1.6 TB (1618374803456 Bytes) (exactly 3160888288 512-Byte-Units) +diskFree=$(diskutil info /dev/disk3s1 | grep Free | awk -F" " '{print $6}' | sed 's/(//') + +# Disk occupé diskUsage=$((${diskSize} - ${diskFree})) +diskUsage=$(printf %s\\n $diskUsage | numfmt --to=iec --suffix=B | sed 's/,/./') +diskFree=$(printf %s\\n $diskFree | numfmt --to=iec --suffix=B | sed 's/,/./') +diskSize=$(printf %s\\n $diskSize | numfmt --to=iec --suffix=B | sed 's/,/./') + profiler=$(system_profiler SPSoftwareDataType | tail -n10 | cut -c 5- ) _sip=$(echo "$profiler" | grep 'System Integrity' | awk -F":" '{print $2}' | xargs) _sv_mem=$(echo "$profiler" | grep 'Virtual Memory' | awk -F":" '{print $2}' | xargs) @@ -40,9 +50,12 @@ networkservice=$(echo "$list_network" | grep "$interface" | awk -F":" '{print $1 local_ip=$(ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}') +dat=$(date) +# | lolcat echo -e " -${COLOR_LIGHT_GREEN}$(figlet -ckw 100 -f slant $(hostname | sed -e 's/.local//')) +${COLOR_LIGHT_GREEN}$(figlet -ckw 100 -f slant $(hostname | sed -e 's/.local//')) + ${COLOR_WHITE}Hostname : ${COLOR_LIGHT_BLUE}$(hostname) ${COLOR_WHITE}Private IP Address : ${COLOR_LIGHT_BLUE}$(ifconfig en0 2>/dev/null | grep 'inet ' | cut -d ' ' -f 2) ${COLOR_WHITE}Current interface : ${COLOR_LIGHT_BLUE}${networkservice} (${interface}) @@ -52,8 +65,10 @@ ${COLOR_WHITE}OS Info : ${COLOR_LIGHT_BLUE}${osname} ${version} ($ ${COLOR_WHITE}Model (Number) : ${COLOR_LIGHT_BLUE}${identifier} (${number}) ${COLOR_WHITE}CPU : ${COLOR_LIGHT_BLUE}${chip} (${core}) ${COLOR_WHITE}Memory : ${COLOR_LIGHT_BLUE}${memory} -${COLOR_WHITE}Disk Used/Total : ${COLOR_LIGHT_BLUE}${diskUsage}Go / ${diskSize}Go +${COLOR_WHITE}Disk Used/Total : ${COLOR_LIGHT_BLUE}${diskUsage} / ${diskSize} ${COLOR_WHITE}Secure Virtual Memory : ${COLOR_LIGHT_BLUE}${_sv_mem} ${COLOR_WHITE}SIP : ${COLOR_LIGHT_BLUE}${_sip} -${COLOR_WHITE}Uptime : ${COLOR_LIGHT_BLUE}${_uptime}" | lolcat -#${COLOR_WHITE}" > /etc/motd +${COLOR_WHITE}Uptime : ${COLOR_LIGHT_BLUE}${_uptime} +${COLOR_WHITE}Date : ${COLOR_LIGHT_BLUE}${dat} + +${COLOR_WHITE}" > /etc/motd