Skip to content

Commit

Permalink
Updating unpack script to unpack binaries and mirror images
Browse files Browse the repository at this point in the history
Signed-off-by: Jared Hocutt <[email protected]>
  • Loading branch information
jaredhocutt committed Sep 15, 2023
1 parent d23a5cb commit 46d552b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 33 deletions.
50 changes: 43 additions & 7 deletions ocp4_disconnected/unpack.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#!/usr/bin/env bash

set -eux -o pipefail
set -eux

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

CLIENTS_DIR=${SCRIPT_DIR}/clients
IMAGES_DIR=${SCRIPT_DIR}/images
BIN_DIR=${SCRIPT_DIR}/bin
REGISTRY_DIR=${SCRIPT_DIR}/registry
METADATA_DIR=${SCRIPT_DIR}/metadata

REGISTRY_PASSWORD=$(< /dev/urandom tr -dc A-Za-z0-9 | head -c 30)
REGISTRY_PASSWORD=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 30)
LATEST_IMAGES_FILE=$(find ${IMAGES_DIR} -name 'mirror_seq*.tar' | sort -Vr | head -n 1)

###############################################################################
# User Data Prompts
Expand All @@ -18,7 +20,7 @@ REGISTRY_PASSWORD=$(< /dev/urandom tr -dc A-Za-z0-9 | head -c 30)


###############################################################################
# Mirror Registry - Unpack and Install
# Mirror Registry
###############################################################################

mkdir -p ${BIN_DIR}
Expand All @@ -29,9 +31,12 @@ else
fi

mkdir -p ${REGISTRY_DIR}
if $(curl --insecure --silent https://$(hostname --fqdn):8443/status); then
if [[ -d ${REGISTRY_DIR}/quay-install ]]; then
echo "Mirror registry appears to already be running, skipping install"
else
echo ${REGISTRY_PASSWORD} > ${REGISTRY_DIR}/registry_password

cd ${REGISTRY_DIR}
${BIN_DIR}/mirror-registry install \
--quayHostname $(hostname --fqdn) \
--quayRoot ${REGISTRY_DIR}/quay-install \
Expand All @@ -41,6 +46,37 @@ else
--initPassword ${REGISTRY_PASSWORD}
fi

# TODO: Copy mirror registry certs to system trust bundle
# TODO: Unpack oc, oc-mirror, and openshift-install binaries to system
# TODO: Populate mirror registry with images from disk
if [[ ! -f /etc/pki/ca-trust/source/anchors/quay_mirror_registry_ca.pem ]]; then
sudo cp ${REGISTRY_DIR}/quay-install/quay-rootCA/rootCA.pem /etc/pki/ca-trust/source/anchors/quay_mirror_registry_ca.pem
sudo update-ca-trust extract
fi

###############################################################################
# OpenShift Clients
###############################################################################

cd ${SCRIPT_DIR}
if [[ ! -f /usr/local/bin/oc ]]; then
sudo tar --extract --verbose --directory /usr/local/bin --file ${CLIENTS_DIR}/openshift-client-linux.tar.gz oc kubectl
sudo chmod +x /usr/local/bin/oc /usr/local/bin/kubectl
fi

if [[ ! -f /usr/local/bin/oc-mirror ]]; then
sudo tar --extract --verbose --directory /usr/local/bin --file ${CLIENTS_DIR}/oc-mirror.tar.gz oc-mirror
sudo chmod +x /usr/local/bin/oc-mirror
fi

if [[ ! -f /usr/local/bin/openshift-install ]]; then
sudo tar --extract --verbose --directory /usr/local/bin --file ${CLIENTS_DIR}/openshift-install-linux.tar.gz openshift-install
sudo chmod +x /usr/local/bin/openshift-install
fi

###############################################################################
# Populate Mirror Registry
###############################################################################

mkdir -p ${METADATA_DIR}
podman login --username openshift --password $(cat ${REGISTRY_DIR}/registry_password) $(hostname --fqdn):8443

cd ${METADATA_DIR}
oc mirror --from=${LATEST_IMAGES_FILE} docker://$(hostname --fqdn):8443
26 changes: 0 additions & 26 deletions prepare_for_installation.sh

This file was deleted.

0 comments on commit 46d552b

Please sign in to comment.