feat: Install salt using onedir packages

This commit is contained in:
Carlos Álvaro
2023-04-19 12:03:31 +02:00
committed by Carlos D. Álvaro
parent b6422db262
commit 4cad83b724
13 changed files with 87 additions and 96 deletions

View File

@@ -52,16 +52,7 @@ function exec_as_salt()
}
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: is_arm32
# DESCRIPTION: Check whether the platform is ARM 32-bits or not.
#----------------------------------------------------------------------------------------------------------------------
function is_arm32()
{
uname -m | grep -qE 'armv7l'
}
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: is_arm32
# NAME: is_arm64
# DESCRIPTION: Check whether the platform is ARM 64-bits or not.
#----------------------------------------------------------------------------------------------------------------------
function is_arm64()
@@ -69,15 +60,6 @@ function is_arm64()
uname -m | grep -qE 'arm64|aarch64'
}
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: is_arm32
# DESCRIPTION: Check whether the platform is ARM or not.
#----------------------------------------------------------------------------------------------------------------------
function is_arm()
{
is_arm32 || is_arm64
}
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: install_pkgs
# DESCRIPTION: Install packages using apt-get install.
@@ -90,6 +72,9 @@ function install_pkgs()
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: download
# DESCRIPTION: Download the content from the given URL and save it into the specified file.
# ARGUMENTS:
# 1: URL where the file is hosted.
# 2: Filename (with path) for the downloaded file.
#----------------------------------------------------------------------------------------------------------------------
function download()
{
@@ -97,7 +82,6 @@ function download()
local FILE_NAME="$2"
local WGET_ARGS=(--quiet)
is_arm32 && WGET_ARGS+=(--no-check-certificate)
log_info "Downloading ${FILE_NAME} from ${URL} ..."
wget ${WGET_ARGS[@]} -O "${FILE_NAME}" "${URL}"
@@ -112,6 +96,9 @@ function download()
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: check_sha256
# DESCRIPTION: Compute the SHA256 hash for the given file and check if it matches the expected one.
# ARGUMENTS:
# 1: The file to check.
# 2: The expected SHA256 checksum.
#----------------------------------------------------------------------------------------------------------------------
function check_sha256()
{
@@ -133,6 +120,8 @@ function check_sha256()
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: extract
# DESCRIPTION: Extract the given .tar.gz into the current directory.
# ARGUMENTS:
# 1: The file to extract.
#----------------------------------------------------------------------------------------------------------------------
function extract()
{
@@ -140,3 +129,20 @@ function extract()
log_info "Unpacking file: ${FILE}"
tar xzf "${FILE}" --strip-components 1
}
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: add_salt_repository
# DESCRIPTION: Add salt repository to packages sources.
#----------------------------------------------------------------------------------------------------------------------
function add_salt_repository()
{
local arch=amd64
is_arm64 && arch=arm64
source /etc/os-release
local keyring_file="/etc/apt/keyrings/salt-archive-keyring.gpg"
local root_url="https://repo.saltproject.io/salt/py3/ubuntu/${VERSION_ID:?}/${arch}"
download "${root_url}/SALT-PROJECT-GPG-PUBKEY-2023.gpg" "${keyring_file}"
echo "deb [signed-by=${keyring_file} arch=${arch}] ${root_url}/minor/${SALT_VERSION} ${VERSION_CODENAME:?} main" > /etc/apt/sources.list.d/salt.list
}