Skip to content

Commit

Permalink
install-script: install rpms from SOS repo (#556)
Browse files Browse the repository at this point in the history
# Description
We change the installation script so it can install packages from SOS
repos directly trhough yum and dnf.

## Checklist
(For exoscale contributors)

* [x] Changelog updated (under *Unreleased* block)
* [x] Testing

## Testing
The script was tested in docker containers for ubuntu:jammy(apt),
ubunty:focal(dpkg), fedora(dnf), centos:7(yum). I tested both fresh
installs, downgrading and upgrading an existing installation.

---------

Co-authored-by: Philipp Sauter <[email protected]>
  • Loading branch information
sauterp and sauterp authored Oct 26, 2023
1 parent 7face0d commit 1ed21e9
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## UNRELEASED

### Improvements

- install-script: install rpms from SOS repo #556

## 1.74.4

### Improvements
Expand Down
65 changes: 46 additions & 19 deletions install-latest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,24 @@ PKGFILE="${PKGPREFIX}_${LATEST_VERSION}_${OSTYPE}_${CPUARCHITECTURE}.${FILEEXT}"
PKGSIGFILE=$PKGFILE.sig
PKGPATH=$TEMPDIR/$PKGFILE
PKGSIGPATH=$TEMPDIR/$PKGSIGFILE
$CURL "$GITHUB_DOWNLOAD_URL/${LATEST_TAG}/$PKGFILE" >$PKGPATH

# check the checksum
CHECKSUMSFILE="${PKGPREFIX}_${LATEST_VERSION}_checksums.txt"
CHECKSUMSPATH=$TEMPDIR/$CHECKSUMSFILE
$CURL "$GITHUB_DOWNLOAD_URL/${LATEST_TAG}/$CHECKSUMSFILE" >$CHECKSUMSPATH
download_pkg() {
$CURL "$GITHUB_DOWNLOAD_URL/${LATEST_TAG}/$PKGFILE" >$PKGPATH

COMPUTED_CHECKSUM=$(sha256sum "$PKGPATH" | cut -d " " -f 1)
EXPECTED_CHECKSUM=$(grep -m 1 $PKGFILE $CHECKSUMSPATH | cut -d " " -f 1)
CHECKSUMSFILE="${PKGPREFIX}_${LATEST_VERSION}_checksums.txt"
CHECKSUMSPATH=$TEMPDIR/$CHECKSUMSFILE
$CURL "$GITHUB_DOWNLOAD_URL/${LATEST_TAG}/$CHECKSUMSFILE" >$CHECKSUMSPATH

if [ "$COMPUTED_CHECKSUM" != "$EXPECTED_CHECKSUM" ]; then
echo "Error: Checksum of $PKGFILE does not match the expected checksum"
echo $COMPUTED_CHECKSUM
echo $EXPECTED_CHECKSUM
exit 1
fi
COMPUTED_CHECKSUM=$(sha256sum "$PKGPATH" | cut -d " " -f 1)
EXPECTED_CHECKSUM=$(grep -m 1 $PKGFILE $CHECKSUMSPATH | cut -d " " -f 1)

if [ "$COMPUTED_CHECKSUM" != "$EXPECTED_CHECKSUM" ]; then
echo "Error: Checksum of $PKGFILE does not match the expected checksum"
echo $COMPUTED_CHECKSUM
echo $EXPECTED_CHECKSUM
exit 1
fi
}

TOOLING_KEY_NAME="Exoscale Tooling <[email protected]>"
TOOLING_KEY_FINGERPRINT="7100E8BFD6199CE0374CB7F003686F8CDE378D41"
Expand All @@ -171,9 +173,9 @@ verify_pkg() {
fi
}

if command -v gpg >/dev/null 2>&1; then
if command -v gpg >/dev/null 2>&1 && [ "$PACKAGETYPE" != "yum" ]; then
if ! gpg --list-keys | grep -q $TOOLING_KEY_FINGERPRINT; then
gpg --recv-keys "$TOOLING_KEY_FINGERPRINT"
gpg --keyserver keys.openpgp.org --recv-keys "$TOOLING_KEY_FINGERPRINT"
fi

GPG_AVAILABLE=yes
Expand All @@ -184,6 +186,32 @@ else
fi
fi

install_rpm_pkg() {
repofile=/etc/yum.repos.d/exoscale-cli.repo
cat <<EOF | $SUDO tee $repofile
[exoscale-cli-repo]
name=exoscale-cli-repo
baseurl=https://sos-ch-gva-2.exo.io/exoscale-packages/rpm/cli
enabled=1
repo_gpgcheck=1
gpgcheck=0
gpgkey=https://keys.openpgp.org/vks/v1/by-fingerprint/7100E8BFD6199CE0374CB7F003686F8CDE378D41
EOF

if [ "$PACKAGETYPE" = "yum" ]; then
REPOFLAG=""
else
REPOFLAG="--repo=exoscale-cli-repo"
fi
if $PACKAGETYPE list installed exoscale-cli >/dev/null 2>&1; then
$SUDO $PACKAGETYPE makecache -y $REPOFLAG
$SUDO $PACKAGETYPE $REPOFLAG upgrade -y exoscale-cli
else
$SUDO $PACKAGETYPE makecache -y $REPOFLAG
$SUDO $PACKAGETYPE $REPOFLAG install -y exoscale-cli
fi
}

echo "Installing exo CLI, using $PACKAGETYPE"
case "$PACKAGETYPE" in
apt)
Expand All @@ -194,15 +222,14 @@ case "$PACKAGETYPE" in
$SUDO apt-get install -y exoscale-cli
;;
dpkg)
download_pkg
verify_pkg
$SUDO dpkg -i $PKGPATH
;;
yum)
verify_pkg
$SUDO yum install -y $PKGPATH
install_rpm_pkg
;;
dnf)
verify_pkg
$SUDO dnf install -y $PKGPATH
install_rpm_pkg
;;
esac

0 comments on commit 1ed21e9

Please sign in to comment.