2018-06-13 20:12:52 +02:00
|
|
|
#!/usr/bin/env bash
|
2018-06-05 07:01:18 +02:00
|
|
|
|
|
|
|
set -ex
|
2018-06-06 20:34:04 +02:00
|
|
|
set -o pipefail
|
2018-06-05 07:01:18 +02:00
|
|
|
|
|
|
|
if ! command -v curl &> /dev/null; then
|
|
|
|
echo >&2 'error: "curl" not found!'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! command -v gpg &> /dev/null; then
|
|
|
|
echo >&2 'error: "gpg" not found!'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-04-07 20:44:13 +02:00
|
|
|
GOSU_VERSION=1.12
|
2023-10-26 07:08:58 +02:00
|
|
|
|
|
|
|
ARCH=$(uname -m)
|
|
|
|
case "$ARCH" in
|
|
|
|
x86_64)
|
|
|
|
GOSU_ARCH=amd64
|
|
|
|
;;
|
|
|
|
aarch64)
|
|
|
|
GOSU_ARCH=arm64
|
|
|
|
;;
|
|
|
|
armv7l)
|
|
|
|
GOSU_ARCH=armhf
|
|
|
|
;;
|
|
|
|
armv6l)
|
|
|
|
GOSU_ARCH=armel
|
|
|
|
;;
|
|
|
|
i686|i386)
|
|
|
|
GOSU_ARCH=i386
|
|
|
|
;;
|
|
|
|
mips64el)
|
|
|
|
GOSU_ARCH=mips64el
|
|
|
|
;;
|
|
|
|
ppc64el)
|
|
|
|
GOSU_ARCH=ppc64el
|
|
|
|
;;
|
|
|
|
riscv64)
|
|
|
|
GOSU_ARCH=riscv64
|
|
|
|
;;
|
|
|
|
s390x)
|
|
|
|
GOSU_ARCH=s390x
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Error: unsupported arch (${ARCH}) by gosu (https://github.com/tianon/gosu/releases)" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
url="https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${GOSU_ARCH}"
|
|
|
|
url_key="https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${GOSU_ARCH}.asc"
|
2018-06-05 07:01:18 +02:00
|
|
|
|
|
|
|
# download and verify the signature
|
|
|
|
export GNUPGHOME="$(mktemp -d)"
|
|
|
|
|
2018-06-06 20:34:04 +02:00
|
|
|
gpg --keyserver hkp://pool.sks-keyservers.net:80 --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 || \
|
|
|
|
gpg --keyserver hkp://pgp.key-server.io:80 --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 || \
|
|
|
|
gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
|
2018-06-05 07:01:18 +02:00
|
|
|
|
|
|
|
echo "Downloading $url"
|
2021-08-06 01:17:47 +02:00
|
|
|
curl --connect-timeout 30 \
|
|
|
|
--max-time 10 \
|
|
|
|
--retry 5 \
|
|
|
|
--retry-delay 10 \
|
|
|
|
--retry-max-time 30 \
|
|
|
|
-o /usr/local/bin/gosu -# -SL $url
|
2018-06-05 07:01:18 +02:00
|
|
|
|
|
|
|
echo "Downloading $url_key"
|
2021-08-06 01:17:47 +02:00
|
|
|
curl --connect-timeout 30 \
|
|
|
|
--max-time 10 \
|
|
|
|
--retry 5 \
|
|
|
|
--retry-delay 10 \
|
|
|
|
--retry-max-time 30 \
|
|
|
|
-o /usr/local/bin/gosu.asc -# -SL $url_key
|
2018-06-05 07:01:18 +02:00
|
|
|
|
|
|
|
gpg --verify /usr/local/bin/gosu.asc
|
|
|
|
|
2019-04-22 18:18:16 +02:00
|
|
|
# cleanup -- need to kill agent so that there is no race condition for
|
2019-04-22 20:29:35 +02:00
|
|
|
# agent files in $GNUPGHOME. Only need to do this on newer distros
|
2019-05-22 19:13:13 +02:00
|
|
|
# with gpgconf installed supporting the option.
|
2019-04-22 20:29:35 +02:00
|
|
|
GPGCONF_BIN="$(command -v gpgconf)" || true
|
2019-05-22 19:13:13 +02:00
|
|
|
if [ -n "$GPGCONF_BIN" ] && [ -x $GPGCONF_BIN ] && [[ $($GPGCONF_BIN --help | grep -- "--kill" || true) != "" ]]; then
|
|
|
|
gpgconf --kill gpg-agent
|
2019-04-22 20:29:35 +02:00
|
|
|
fi
|
|
|
|
|
2018-06-05 07:01:18 +02:00
|
|
|
rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc
|
|
|
|
|
|
|
|
chmod +x /usr/local/bin/gosu
|