Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Add load config to install-server script #748

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 28 additions & 15 deletions install-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ cmdline() {
;;

r)
readonly ROLLING=true
ROLLING=true
;;

*)
Expand All @@ -95,7 +95,7 @@ cmdline() {
echo "Path to the private key file does not exist, please try again."
exit 1
}

configure_mtls

if [[ "$ROLLING" == "true" ]]; then
Expand All @@ -105,6 +105,14 @@ cmdline() {
return 0
}

function load_conf() {
if [ -f /etc/trento/installer.conf ]; then
echo "Loading installer configuration"
# shellcheck source=/dev/null
source /etc/trento/installer.conf
fi
}

function configure_mtls() {
if [[ -n "$ENABLE_MTLS" ]]; then
if [[ -z "$CERT" ]]; then
Expand Down Expand Up @@ -190,23 +198,29 @@ update_helm_dependencies() {
}

install_trento_server_chart() {
local download_chart=${DOWNLOAD_CHART:-true}
local repo_owner=${TRENTO_REPO_OWNER:-"trento-project"}
local runner_image=${TRENTO_RUNNER_IMAGE:-"ghcr.io/$repo_owner/trento-runner"}
local web_image=${TRENTO_WEB_IMAGE:-"ghcr.io/$repo_owner/trento-web"}
local private_key=${PRIVATE_KEY:-"./id_rsa_runner"}
local trento_source_zip="${TRENTO_VERSION}"
local trento_chart_path=${TRENTO_CHART_PATH:-"/tmp/trento-${trento_source_zip}/packaging/helm/trento-server"}
local trento_packages_url="https://github.com/${repo_owner}/trento/archive/refs/tags"

echo "Installing trento-server chart..."
pushd -- /tmp >/dev/null
rm -rf trento-"${trento_source_zip}"
rm -f ${trento_source_zip}.zip
curl -f -sS -O -L "${trento_packages_url}/${trento_source_zip}.zip" >/dev/null
unzip -o "${trento_source_zip}.zip" >/dev/null
popd >/dev/null

pushd -- /tmp/trento-"${trento_source_zip}"/packaging/helm/trento-server >/dev/null
helm dep update >/dev/null
if [[ "$download_chart" == true ]]; then
echo "Downloading trento-server chart..."
pushd -- /tmp >/dev/null
rm -rf trento-"${trento_source_zip}"
rm -f ${trento_source_zip}.zip
curl -f -sS -O -L "${trento_packages_url}/${trento_source_zip}.zip" >/dev/null
unzip -o "${trento_source_zip}.zip" >/dev/null
popd >/dev/null

echo "Updating chart dependencies..."
pushd -- "$trento_chart_path" >/dev/null
helm dep update >/dev/null
popd >/dev/null
fi

local args=(
--set-file trento-runner.privateKey="${private_key}"
Expand All @@ -229,13 +243,12 @@ install_trento_server_chart() {
--set trento-runner.image.pullPolicy=Always
)
fi
helm upgrade --install trento-server . "${args[@]}"

popd >/dev/null
HELM_EXPERIMENTAL_OCI=1 helm upgrade --install trento-server "$trento_chart_path" "${args[@]}"
}

main() {
cmdline "${ARGS[@]}"
load_conf
echo "Installing trento-server on k3s..."
check_requirements
install_k3s
Expand Down