From f7f5ea6b851d738f12b2ca2fd6fb050e79a542ae Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Sun, 27 Mar 2022 00:12:45 +0100 Subject: [PATCH] upgrade to snap certbot if old one is used (#2267) --- lib.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib.sh b/lib.sh index 6fe4a58d..00d86171 100644 --- a/lib.sh +++ b/lib.sh @@ -769,11 +769,25 @@ fi # Install certbot (Let's Encrypt) install_certbot() { -certbot --version 2> /dev/null -LE_IS_AVAILABLE=$? -if [ $LE_IS_AVAILABLE -eq 0 ] +if certbot --version >/dev/null 2>&1 then - certbot --version 2> /dev/null + # Reinstall certbot (use snap instead of package) + # https://askubuntu.com/a/1271565 + if dpkg -l | grep certbot >/dev/null 2>&1 + then + # certbot will be removed, but still listed, so we need to check if the snap is installed as well so that this doesn't run every time + if ! snap list certbot >/dev/null 2>&1 + then + print_text_in_color "$ICyan" "Reinstalling certbot (Let's Encrypt) as a snap instead..." + apt-get remove certbot -y + apt-get autoremove -y + install_if_not snapd + snap install core + snap install certbot --classic + # Update $PATH in current session (login and logout is required otherwise) + check_command hash -r + fi + fi else print_text_in_color "$ICyan" "Installing certbot (Let's Encrypt)..." install_if_not snapd