Skip to content

Instantly share code, notes, and snippets.

@DblD
Last active November 4, 2024 20:32
Show Gist options
  • Save DblD/ce4d79bc9c164ac19d151e60f832e59d to your computer and use it in GitHub Desktop.
Save DblD/ce4d79bc9c164ac19d151e60f832e59d to your computer and use it in GitHub Desktop.
Install and Configure ZeroTier on Asahi Linux (Fedora for Apple Silicon) with Automatic GPG Key Retrieval

Title: Install and Configure ZeroTier on Asahi Linux (Fedora for Apple Silicon) with Automatic GPG Key Retrieval

Description:

This script addresses issues with installing ZeroTier on Asahi Linux (Fedora installations on Apple Silicon). It ensures the correct GPG key and repository configuration for systems that may lack native ZeroTier support out of the box. The script performs the following steps:

  1. Checks for the presence of the ZeroTier GPG key in /tmp. If missing, it downloads the key directly from ZeroTier's official source to ensure package authenticity.
  2. Imports the GPG key to verify ZeroTier packages.
  3. Creates a temporary repository configuration file for ZeroTier.
  4. Moves the repository file to /etc/yum.repos.d to make it system-wide.
  5. Installs the zerotier-one package using dnf.
  6. Enables and starts the ZeroTier service immediately.

Designed specifically for Fedora on Apple Silicon via Asahi Linux, this script simplifies ZeroTier installation on devices that might otherwise face compatibility challenges.

#!/bin/bash
# Set variables for paths
GPG_KEY_URL="https://download.zerotier.com/contact%40zerotier.com.gpg"
GPG_KEY_PATH="/tmp/zt-gpg-key"
REPO_TEMP_PATH="/tmp/zerotier.repo"
REPO_PATH="/etc/yum.repos.d/zerotier.repo"
# Check if GPG key is present, download if not
if [ ! -f "$GPG_KEY_PATH" ]; then
echo "GPG key not found at $GPG_KEY_PATH. Downloading..."
if curl -o "$GPG_KEY_PATH" "$GPG_KEY_URL"; then
echo "GPG key downloaded successfully."
else
echo "Error: Failed to download GPG key from $GPG_KEY_URL."
exit 1
fi
else
echo "GPG key found at $GPG_KEY_PATH."
fi
# Import the ZeroTier GPG key
echo "Importing ZeroTier GPG key..."
sudo rpm --import "$GPG_KEY_PATH"
# Create and configure the temporary repository file
echo "Creating temporary repository file..."
sudo tee "$REPO_TEMP_PATH" >/dev/null <<EOF
[zerotier]
name=ZeroTier, Inc. RPM Release Repository
baseurl=http://download.zerotier.com/redhat/fc/40
enabled=1
gpgcheck=1
EOF
# Move the repo file to the appropriate location
echo "Moving repository file to $REPO_PATH..."
sudo mv -f "$REPO_TEMP_PATH" "$REPO_PATH"
sudo chown root:root "$REPO_PATH"
# Install the ZeroTier package
echo "Installing ZeroTier package..."
sudo dnf install -y zerotier-one
# Enable and start the ZeroTier service
echo "Enabling and starting the ZeroTier service..."
sudo systemctl enable zerotier-one.service --now
# Verify the service is running
echo "Checking ZeroTier service status..."
sudo zerotier-cli info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment