]> git.nbdom.net Git - nb.git/commitdiff
sys_os and date_install improvement
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 7 Apr 2023 23:53:16 +0000 (01:53 +0200)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 7 Apr 2023 23:53:16 +0000 (01:53 +0200)
etc/profile.d/sys.sh

index b565ac9fa304535e2a6fb2bd560c815baa25f400..9f725026e95edb50a15aa787b74e0acda0bb6adf 100644 (file)
@@ -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() {