From: Nicolas Boisselier Date: Fri, 7 Apr 2023 23:53:16 +0000 (+0200) Subject: sys_os and date_install improvement X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=a8accb9414abcefba9ba5e4a110038c29625ec7d;p=nb.git sys_os and date_install improvement --- diff --git a/etc/profile.d/sys.sh b/etc/profile.d/sys.sh index b565ac9f..9f725026 100644 --- a/etc/profile.d/sys.sh +++ b/etc/profile.d/sys.sh @@ -61,7 +61,15 @@ sys_public_ip() { } sys_date_install() { - (date -r $(ls -1drt /lost+found /etc/ssh/ssh_host_dsa_key.pub /etc/ssh_host_dsa_key.pub|head -1) +'%F %T') 2>/dev/null + (date -r \ + $( \ + ls -1drt \ + /lost+found \ + /etc/ssh/ssh_host_*_key.pub\ + /etc/ssh_host_dsa_key.pub \ + |head -1 \ + ) +'%F %T' \ + ) 2>/dev/null } sys_nproc() { @@ -147,20 +155,21 @@ sys_activity() { rm -rf "$tmp"* } -sys_os() { +sys_os() { + if [ -e /etc/os-release ]; then - ( - . /etc/os-release && echo $ID $VERSION - ) + #( . /etc/os-release && echo $ID $VERSION ) + sh -c '. /etc/os-release && echo $ID $VERSION' elif which lsb_release > /dev/null; then - lsb_release --short -d + lsb_release --short -d elif which sw_vers > /dev/null; then - echo $(sw_vers 2>/dev/null | awk -F':\t' '/^(ProductName|ProductVersion)/{print $2}' | head -2) && return + echo $(sw_vers 2>/dev/null | \ + awk -F':\t' '/^(ProductName|ProductVersion)/{print $2}' | head -2) fi - #[ -r /etc/debian_version ] && echo Debian $(cat /etc/debian_version) && return + #[ -r /etc/debian_version ] && echo Debian $(cat /etc/debian_version) } sys_mem_total() {