-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
install-script: install rpms from SOS repo (#556)
# 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
Showing
2 changed files
with
52 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -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 | ||
|
@@ -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) | ||
|
@@ -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 |