Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 37 additions & 13 deletions content/scripts/install-tailscale.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ main() {

TAILSCALE_VERSION="1.88.1"
JETKVM_IP=""
SSH_CONFIG_NAME=""
AUTO_YES=false
CLEAN_INSTALL=false
CLEAN_INSTALL=false


# Parse command line arguments
while [ $# -gt 0 ]; do
Expand All @@ -26,28 +28,47 @@ main() {
-c | --clean)
CLEAN_INSTALL=true
shift
-s | --ssh-config)
SSH_CONFIG_NAME="$2"
shift 1
;;
*)
JETKVM_IP="$1"
if [ -z "$JETKVM_IP" ]; then
JETKVM_IP="$1"
else
echo "ERROR: Unknown argument: $1"
exit 1
fi
shift
;;
esac
done

# Set SSH target based on whether config name is provided
if [ -n "$SSH_CONFIG_NAME" ]; then
SSH_TARGET="$SSH_CONFIG_NAME"
else
SSH_TARGET="root@$JETKVM_IP"
fi

if [ -z "$JETKVM_IP" ]; then
echo "ERROR: JetKVM IP address is required"
echo ""
echo "Usage: $0 [-v|--version <TAILSCALE_VERSION>] [-y|--yes] <JETKVM_IP>"
echo "Usage: $0 [OPTIONS] <JETKVM_IP>"
echo ""
echo "Options:"
echo " -v, --version Specify Tailscale version (default: $TAILSCALE_VERSION)"
echo " -y, --yes Automatically answer yes to confirmation prompt"
echo " -c, --clean Delete any existing tailscale data (will cause a new machine to be created)"
echo " -v, --version Specify Tailscale version (default: $TAILSCALE_VERSION)"
echo " -y, --yes Automatically answer yes to confirmation prompt"
echo " -c, --clean Delete any existing tailscale data (will cause a new machine to be created)"
echo " -s, --ssh-config <NAME> Name of SSH config entry to use instead of root@IP"
echo ""
echo "Arguments:"
echo " JETKVM_IP IP address of the JetKVM device (required)"
echo ""
echo "Examples:"
echo " $0 192.168.1.64"
echo " $0 -v 1.88.1 -y 192.168.1.64"
echo " $0 --version 1.88.1 192.168.1.64"
echo " $0 -s jetkvm 192.168.1.64"
echo " $0 -v 1.88.1 -y -s jetkvm 192.168.1.64"
echo ""
echo "Default Tailscale version: $TAILSCALE_VERSION (first version to support JetKVM)"
exit 1
Expand All @@ -63,6 +84,9 @@ main() {
echo ""
echo " JetKVM IP: $JETKVM_IP"
echo " Tailscale Version: $TAILSCALE_VERSION"
if [ -n "$SSH_CONFIG_NAME" ]; then
echo " SSH Config: $SSH_CONFIG_NAME"
fi
echo ""
echo " Note: The device will be rebooted during installation"
echo ""
Expand Down Expand Up @@ -110,7 +134,7 @@ main() {
# First, test SSH connectivity without BatchMode to get proper error messages
SSH_TEST_OUTPUT=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
-o PreferredAuthentications=publickey -o PubkeyAuthentication=yes -o PasswordAuthentication=no \
root@"$JETKVM_IP" 'echo "SSH OK"' 2>&1) || SSH_EXIT_CODE=$?
"$SSH_TARGET" 'echo "SSH OK"' 2>&1) || SSH_EXIT_CODE=$?

if [ "${SSH_EXIT_CODE:-0}" -ne 0 ]; then
echo ""
Expand Down Expand Up @@ -161,11 +185,11 @@ main() {
echo " Package verification successful"

echo "[5/7] Transferring Tailscale package to JetKVM..."
ssh root@"${JETKVM_IP}" "cat > /userdata/tailscale.tgz" <"$TMP_FILE"
ssh "$SSH_TARGET" "cat > /userdata/tailscale.tgz" <"$TMP_FILE"

echo "[6/7] Installing and configuring Tailscale on JetKVM..."
ssh -o ServerAliveInterval=1 -o ServerAliveCountMax=1 \
root@"$JETKVM_IP" \
"$SSH_TARGET" \
"export TAILSCALE_VERSION=$TAILSCALE_VERSION CLEAN_INSTALL=$CLEAN_INSTALL; ash -s" 2>/dev/null <<'EOF' || true
set -e

Expand Down Expand Up @@ -204,7 +228,7 @@ EOF
while [ "$i" -le 120 ]; do
echo " Checking device status... ($i/120s)"
if ssh -q -o ConnectTimeout=2 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
root@"$JETKVM_IP" 'tailscale version' >/dev/null 2>&1; then
"$SSH_TARGET" 'tailscale version' >/dev/null 2>&1; then
echo " JetKVM is back online with Tailscale installed!"
break
fi
Expand All @@ -220,7 +244,7 @@ EOF
done

echo "[7/7] Starting Tailscale service..."
ssh root@"$JETKVM_IP" "tailscale up"
ssh "$SSH_TARGET" "tailscale up"
echo ""
echo "SUCCESS: Tailscale installation completed!"
echo " Your JetKVM device is now ready to connect to your Tailscale network."
Expand Down