diff options
author | Daniel Graña | 2024-02-12 16:19:48 -0300 |
---|---|---|
committer | Daniel Graña | 2024-02-12 16:20:01 -0300 |
commit | fb41ac4f26e02cf862027cd8407e97aaa3516d26 (patch) | |
tree | 130856d9c0dde79ca087442648395f83b7f7d434 | |
parent | 139ba3e461c25c282eaaf69df47e8de1dba346ac (diff) | |
download | aur-mkinitcpio-tailscale.tar.gz |
simplified initial setup
-rw-r--r-- | .SRCINFO | 6 | ||||
-rw-r--r-- | PKGBUILD | 6 | ||||
-rwxr-xr-x | setup-initcpio-tailscale | 35 |
3 files changed, 28 insertions, 19 deletions
@@ -1,6 +1,6 @@ pkgbase = mkinitcpio-tailscale pkgdesc = mkinitcpio hook to launch Tailscale on systemd or busybox based initramfs - pkgver = 0.3 + pkgver = 0.4 pkgrel = 1 url = https://github.com/dangra/mkinitcpio-tailscale arch = any @@ -9,8 +9,8 @@ pkgbase = mkinitcpio-tailscale source = initcpio-hooks-tailscale source = initcpio-install-tailscale source = setup-initcpio-tailscale - sha256sums = 5c341668e502c5e54e25b24607b1eb004a78d52332c48ccdfb07003f19f6fc8d + sha256sums = 55177e12c2292665ca86a9235d17e61f7ad080d2ed236e7de60be048116d2f15 sha256sums = 60ebfa2d0a557d0b951a3a3cec01023acbb24feb55c986561e5c8e94bec1a77f - sha256sums = fa0bec1288bb190389fc9fad26d0a3a366b3933be27e0957fa9d5d8f12b94253 + sha256sums = e6cf49ea9ac359d21665444c2a3ab009aedb52d215e47287ecff7d6d4159d4c2 pkgname = mkinitcpio-tailscale @@ -1,7 +1,7 @@ # Maintainer: Daniel Graña <dangra at gmail dot com> pkgname=mkinitcpio-tailscale -pkgver=0.3 +pkgver=0.4 pkgrel=1 pkgdesc="mkinitcpio hook to launch Tailscale on systemd or busybox based initramfs" arch=("any") @@ -11,9 +11,9 @@ depends=("mkinitcpio") source=("initcpio-hooks-tailscale" "initcpio-install-tailscale" "setup-initcpio-tailscale") -sha256sums=('5c341668e502c5e54e25b24607b1eb004a78d52332c48ccdfb07003f19f6fc8d' +sha256sums=('55177e12c2292665ca86a9235d17e61f7ad080d2ed236e7de60be048116d2f15' '60ebfa2d0a557d0b951a3a3cec01023acbb24feb55c986561e5c8e94bec1a77f' - 'fa0bec1288bb190389fc9fad26d0a3a366b3933be27e0957fa9d5d8f12b94253') + 'e6cf49ea9ac359d21665444c2a3ab009aedb52d215e47287ecff7d6d4159d4c2') package() { install -m 644 -D ${srcdir}/initcpio-hooks-tailscale ${pkgdir}/usr/lib/initcpio/hooks/tailscale diff --git a/setup-initcpio-tailscale b/setup-initcpio-tailscale index 97c9502c00f2..2be2c5f4987a 100755 --- a/setup-initcpio-tailscale +++ b/setup-initcpio-tailscale @@ -10,16 +10,18 @@ usage() { cat <<EOF ${CMD0} launches and configures Tailscale daemon in an isolated environment that doesn't mess with the system service. -usage: ${CMD0} [options] [-- [tailscale-up-options...]] +usage: ${CMD0} [option...] - Options: - -H Hostname to use when registering the node (default: '${TS_HOSTNAME}') +The setup script shouldn't require any arguments to get it working, but keep in mind that any extra argument is passed as-is to 'tailscale up'. +See 'tailscale up --help' for available flags. -Any arguments after '--' (double dash), like in 'setup-initcpio-tailscale -- --ssh' are passed verbatim to 'tailscale up'. -See 'tailscale up --help' output for available flags. i.e.: +i.e.: - ${CMD0} -H ${TS_HOSTNAME} -- --ssh --login-server=headscale.my.net --authkey=file:node.key + ${CMD0} --hostname ${TS_HOSTNAME} --ssh --login-server=headscale.my.net --authkey=file:node.key +The default value for '--hostname' is the current hostname plus '-initrd' suffix, in this case "${TS_HOSTNAME}". + +If in doubt, run '$CMD0' without arguments. EOF } @@ -38,13 +40,20 @@ cleanup() { } trap "cleanup" EXIT -while getopts H:k:d:t:h flag; do - case "$flag" in - H) TS_HOSTNAME="$OPTARG" ;; - ?) usage; exit 0 ;; - esac +# Scan arguments looking for --hostname=VALUE +FOUND_HOSTNAME_IN_ARGS=no +for arg in "$@"; do + if [[ $arg =~ ^(-h|--help|help)$ ]]; then + usage + exit 0 + fi + if [[ $arg =~ ^--hostname= ]]; then + TS_HOSTNAME=${arg#*=} + TS_HOSTNAME=${TS_HOSTNAME//[\"\']} + FOUND_HOSTNAME_IN_ARGS=yes + fi done -shift $(( OPTIND - 1 )) +[[ $FOUND_HOSTNAME_IN_ARGS == yes ]] || set -- --hostname="$TS_HOSTNAME" "$@" SETUPDIR="$(mktemp -d)" socket="${SETUPDIR}/tailscaled.sock" @@ -60,7 +69,7 @@ PID="$!" # --accept-risk=lose-ssh is fine because we are setting up an isolated tailscaled daemon, # it has nothing to do with system tailscale service. -if ! tailscale --socket="$socket" up --qr --hostname="$TS_HOSTNAME" --accept-risk=lose-ssh "$@"; then +if ! tailscale --socket="$socket" up --qr --accept-risk=lose-ssh "$@"; then cp -f "${SETUPDIR}/setup.log" /tmp/setup-initcpio-tailscale-daemon.log die "Failed to configure tailscale. Check daemon logs at /tmp/setup-initcpio-tailscale-daemon.log" fi |