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 11, 2024
1 parent a92fc90 commit 1018299
Show file tree
Hide file tree
Showing 3 changed files with 14 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
12 changes: 12 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
VERSION_ID=$2

if dpkg --compare-versions "$PREVIOUS_PKG_VER" lt "32~"; then
# When we perform the write operation through
Expand Down Expand Up @@ -81,4 +82,15 @@ if dpkg --compare-versions "$PREVIOUS_PKG_VER" lt "35~"; then
if [ -f "/var/lib/ubuntu-advantage/private/machine-token.json" ]; then
touch "/var/lib/ubuntu-advantage/marker-only-series-check"
fi

# 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 [ "$VERSION_ID" = "20.04" ] || [ "$VERSION_ID" = "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 1018299

Please sign in to comment.