snap: fix generated postrefreshhook script (#9994)

Fixes #9990

If the python oneliner to check certbot's version succeeded, exit_code
would never be set, which would cause our exit_code check to fail. Use
a check that handles unset exit_code
This commit is contained in:
Will Greenberg 2024-11-01 08:03:57 -07:00 committed by GitHub
parent 2660a2017b
commit 165c3e32b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -25,7 +25,7 @@ cb_required=\$(grep -oP "version = '\K.*(?=')" \$SNAP/setup.py)
\$SNAP/bin/python3 -c "import sys; from packaging import version; sys.exit(1) if\
version.parse('\$cb_installed') < version.parse('\$cb_required') else sys.exit(0)" || exit_code=\$?
if [ "\$exit_code" -eq 1 ]; then
if [ "\$exit_code" = "1" ]; then
echo "Certbot is version \$cb_installed but needs to be at least \$cb_required before" \\
"this plugin can be updated; will try again on next refresh."
exit 1