From e338e42bae790d8ff65cf69c48afae8d6f8ca3a0 Mon Sep 17 00:00:00 2001 From: gary2002 Date: Sat, 15 Apr 2023 10:58:48 +1000 Subject: [PATCH 01/10] banner with letsencrypt certificate details Addition to check if a letsencrypt certificate exists and if so, print the certificate expiration details. This can act as a simple check to see if letsencrypt certificates are updating over time. --- dietpi/func/dietpi-banner | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/dietpi/func/dietpi-banner b/dietpi/func/dietpi-banner index 2444d6ea76..6d46eaeb9d 100755 --- a/dietpi/func/dietpi-banner +++ b/dietpi/func/dietpi-banner @@ -56,15 +56,16 @@ 'VPN status' 'Large hostname' 'Print credits' + 'Certificate Valid to' ) # Set defaults: Disable CPU temp by default in VMs if (( $G_HW_MODEL == 20 )) then - aENABLED=(1 0 0 0 0 1 0 1 0 0 0 1 1 0 0 1) + aENABLED=(1 0 0 0 0 1 0 1 0 0 0 1 1 0 0 1 1) else - aENABLED=(1 0 1 0 0 1 0 0 0 0 0 1 1 0 0 1) + aENABLED=(1 0 1 0 0 1 0 0 0 0 0 1 1 0 0 1 1) fi COLOUR_RESET='\e[0m' @@ -263,6 +264,18 @@ $GREEN_LINE" (( ${aENABLED[8]} == 1 )) && echo -e "$GREEN_BULLET ${aCOLOUR[1]}${aDESCRIPTION[8]} $GREEN_SEPARATOR $(df -h --output=avail /mnt/dietpi_userdata | mawk 'NR==2 {print $1}' 2>&1)" # Weather (( ${aENABLED[9]} == 1 )) && echo -e "$GREEN_BULLET ${aCOLOUR[1]}${aDESCRIPTION[9]} $GREEN_SEPARATOR $(curl -sSfLm 3 'https://wttr.in/?format=4' 2>&1)" + # Certificate + local certinfo='No certificate found' + local letsencrypt=/etc/letsencrypt + if [ -d "$letsencrypt" ]; + then + for i in $letsencrypt/live/*/cert.pem + do + certinfo=$(openssl x509 --enddate --noout --in "$i" | mawk '/notAfter=/{print substr($2,1) "-" substr($1,10) "-" substr($4,1) " @ " substr($3,1)}' 2>&1) + break + done + fi + (( ${aENABLED[16]} == 1 )) && echo -e "$GREEN_BULLET ${aCOLOUR[1]}${aDESCRIPTION[16]} $GREEN_SEPARATOR $certinfo" # Custom (( ${aENABLED[10]} == 1 )) && echo -e "$GREEN_BULLET ${aCOLOUR[1]}${aDESCRIPTION[10]} $GREEN_SEPARATOR $(bash "$FP_CUSTOM" 2>&1)" # MOTD From 2bde7e70d12ff3d3324fb8b4e9945647b0a62818 Mon Sep 17 00:00:00 2001 From: gary2002 Date: Sat, 15 Apr 2023 17:22:33 +1000 Subject: [PATCH 02/10] Update dietpi-banner --- dietpi/func/dietpi-banner | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dietpi/func/dietpi-banner b/dietpi/func/dietpi-banner index 6d46eaeb9d..cf02ea8a95 100755 --- a/dietpi/func/dietpi-banner +++ b/dietpi/func/dietpi-banner @@ -267,9 +267,9 @@ $GREEN_LINE" # Certificate local certinfo='No certificate found' local letsencrypt=/etc/letsencrypt - if [ -d "$letsencrypt" ]; + if [[ -d "$letsencrypt" ]]; then - for i in $letsencrypt/live/*/cert.pem + for i in "$letsencrypt"/live/*/cert.pem do certinfo=$(openssl x509 --enddate --noout --in "$i" | mawk '/notAfter=/{print substr($2,1) "-" substr($1,10) "-" substr($4,1) " @ " substr($3,1)}' 2>&1) break From 90719d04d52ba2aa3d7469c06def31d558735fe1 Mon Sep 17 00:00:00 2001 From: gary2002 Date: Sun, 16 Apr 2023 22:23:55 +1000 Subject: [PATCH 03/10] Update dietpi/func/dietpi-banner Happy with that. Co-authored-by: MichaIng --- dietpi/func/dietpi-banner | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dietpi/func/dietpi-banner b/dietpi/func/dietpi-banner index cf02ea8a95..86bcf6a5f2 100755 --- a/dietpi/func/dietpi-banner +++ b/dietpi/func/dietpi-banner @@ -264,18 +264,18 @@ $GREEN_LINE" (( ${aENABLED[8]} == 1 )) && echo -e "$GREEN_BULLET ${aCOLOUR[1]}${aDESCRIPTION[8]} $GREEN_SEPARATOR $(df -h --output=avail /mnt/dietpi_userdata | mawk 'NR==2 {print $1}' 2>&1)" # Weather (( ${aENABLED[9]} == 1 )) && echo -e "$GREEN_BULLET ${aCOLOUR[1]}${aDESCRIPTION[9]} $GREEN_SEPARATOR $(curl -sSfLm 3 'https://wttr.in/?format=4' 2>&1)" - # Certificate - local certinfo='No certificate found' - local letsencrypt=/etc/letsencrypt - if [[ -d "$letsencrypt" ]]; + # Let's Encrypt cert status + if (( ${aENABLED[16]} == 1 )) then - for i in "$letsencrypt"/live/*/cert.pem + local i certinfo='No certificate found' + for i in /etc/letsencrypt/live/*/cert.pem do - certinfo=$(openssl x509 --enddate --noout --in "$i" | mawk '/notAfter=/{print substr($2,1) "-" substr($1,10) "-" substr($4,1) " @ " substr($3,1)}' 2>&1) + [[ -f $i ]] || continue + certinfo=$(openssl x509 --enddate --noout --in "$i" | mawk '/notAfter=/{print "Valid until " substr($2,1) "-" substr($1,10) "-" substr($4,1) " @ " substr($3,1)}' 2>&1) break done + echo -e "$GREEN_BULLET ${aCOLOUR[1]}${aDESCRIPTION[16]} $GREEN_SEPARATOR $certinfo" fi - (( ${aENABLED[16]} == 1 )) && echo -e "$GREEN_BULLET ${aCOLOUR[1]}${aDESCRIPTION[16]} $GREEN_SEPARATOR $certinfo" # Custom (( ${aENABLED[10]} == 1 )) && echo -e "$GREEN_BULLET ${aCOLOUR[1]}${aDESCRIPTION[10]} $GREEN_SEPARATOR $(bash "$FP_CUSTOM" 2>&1)" # MOTD From e8e40c9fcbf090b027e40a55a0d571fe345aadb7 Mon Sep 17 00:00:00 2001 From: Joulinar <47155374+Joulinar@users.noreply.github.com> Date: Sun, 16 Apr 2023 14:33:44 +0200 Subject: [PATCH 04/10] v8.17 DietPi-Banner | add letsencrypt certificate details, do not enable function by default Co-authored-by: MichaIng --- dietpi/func/dietpi-banner | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dietpi/func/dietpi-banner b/dietpi/func/dietpi-banner index 86bcf6a5f2..605e8c0235 100755 --- a/dietpi/func/dietpi-banner +++ b/dietpi/func/dietpi-banner @@ -65,7 +65,7 @@ then aENABLED=(1 0 0 0 0 1 0 1 0 0 0 1 1 0 0 1 1) else - aENABLED=(1 0 1 0 0 1 0 0 0 0 0 1 1 0 0 1 1) + aENABLED=(1 0 1 0 0 1 0 0 0 0 0 1 1 0 0 1 0) fi COLOUR_RESET='\e[0m' From 72dc182c10f4e97a665c87ad89e65207beb1750f Mon Sep 17 00:00:00 2001 From: Joulinar <47155374+Joulinar@users.noreply.github.com> Date: Sun, 16 Apr 2023 14:34:47 +0200 Subject: [PATCH 05/10] v8.17 DietPi-Banner | add letsencrypt certificate details, change menu name Co-authored-by: MichaIng --- dietpi/func/dietpi-banner | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dietpi/func/dietpi-banner b/dietpi/func/dietpi-banner index 605e8c0235..6d635188e9 100755 --- a/dietpi/func/dietpi-banner +++ b/dietpi/func/dietpi-banner @@ -56,7 +56,7 @@ 'VPN status' 'Large hostname' 'Print credits' - 'Certificate Valid to' + 'Let'\''s Encrypt cert status' ) From c09f982936a73f745386005c6c730803d3908ea1 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Thu, 20 Apr 2023 19:15:33 +0200 Subject: [PATCH 06/10] Do not enable Let's Encrypt status by default on VMs --- dietpi/func/dietpi-banner | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dietpi/func/dietpi-banner b/dietpi/func/dietpi-banner index 6d635188e9..e1e1212770 100755 --- a/dietpi/func/dietpi-banner +++ b/dietpi/func/dietpi-banner @@ -63,7 +63,7 @@ # Set defaults: Disable CPU temp by default in VMs if (( $G_HW_MODEL == 20 )) then - aENABLED=(1 0 0 0 0 1 0 1 0 0 0 1 1 0 0 1 1) + aENABLED=(1 0 0 0 0 1 0 1 0 0 0 1 1 0 0 1 0) else aENABLED=(1 0 1 0 0 1 0 0 0 0 0 1 1 0 0 1 0) fi From 5637fa3c51c3883a38aeefefdfafcffdf69bfdbf Mon Sep 17 00:00:00 2001 From: MichaIng Date: Thu, 20 Apr 2023 19:20:21 +0200 Subject: [PATCH 07/10] v8.17 - CHANGELOG | DietPi-Banner: Added a new option to show the Let's Encrypt certificate status (expiry date), when installed via dietpi-letsencrypt or Certbot. Many thanks to @gary2002 for implementing this option. --- CHANGELOG.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 539416d485..3211a28cb6 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -6,6 +6,7 @@ New images: New software: Enhancements: +- DietPi-Banner | Added a new option to show the Let's Encrypt certificate status (expiry date), when installed via dietpi-letsencrypt or Certbot. Many thanks to @gary2002 for implementing this option. Bug fixes: - General | Resolved an issue where our recent images had the cron service masked accidentally after first run setup. Many thanks to @Johannes for reporting this issue: https://dietpi.com/forum/t/cron-service-is-masked/16544 From c90c8393df909e35b231d8a63ecf0cacbc83e851 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Thu, 20 Apr 2023 19:29:30 +0200 Subject: [PATCH 08/10] v8.17 - DietPi-Banner | Simplify awk for obtaining the certificate expiry date --- dietpi/func/dietpi-banner | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dietpi/func/dietpi-banner b/dietpi/func/dietpi-banner index e1e1212770..b50b856120 100755 --- a/dietpi/func/dietpi-banner +++ b/dietpi/func/dietpi-banner @@ -271,7 +271,7 @@ $GREEN_LINE" for i in /etc/letsencrypt/live/*/cert.pem do [[ -f $i ]] || continue - certinfo=$(openssl x509 --enddate --noout --in "$i" | mawk '/notAfter=/{print "Valid until " substr($2,1) "-" substr($1,10) "-" substr($4,1) " @ " substr($3,1)}' 2>&1) + certinfo=$(openssl x509 -enddate -noout -in "$i" | mawk '/notAfter=/{print "Valid until "$2"-"substr($1,10)"-"$4" @ "$3}' 2>&1) break done echo -e "$GREEN_BULLET ${aCOLOUR[1]}${aDESCRIPTION[16]} $GREEN_SEPARATOR $certinfo" From 679d5a5bb54c2cf82051230e2ec2e8d8475c20a6 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Fri, 21 Apr 2023 14:33:02 +0200 Subject: [PATCH 09/10] v8.17 - DietPi-Banner | Do not obtain IP info if it is not printed anyway - DietPi-Banner | Let's Encrypt cert status: Print in format "YYYY-MMM-DD HH:MM:SS" --- dietpi/func/dietpi-banner | 65 ++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/dietpi/func/dietpi-banner b/dietpi/func/dietpi-banner index b50b856120..904865770a 100755 --- a/dietpi/func/dietpi-banner +++ b/dietpi/func/dietpi-banner @@ -57,7 +57,6 @@ 'Large hostname' 'Print credits' 'Let'\''s Encrypt cert status' - ) # Set defaults: Disable CPU temp by default in VMs @@ -75,7 +74,6 @@ '\e[1m' # Bold white | Main descriptions '\e[90m' # Grey | Credits '\e[91m' # Red | Update notifications - ) # Load settings here, to have chosen ${aCOLOUR[0]} applied to below strings @@ -91,32 +89,29 @@ # DietPi update available? AVAILABLE_UPDATE= # value = version string - Check_DietPi_Update(){ - + Check_DietPi_Update() + { [[ -f '/run/dietpi/.update_available' ]] || return 1 AVAILABLE_UPDATE=$(&1)" - # LAN IP [5] + # LAN IP Print_Local_Ip # WAN IP + location info (( ${aENABLED[6]} == 1 )) && echo -e "$GREEN_BULLET ${aCOLOUR[1]}${aDESCRIPTION[6]} $GREEN_SEPARATOR $(G_GET_WAN_IP 2>&1)" @@ -271,7 +260,7 @@ $GREEN_LINE" for i in /etc/letsencrypt/live/*/cert.pem do [[ -f $i ]] || continue - certinfo=$(openssl x509 -enddate -noout -in "$i" | mawk '/notAfter=/{print "Valid until "$2"-"substr($1,10)"-"$4" @ "$3}' 2>&1) + certinfo=$(openssl x509 -enddate -noout -in "$i" | mawk '/notAfter=/{print "Valid until "$4"-"substr($1,10)"-"$2" "$3}' 2>&1) break done echo -e "$GREEN_BULLET ${aCOLOUR[1]}${aDESCRIPTION[16]} $GREEN_SEPARATOR $certinfo" @@ -291,11 +280,10 @@ $GREEN_LINE" (( ${aENABLED[15]} == 1 )) && Print_Credits Print_Updates (( ${aENABLED[11]} == 1 )) && Print_Useful_Commands - } - Menu_Main(){ - + Menu_Main() + { G_WHIP_CHECKLIST_ARRAY=() for i in "${!aDESCRIPTION[@]}" do @@ -333,7 +321,6 @@ NB: It is executed as bash script, so it needs to be in bash compatible syntax. [[ -f $FP_CUSTOM ]] || aENABLED[10]=0 Save > "$FP_SAVEFILE" - } #///////////////////////////////////////////////////////////////////////////////////// From 98d558a97e9ff1f2ef2832a244e52224457ce578 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Fri, 21 Apr 2023 14:34:06 +0200 Subject: [PATCH 10/10] v8.17 - CHANGELOG | DietPi-Banner: Add link to PR --- CHANGELOG.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 3211a28cb6..0461efff74 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -6,7 +6,7 @@ New images: New software: Enhancements: -- DietPi-Banner | Added a new option to show the Let's Encrypt certificate status (expiry date), when installed via dietpi-letsencrypt or Certbot. Many thanks to @gary2002 for implementing this option. +- DietPi-Banner | Added a new option to show the Let's Encrypt certificate status (expiry date), when installed via dietpi-letsencrypt or Certbot. Many thanks to @gary2002 for implementing this option: https://github.com/MichaIng/DietPi/pull/6314 Bug fixes: - General | Resolved an issue where our recent images had the cron service masked accidentally after first run setup. Many thanks to @Johannes for reporting this issue: https://dietpi.com/forum/t/cron-service-is-masked/16544