From 3304c8f8a65c36012dfaf2e0f643dd9da42ef84f Mon Sep 17 00:00:00 2001 From: Bas Steins <592313+sebst@users.noreply.github.com> Date: Sun, 13 Oct 2024 11:18:06 +0200 Subject: [PATCH] feat(`tailscale.com`): Add feature. (#19) --- .github/workflows/test.yaml | 2 ++ src/tailscale.com/devcontainer-feature.json | 17 ++++++++++ src/tailscale.com/install.sh | 36 +++++++++++++++++++++ test/tailscale.com/test.sh | 19 +++++++++++ 4 files changed, 74 insertions(+) create mode 100644 src/tailscale.com/devcontainer-feature.json create mode 100755 src/tailscale.com/install.sh create mode 100755 test/tailscale.com/test.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9759942..d914f8f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -21,6 +21,7 @@ jobs: - pkgx.sh - smallstep.com - starship.rs + - tailscale.com - webinstall.dev - zellij.dev baseImage: @@ -50,6 +51,7 @@ jobs: - pkgx.sh - smallstep.com - starship.rs + - tailscale.com - webinstall.dev - zellij.dev steps: diff --git a/src/tailscale.com/devcontainer-feature.json b/src/tailscale.com/devcontainer-feature.json new file mode 100644 index 0000000..ced2220 --- /dev/null +++ b/src/tailscale.com/devcontainer-feature.json @@ -0,0 +1,17 @@ +{ + "name": "tailscale.com", + "id": "tailscale.com", + "version": "1.0.0", + "description": "Install \"tailscale\" binary", + "documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/tailscale.com", + "options": { + "version": { + "type": "string", + "default": "latest", + "proposals": [ + "latest" + ], + "description": "Currently unused." + } + } +} \ No newline at end of file diff --git a/src/tailscale.com/install.sh b/src/tailscale.com/install.sh new file mode 100755 index 0000000..1d73efc --- /dev/null +++ b/src/tailscale.com/install.sh @@ -0,0 +1,36 @@ +#!/bin/bash +set -o errexit +set -o pipefail +set -o noclobber +set -o nounset +set -o allexport +readonly name="tailscale" +apt_get_update() { + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi +} +apt_get_checkinstall() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + apt_get_update + DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends --no-install-suggests --option 'Debug::pkgProblemResolver=true' --option 'Debug::pkgAcquire::Worker=1' "$@" + fi +} +apt_get_cleanup() { + apt-get clean + rm -rf /var/lib/apt/lists/* +} +echo_banner() { + local text="$1" + echo -e "\e[1m\e[97m\e[41m$text\e[0m" +} +install() { + apt_get_checkinstall unzip curl ca-certificates + curl -fsSL https://tailscale.com/install.sh | sh + apt_get_cleanup +} +echo_banner "devcontainer.community" +echo "Installing $name..." +install "$@" +echo "(*) Done!" diff --git a/test/tailscale.com/test.sh b/test/tailscale.com/test.sh new file mode 100755 index 0000000..c8e777f --- /dev/null +++ b/test/tailscale.com/test.sh @@ -0,0 +1,19 @@ +#!/bin/bash + + +set -e + +# Optional: Import test library bundled with the devcontainer CLI +# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib +# Provides the 'check' and 'reportResults' commands. +source dev-container-features-test-lib + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. Syntax is... +# check