aboutsummaryrefslogtreecommitdiff
path: root/bin/age
diff options
context:
space:
mode:
Diffstat (limited to 'bin/age')
-rwxr-xr-xbin/age41
1 files changed, 41 insertions, 0 deletions
diff --git a/bin/age b/bin/age
new file mode 100755
index 0000000..d0d4eef
--- /dev/null
+++ b/bin/age
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+set -euo pipefail
+
+v=1.0.0
+
+basedir="${0%/*}"
+self="${0##*/}"
+
+s=$(uname -s)
+case "$s"
+in
+ Darwin) s=darwin ;;
+ Linux) s=linux ;;
+ *) echo "Unsupported system: $s" >/dev/stderr; exit 1 ;;
+esac
+
+m=$(uname -m)
+case "$m"
+in
+ x86_64) m=amd64 ;;
+ arm64) ;;
+ *) echo "Unsupported machine: $m" >/dev/stderr; exit 1 ;;
+esac
+
+url=https://github.com/FiloSottile/age/releases/download/v${v}/age-v${v}-${s}-${m}.tar.gz
+
+tar="$basedir/.age/age-${v}.tar.gz"
+bin="${tar%.tar.gz}/age/$self"
+
+if [[ ! -x "$bin" ]]
+then
+ mkdir -p "${tar%/*}"
+ wget -O "$tar" "$url"
+
+ mkdir -p "${tar%.tar.gz}"
+ tar xf "$tar" -C "${tar%.tar.gz}"
+ chmod +x "$bin"
+fi
+
+exec "$bin" "${@}"