From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
Cc: pmg-devel@lists.proxmox.com
Subject: Re: [pmg-devel] [PATCH pmg-api] postinst: migrate/update APT auth config
Date: Tue, 13 Sep 2022 17:07:13 +0200 [thread overview]
Message-ID: <20220913170713.4aad18ba@rosa.proxmox.com> (raw)
In-Reply-To: <20220913123006.3066752-1-f.gruenbichler@proxmox.com>
Thanks for the patch!
tested on a machine with /etc/apt/auth.conf.d/pmg.conf already present
(and copied over to /etc/apt/auth.conf)
this works as is - the only cosmetic issue (also mentioned in my reply to
the equivalent patch for pve-manager):
On Tue, 13 Sep 2022 14:30:06 +0200
Fabian Grünbichler <f.gruenbichler@proxmox.com> wrote:
> missed when switching over to Proxmox::RS::Subscription, which stores
> the same info in the product-specific /etc/apt/auth.conf.d/pmg.conf .
>
> the top-level file might contain non-PMG-managed entries, so only remove
> entries matching "our" machine.
>
> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> ---
> debian/postinst | 36 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
>
> diff --git a/debian/postinst b/debian/postinst
> index fdcecbf..2fbb73f 100644
> --- a/debian/postinst
> +++ b/debian/postinst
> @@ -19,6 +19,36 @@ ucf_register_templates() {
> done
> }
>
> +migrate_apt_auth_conf() {
> + output=""
> + removed=""
> + match=0
> +
> + while read l; do
> + if echo "$l" | grep -q "^machine enterprise.proxmox.com/debian/pmg"; then
> + match=1
> + elif echo "$l" | grep -q "machine"; then
> + match=0
> + fi
> +
> + if test "$match" = "1"; then
> + removed="$removed\n$l"
> + else
> + output="$output\n$l"
> + fi
> + done < /etc/apt/auth.conf
> +
> + if test -n "$removed"; then
> + if test ! -e /etc/apt/auth.conf.d/pmg.conf; then
> + echo "Migrating APT auth config for enterprise.proxmox.com to /etc/apt/auth.conf.d/pmg.conf .."
> + echo "$removed" > /etc/apt/auth.conf.d/pmg.conf
> + else
> + echo "Removing stale APT auth config from /etc/apt/auth.conf"
> + fi
> + echo "$output" > /etc/apt/auth.conf
this leaves an emtpy /etc/apt/auth.conf (tested on a pmg-install) if the
only auth.conf entry was the one for our hosts
(maybe `test -n "$output" && echo "$output" > /etc/apt/auth.conf`
also maybe printf might save you the trailing newline)
apart from that:
Reviewed-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-by: Stoiko Ivanov <s.ivanov@proxmox.com>
> + fi
> +}
> +
> case "$1" in
> triggered)
>
> @@ -81,6 +111,12 @@ case "$1" in
> # rewrite banner
> pmgbanner || true
> fi
> +
> + if test ! -e /proxmox_install_mode && test -n "$2" && dpkg --compare-versions "$2" 'lt' '7.1-7~'; then
> + if test -e /etc/apt/auth.conf ; then
> + migrate_apt_auth_conf
> + fi
> + fi
> ;;
>
> abort-upgrade)
prev parent reply other threads:[~2022-09-13 15:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-13 12:30 Fabian Grünbichler
2022-09-13 15:07 ` Stoiko Ivanov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220913170713.4aad18ba@rosa.proxmox.com \
--to=s.ivanov@proxmox.com \
--cc=f.gruenbichler@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox