Skip to content

Instantly share code, notes, and snippets.

@christippett
Created May 31, 2024 23:14
Show Gist options
  • Save christippett/ec20bd7744e1c1dd272e72cb076e47c6 to your computer and use it in GitHub Desktop.
Save christippett/ec20bd7744e1c1dd272e72cb076e47c6 to your computer and use it in GitHub Desktop.
Install Tailscale on Steam Deck ft. SquashFS & systemd-sysext
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# _____ _ _ _
# /__ \__ _(_) |___ ___ __ _| | ___
# / /\/ _` | | / __|/ __/ _` | |/ _ \
# / / | (_| | | \__ \ (_| (_| | | __/
# \/ \____|_|_|___/\___\__,_|_|\___| _ _
# ,d88b.d88b, / _\ |_ ___ __ _ _ __ ___ __| | ___ ___| | __
# 88888888888 \ \| __/ _ \/ _` | '_ ` _ \ / _` |/ _ \/ __| |/ /
# `Y8888888Y' _\ \ || __/ (_| | | | | | | (_| | __/ (__| <
# `Y888Y' \__/\__\___|\__,_|_| |_| |_|\__,_|\___|\___|_|\_\
# `Y'
#
# reference:
# → https://tailscale.com/blog/steam-deck
# → https://blogs.igalia.com/berto/2022/09/13/adding-software-to-the-steam-deck-with-systemd-sysext/
#
# -----------------------------------------------------------------------------
set -euo pipefail
ext_dir="$HOME/.local/extensions"
dir="$(mktemp -d)"
pushd .
cd "${dir}"
tarball="$(curl 'https://pkgs.tailscale.com/stable/?mode=json' | jq -r .Tarballs.amd64)"
version="$(echo ${tarball} | cut -d_ -f2)"
curl "https://pkgs.tailscale.com/stable/${tarball}" -o tailscale.tgz
mkdir -p tailscale/usr/{bin,sbin,lib/{systemd/system,extension-release.d}}
tar xzf tailscale.tgz
cp -vrf "tailscale_${version}_amd64"/tailscale tailscale/usr/bin/tailscale
cp -vrf "tailscale_${version}_amd64"/tailscaled tailscale/usr/sbin/tailscaled
cp -vrf "tailscale_${version}_amd64"/systemd/tailscaled.service tailscale/usr/lib/systemd/system/tailscaled.service
sed -i 's/--port.*//g' tailscale/usr/lib/systemd/system/tailscaled.service
source /etc/os-release
echo -e "SYSEXT_LEVEL=1.0\nID=steamos\nVERSION_ID=${VERSION_ID}" >> tailscale/usr/lib/extension-release.d/extension-release.tailscale
if [ ! -h "/var/lib/extensions" ]; then
mkdir -p "$ext_dir"
sudo ln -fsv "$ext_dir" /var/lib/extensions
fi
sudo rm -fv "$ext_dir/tailscale.raw"
mksquashfs tailscale "$ext_dir/tailscale.raw"
if [ ! -f "/etc/default/tailscaled" ]; then
mkdir -p /etc/default
sudo touch /etc/default/tailscaled
fi
popd
rm -rf "${dir}"
sudo systemctl enable --now systemd-sysext
sudo systemd-sysext merge || sudo systemd-sysext refresh
sudo systemctl daemon-reload
sudo systemctl restart tailscaled.service
sudo tailscale up --operator=deck --qr --ssh --accept-dns=false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment