2024-03-16 07:45:28 +00:00
|
|
|
#!/usr/bin/env bash
|
2019-05-14 16:31:53 +00:00
|
|
|
|
2024-03-16 07:45:28 +00:00
|
|
|
set -o errexit
|
|
|
|
set -o nounset
|
|
|
|
set -o pipefail
|
2019-05-14 16:31:53 +00:00
|
|
|
|
|
|
|
export GITHUB="true"
|
|
|
|
|
2024-03-16 07:59:42 +00:00
|
|
|
GITHUB_ACTION_PATH="${GITHUB_ACTION_PATH%/}"
|
2024-03-16 07:45:28 +00:00
|
|
|
DRONE_SSH_RELEASE_URL="${DRONE_SSH_RELEASE_URL:-https://github.com/appleboy/drone-ssh/releases/download}"
|
|
|
|
DRONE_SSH_VERSION="${DRONE_SSH_VERSION:-1.7.4}"
|
|
|
|
|
|
|
|
function detect_client_info() {
|
|
|
|
if [ -n "${SSH_CLIENT_OS-}" ]; then
|
|
|
|
CLIENT_PLATFORM="${SSH_CLIENT_OS}"
|
|
|
|
else
|
|
|
|
local kernel
|
|
|
|
kernel="$(uname -s)"
|
|
|
|
case "${kernel}" in
|
|
|
|
Darwin)
|
|
|
|
CLIENT_PLATFORM="darwin"
|
|
|
|
;;
|
|
|
|
Linux)
|
|
|
|
CLIENT_PLATFORM="linux"
|
|
|
|
;;
|
|
|
|
Windows)
|
|
|
|
CLIENT_PLATFORM="windows"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown, unsupported platform: ${kernel}." >&2
|
|
|
|
echo "Supported platforms: Linux, Darwin and Windows." >&2
|
|
|
|
echo "Bailing out." >&2
|
|
|
|
exit 2
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "${SSH_CLIENT_ARCH-}" ]; then
|
|
|
|
CLIENT_ARCH="${SSH_CLIENT_ARCH}"
|
|
|
|
else
|
|
|
|
local machine
|
|
|
|
machine="$(uname -m)"
|
|
|
|
case "${machine}" in
|
|
|
|
x86_64*|i?86_64*|amd64*)
|
|
|
|
CLIENT_ARCH="amd64"
|
|
|
|
;;
|
|
|
|
aarch64*|arm64*)
|
|
|
|
CLIENT_ARCH="arm64"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown, unsupported architecture (${machine})." >&2
|
|
|
|
echo "Supported architectures x86_64, i686, arm64." >&2
|
|
|
|
echo "Bailing out." >&2
|
|
|
|
exit 3
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
detect_client_info
|
|
|
|
DOWNLOAD_URL_PREFIX="${DRONE_SSH_RELEASE_URL}/v${DRONE_SSH_VERSION}"
|
|
|
|
CLIENT_BINARY="drone-ssh-${DRONE_SSH_VERSION}-${CLIENT_PLATFORM}-${CLIENT_ARCH}"
|
2024-07-10 16:25:58 +00:00
|
|
|
TARGET="${GITHUB_ACTION_PATH}/${CLIENT_BINARY}"
|
|
|
|
URL="https://git.dsvision.net/suyiiyii/ssh-action/raw/branch/master/drone-ssh-1.7.6-linux-amd64"
|
2024-07-11 04:24:35 +00:00
|
|
|
echo "Will download ${CLIENT_BINARY} from ${URL}"
|
2024-07-10 16:25:58 +00:00
|
|
|
curl -fL --retry 3 --keepalive-time 2 "${URL}" -o ${TARGET}
|
2024-03-16 07:59:42 +00:00
|
|
|
chmod +x ${TARGET}
|
|
|
|
sh -c "${TARGET} $*"
|