Skip to content

Commit

Permalink
postinst: migrate CIS to USG on Focal and Jammy
Browse files Browse the repository at this point in the history
The old CIS entitlement will not be recognized on Focal and Jammy after
version 35. This converts the .list file and changes cis/ to usg/ both
in the source and authentication files when running on these series.

Signed-off-by: Renan Rodrigo <[email protected]>
  • Loading branch information
renanrodrigo committed Oct 22, 2024
1 parent 03c90cf commit 5a0ca04
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion debian/ubuntu-advantage-tools.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ case "$1" in
fi

if dpkg --compare-versions "$PREVIOUS_PKG_VER" lt "31~"; then
/usr/lib/ubuntu-advantage/postinst-migrations.sh $PREVIOUS_PKG_VER
/usr/lib/ubuntu-advantage/postinst-migrations.sh $PREVIOUS_PKG_VER $VERSION_ID
fi
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion debian/ubuntu-pro-client.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ case "$1" in
#

if dpkg --compare-versions "$PREVIOUS_PKG_VER" ge "31~"; then
/usr/lib/ubuntu-advantage/postinst-migrations.sh $PREVIOUS_PKG_VER
/usr/lib/ubuntu-advantage/postinst-migrations.sh $PREVIOUS_PKG_VER $VERSION_ID
fi

#
Expand Down
11 changes: 11 additions & 0 deletions lib/postinst-migrations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
set -e

PREVIOUS_PKG_VER=$1
UBUNTU_RELEASE=$2

if dpkg --compare-versions "$PREVIOUS_PKG_VER" lt "32~"; then
# When we perform the write operation through
Expand Down Expand Up @@ -86,5 +87,15 @@ if dpkg --compare-versions "$PREVIOUS_PKG_VER" lt "35~"; then
# is updated to include the snapshot urls for esm-infra and esm-apps
if [ -f "/var/lib/ubuntu-advantage/private/machine-token.json" ]; then
/usr/bin/python3 /usr/lib/ubuntu-advantage/add_esm_snapshot_auth.py

# On Focal and Jammy, the CIS service transitioned to USG from v35
# This changes the lists and authentication files to represent that
# in case CIS is enabled
if [ "$UBUNTU_RELEASE" = "20.04" ] || [ "$UBUNTU_RELEASE" = "22.04" ]; then
if [ -f /etc/apt/sources.list.d/ubuntu-cis.list ]; then
mv /etc/apt/sources.list.d/ubuntu-cis.list /etc/apt/sources.list.d/ubuntu-usg.list
sed -i 's#/cis/ubuntu#/usg/ubuntu#' /etc/apt/sources.list.d/ubuntu-usg.list
sed -i 's#/cis/ubuntu#/usg/ubuntu#' /etc/apt/auth.conf.d/90ubuntu-advantage
fi
fi
fi

0 comments on commit 5a0ca04

Please sign in to comment.