Skip to content

Commit

Permalink
Clean up install-non-distributable.sh
Browse files Browse the repository at this point in the history
Change from minio to s5cmd because s5cmd is plain faster, has batch
support for easier use and plays better with AWS env vars that everyone
else has standardized on.

Clean up the rest of the script by doing a better job explicitly
checking the environment variables early and with better error messages.
Also take advantage of `set -e` to avoid `&&` and indentation.
  • Loading branch information
mmlb committed Sep 3, 2024
1 parent 1b723e0 commit a7c1444
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 72 deletions.
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ RUN if [[ $TARGETARCH == "amd64" ]] ; then \
RUN rm -rf /tmp/*

# The non-distributable files are executables provided by hardware vendors.
ARG ACCESS_KEY
ARG INSTALL_NON_DISTRIBUTABLE=false
ARG S3_BUCKET_ALIAS=utils
ARG S3_PATH
ARG SECRET_KEY
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG BUCKET
ARG INSTALL_NON_DISTRIBUTABLE
COPY scripts/install-non-distributable.sh non-distributable/
RUN cd non-distributable && ./install-non-distributable.sh
RUN rm -rf non-distributable/
Expand Down
129 changes: 62 additions & 67 deletions scripts/install-non-distributable.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash

set -eux

INSTALL_NON_DISTRIBUTABLE=${INSTALL_NON_DISTRIBUTABLE:-}
Expand All @@ -7,98 +8,92 @@ if ! [[ ${INSTALL_NON_DISTRIBUTABLE,,} =~ ^(1|on|true|y|yes)$ ]]; then
exit 0
fi

ARCH=$(uname -m)
export WORKDIR="non-distributable"

# a few checks before proceeding
PARENT_DIR="$(basename "$(pwd)")"

[[ "$PARENT_DIR" != "${WORKDIR}" ]] && echo "expected to be executed from within ${WORKDIR} directory" && exit 1
[[ "${ARCH}" != "x86_64" ]] && echo "nothing to be done for arch: ${ARCH}" && exit 0

# minio client s3 parameters
# https://github.com/minio/mc/blob/master/docs/minio-client-complete-guide.md#specify-temporary-host-configuration-through-environment-variable
export MC_HOST_${S3_BUCKET_ALIAS}="https://${ACCESS_KEY}:${SECRET_KEY}@s3.amazonaws.com"
set -v +x

export ASRDEV_KERNEL_MODULE=asrdev-5.4.0-73-generic.ko

# set minio client url
OS=$(uname -s)
ARCH=$(uname -m)
if [[ -z ${AWS_ACCESS_KEY_ID:-} ]]; then
echo AWS_ACCESS_KEY_ID env var is missing >&2
exit 1
fi

MC_ARCH=$ARCH
if [[ -z ${AWS_SECRET_ACCESS_KEY:-} ]]; then
echo AWS_SECRET_ACCESS_KEY env var is missing >&2
exit 1
fi

MC_ARCH=$ARCH
set +v -x

case $ARCH in
aarch64 | arm64)
MC_ARCH=arm64
;;
x86_64)
MC_ARCH=amd64
;;
*)
echo "unsupported ARCH; $ARCH"
if [[ -z ${BUCKET:-} ]]; then
echo BUCKET env var is missing >&2
exit 1
;;
esac
fi

case $OS in
Darwin*)
MC_URL="https://dl.min.io/client/mc/release/darwin-${MC_ARCH}/mc"
;;
Linux*)
MC_URL="https://dl.min.io/client/mc/release/linux-${MC_ARCH}/mc"
;;
*)
echo "unsupported OS: $OS"
# a few checks before proceeding
if [[ $(basename "${PWD}") != non-distributable ]]; then
echo "expected to be executed from within non-distributable directory"
exit 1
;;
esac
fi

# install minio client to fetch firmware tooling artifacts
curl "${MC_URL}" -o mc && chmod +x mc
ARCH=$(uname -m)
if [[ $ARCH != "x86_64" ]]; then
echo "nothing to be done for arch: $ARCH"
exit 0
fi

# install s5cmd to fetch firmware tooling artifacts
s5cmd_url=https://github.com/peak/s5cmd/releases/download/v2.2.2/s5cmd_2.2.2_
case $(uname -s):$ARCH in
Darwin:arm64) s5cmd_url+=macOS-arm64 ;;
Darwin:x86_64) s5cmd_url+=macOS-64bit ;;
Linux:aarch64) s5cmd_url+=Linux-arm64 ;;
Linux:x86_64) s5cmd_url+=Linux-64bit ;;
esac
s5cmd_url+=.tar.gz
curl --fail --location --silent "$s5cmd_url" | tar -xz s5cmd
chmod +x s5cmd

# fetch vendor tools
./mc cp "${S3_PATH}"/mlxup .
./mc cp "${S3_PATH}"/msecli_Linux.run .
./mc cp "${S3_PATH}"/IPMICFG_1.32.0_build.200910.zip .
./mc cp "${S3_PATH}"/sum_2.10.0_Linux_x86_64_20221209.tar.gz .
./mc cp "${S3_PATH}"/SW_Broadcom_Unified_StorCLI_v007.1316.0000.0000_20200428.ZIP .
./mc cp "${S3_PATH}"/asrr/BIOSControl_v1.0.3.zip .
./mc cp "${S3_PATH}"/asrr/asrr_bios_kernel_module/$ASRDEV_KERNEL_MODULE .
./mc cp "${S3_PATH}"/mvcli-4.1.13.31_A01.zip .
cat <<-EOF | ./s5cmd run
cp s3://${BUCKET}/IPMICFG_1.32.0_build.200910.zip .
cp s3://${BUCKET}/SW_Broadcom_Unified_StorCLI_v007.1316.0000.0000_20200428.ZIP .
cp s3://${BUCKET}/asrr/BIOSControl_v1.0.3.zip .
cp s3://${BUCKET}/asrr/asrr_bios_kernel_module/asrdev-5.4.0-73-generic.ko .
cp s3://${BUCKET}/mlxup .
cp s3://${BUCKET}/msecli_Linux.run .
cp s3://${BUCKET}/mvcli-4.1.13.31_A01.zip .
cp s3://${BUCKET}/sum_2.10.0_Linux_x86_64_20221209.tar.gz .
EOF

# install dependencies
#

# install Mellanox mlxup
install -m 755 -D mlxup /usr/sbin/

# install SMC sum 2.10.0
tar -xvzf sum_2.10.0_Linux_x86_64_20221209.tar.gz &&
install -m 755 -D sum_2.10.0_Linux_x86_64/sum /usr/sbin/
tar -xvzf sum_2.10.0_Linux_x86_64_20221209.tar.gz
install -m 755 -D sum_2.10.0_Linux_x86_64/sum /usr/sbin/

# install SMC ipmicfg
unzip IPMICFG_1.32.0_build.200910.zip &&
install -m 755 -D IPMICFG_1.32.0_build.200910/Linux/64bit/IPMICFG-Linux.x86_64 /usr/sbin/smc-ipmicfg
unzip IPMICFG_1.32.0_build.200910.zip
install -m 755 -D IPMICFG_1.32.0_build.200910/Linux/64bit/IPMICFG-Linux.x86_64 /usr/sbin/smc-ipmicfg

# install Broadcom storcli
unzip SW_Broadcom_Unified_StorCLI_v007.1316.0000.0000_20200428.ZIP &&
rpm --import Unified_storcli_all_os/Linux/pubKey.asc &&
rpm -ivh Unified_storcli_all_os/Linux/storcli-007.1316.0000.0000-1.noarch.rpm
unzip SW_Broadcom_Unified_StorCLI_v007.1316.0000.0000_20200428.ZIP
rpm --import Unified_storcli_all_os/Linux/pubKey.asc
rpm -ivh Unified_storcli_all_os/Linux/storcli-007.1316.0000.0000-1.noarch.rpm

# install AsRockRack BIOSControl and copy kernel module
unzip BIOSControl_v1.0.3.zip &&
install -m 755 -D BIOSControl /usr/sbin/asrr-bioscontrol &&
cp asrdev*.*.ko /opt/asrr/
unzip BIOSControl_v1.0.3.zip
install -m 755 -D BIOSControl /usr/sbin/asrr-bioscontrol
cp asrdev*.*.ko /opt/asrr/

# install Marvell mvcli
unzip mvcli-4.1.13.31_A01.zip &&
install -m 755 -D mvcli-4.1.13.31_A01/x64/cli/mvcli /usr/sbin/mvcli &&
install -m 755 -D mvcli-4.1.13.31_A01/x64/cli/libmvraid.so /usr/lib/libmvraid.so
unzip mvcli-4.1.13.31_A01.zip
install -m 755 -D mvcli-4.1.13.31_A01/x64/cli/mvcli /usr/sbin/mvcli
install -m 755 -D mvcli-4.1.13.31_A01/x64/cli/libmvraid.so /usr/lib/libmvraid.so

# install Dell msecli
chmod 755 msecli_Linux.run && ./msecli_Linux.run --mode unattended
chmod 755 msecli_Linux.run
./msecli_Linux.run --mode unattended

# Add symlink to location where OSIE expects vendor tools to be
ln -s /usr/sbin/sum /opt/supermicro/sum/sum
Expand Down

0 comments on commit a7c1444

Please sign in to comment.