From 418dc3a3329ebeee8b3738be5bdbcbd0f408b118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lesimple?= Date: Fri, 13 Nov 2020 10:15:31 +0100 Subject: [PATCH] feat: add more archs to dockerhub sandbox --- .github/workflows/dockerhub.yml | 5 +++-- README.md | 2 +- bin/admin/install-ttyrec.sh | 34 ++++++++++++++++++--------------- bin/admin/packages-check.sh | 5 +++++ 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/.github/workflows/dockerhub.yml b/.github/workflows/dockerhub.yml index ab7ef16..03f2a48 100644 --- a/.github/workflows/dockerhub.yml +++ b/.github/workflows/dockerhub.yml @@ -18,7 +18,7 @@ jobs: uses: docker/setup-buildx-action@v1 - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_LOGIN }} password: ${{ secrets.DOCKERHUB_TOKEN }} @@ -29,7 +29,8 @@ jobs: with: push: true file: docker/Dockerfile.sandbox - tags: ovhcom/the-bastion:sandbox-latest + tags: ovhcom/the-bastion:sandbox + platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/README.md b/README.md index 2ac3767..b3a2c45 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ This is a good way to test The Bastion within seconds, but [read the FAQ](https: OK, let's run the docker image: - docker run -d -p 22 --name bastiontest ovhcom/the-bastion:sandbox-latest + docker run -d -p 22 --name bastiontest ovhcom/the-bastion:sandbox Get your public SSH key at hand, then configure the first administrator account: diff --git a/bin/admin/install-ttyrec.sh b/bin/admin/install-ttyrec.sh index a925b09..993bad9 100755 --- a/bin/admin/install-ttyrec.sh +++ b/bin/admin/install-ttyrec.sh @@ -22,38 +22,42 @@ EOF set_download_url() { pattern="$1" - action_doing "Checking for prerequisites..." - if command -v curl >/dev/null; then - action_done curl - _apicall() { - curl -sL -H 'Accept: application/vnd.github.v3+json' "$1" - } - _download() { - curl -sL -O "$1" - } - elif command -v wget >/dev/null; then + action_doing "Looking for download tool..." + if command -v wget >/dev/null; then action_done wget _apicall() { - wget -q -O - --header="Accept: application/vnd.github.v3+json" "$1" + wget -q -O - --header="Accept: application/vnd.github.v3+json" "$1" || true } _download() { wget -q "$1" } + elif command -v curl >/dev/null; then + action_done curl + _apicall() { + curl -sL -H 'Accept: application/vnd.github.v3+json' "$1" || true + } + _download() { + curl -sL -O "$1" + } else action_error "Couldn't find wget nor curl" exit 1 fi - action_doing "Getting latest release for arch $arch..." + payload=$(mktemp) + # shellcheck disable=SC2064 + trap "rm -f $payload" EXIT + + _apicall $RELEASE_API_URL > "$payload" if command -v jq >/dev/null; then # If we have jq, we can do it properly - url=$(_apicall $RELEASE_API_URL | jq -r '.[0].assets|.[]|.browser_download_url' | grep -F "$pattern" | head -n1) + url=$(jq -r '.[0].assets|.[]|.browser_download_url' < "$payload" | grep -F "$pattern" | head -n1) elif perl -MJSON -e 1 2>/dev/null; then # If we don't, there's a good chance we have Perl with the JSON module, use it - url=$(_apicall $RELEASE_API_URL | perl -MJSON -e 'undef $/; $d=decode_json(<>); foreach(@{ $d->[0]{assets} || [] }) { $_=$_->{browser_download_url}; /\Q'"$pattern"'\E/ && print && exit }' | head -n1) + url=$(perl -MJSON -e 'undef $/; $d=decode_json(<>); foreach(@{ $d->[0]{assets} || [] }) { $_=$_->{browser_download_url}; /\Q'"$pattern"'\E/ && print && exit }' "$payload" | head -n1) else # Otherwise, go the ugly way, don't bother the user in installing jq just for this need - url=$(_apicall $RELEASE_API_URL | grep -Eo 'https://[a-z0-9./_-]+' | grep -F "$pattern" | head -n1) + url=$(grep -Eo 'https://[a-z0-9./_-]+' "$payload" | grep -F "$pattern" | head -n1) fi if [ -n "$url" ]; then diff --git a/bin/admin/packages-check.sh b/bin/admin/packages-check.sh index f9721e0..a88eace 100755 --- a/bin/admin/packages-check.sh +++ b/bin/admin/packages-check.sh @@ -40,6 +40,11 @@ if echo "$DISTRO_LIKE" | grep -q -w debian; then libwww-perl libdigest-sha-perl libnet-ssleay-perl \ libnet-server-perl cryptsetup mosh expect openssh-server locales \ coreutils netcat bash libcgi-pm-perl iputils-ping" + # workaround for debian/armhf: curl fails to validate some SSL certificates, + # whereas wget succeeds; this is needed for e.g. install-ttyrec.sh + if [ "$(uname -m)" = armv7l ]; then + wanted_list="$wanted_list wget" + fi [ "$opt_dev" = 1 ] && wanted_list="$wanted_list libperl-critic-perl perltidy shellcheck" if { [ "$LINUX_DISTRO" = debian ] && [ "$DISTRO_VERSION_MAJOR" -lt 9 ]; } || { [ "$LINUX_DISTRO" = ubuntu ] && [ "$DISTRO_VERSION_MAJOR" -le 16 ]; }; then