#!/bin/bash # URLyup WireGuard Tunnel Setup # Usage: EMAIL=you@example.com bash <(curl -s https://api.urlyup.com/install.sh) # Country: COUNTRY=jp EMAIL=you@example.com bash <(curl -s https://api.urlyup.com/install.sh) # Optional: BYPASS_KEY=key EMAIL=you@example.com bash <(curl -s https://api.urlyup.com/install.sh) set -e if [ -z "$EMAIL" ]; then read -p "Enter your email: " EMAIL fi OS="$(uname -s)" echo "Setting up URLyup tunnel for $EMAIL on $OS..." # Get tunnel config first (works the same on every OS) echo "Requesting tunnel..." CURL_OPTS="" [ -n "$BYPASS_KEY" ] && CURL_OPTS="-H "X-Urlyup-Internal: $BYPASS_KEY"" API_URL="https://api.urlyup.com/easyurl/v1?email=$EMAIL&confirm=true" [ -n "$COUNTRY" ] && API_URL="${API_URL}&country=$COUNTRY" && echo "Country: $COUNTRY" # jq might not be installed yet on a fresh box — install minimally first if needed if ! command -v jq >/dev/null 2>&1; then if command -v apt-get >/dev/null 2>&1; then sudo apt-get update -qq && sudo apt-get install -y -qq jq curl elif command -v yum >/dev/null 2>&1; then sudo yum install -y jq curl elif command -v brew >/dev/null 2>&1; then brew install jq curl else echo "Error: jq is required. Install it and re-run." exit 1 fi fi RESP=$(eval curl -s $CURL_OPTS "$API_URL") if [ -z "$RESP" ]; then echo "Error: No response from API" exit 1 fi # Check for error in response ERR=$(echo "$RESP" | jq -r '.error // empty') if [ -n "$ERR" ]; then MSG=$(echo "$RESP" | jq -r '.message // empty') echo "Error: $ERR" [ -n "$MSG" ] && echo "$MSG" exit 1 fi # Extract fields from response CONFIG=$(echo "$RESP" | jq -r '.config_for_wireguard') URL=$(echo "$RESP" | jq -r '.url_to_reach_host') ADMIN=$(echo "$RESP" | jq -r '.admin_url') ADMINPWD=$(echo "$RESP" | jq -r '.admin_password') AGENT=$(echo "$RESP" | jq -r '.coding_agent_url // empty') # ============================================================ # macOS path — GUI app, no sudo, no /etc/wireguard, no wg-quick # ============================================================ if [ "$OS" = "Darwin" ]; then DEST="$HOME/Downloads/urlyup.conf" echo "$CONFIG" > "$DEST" chmod 600 "$DEST" HAS_APP="no" [ -d "/Applications/WireGuard.app" ] && HAS_APP="yes" echo "" echo "=== URLyup Tunnel Ready (macOS) ===" echo "Public URL: $URL" echo "Admin: $ADMIN" echo "Password: $ADMINPWD" echo "" echo "Config saved to: $DEST" echo "" if [ "$HAS_APP" = "no" ]; then echo "Next steps:" echo " 1. Install WireGuard from the Mac App Store, OR run:" echo " brew install --cask wireguard" echo " 2. Double-click the config file to import:" echo " open \"$DEST\"" echo " 3. Toggle the tunnel on in WireGuard." else echo "WireGuard.app detected. Opening the config now —" echo "WireGuard will offer to import it. Click Allow, then flip the switch." open "$DEST" fi echo "" echo "Test once the tunnel is on:" echo " python3 -m http.server 6000 --bind 0.0.0.0" echo "Then visit: https://6000-${URL#https://}" if [ -n "$AGENT" ]; then echo "" echo "Coding agent: $AGENT" fi exit 0 fi # ============================================================ # Linux path — wg-quick (the original flow) # ============================================================ # Install wireguard-tools if needed if ! command -v wg-quick >/dev/null 2>&1; then if command -v apt-get >/dev/null 2>&1; then sudo apt-get update -qq && sudo apt-get install -y -qq wireguard-tools elif command -v yum >/dev/null 2>&1; then sudo yum install -y wireguard-tools else echo "Error: wireguard-tools not installed and no apt/yum found." exit 1 fi fi # Resolve wg-quick absolute path BEFORE sudo (sudo strips PATH on many distros) WG_QUICK="$(command -v wg-quick)" if [ -z "$WG_QUICK" ]; then echo "Error: wg-quick still not on PATH after install." exit 1 fi # Save config sudo mkdir -p /etc/wireguard [ -f /etc/wireguard/wg0.conf ] && sudo mv /etc/wireguard/wg0.conf /etc/wireguard/wg0.conf.bak echo "$CONFIG" | sudo tee /etc/wireguard/wg0.conf > /dev/null sudo chmod 600 /etc/wireguard/wg0.conf # Start tunnel sudo "$WG_QUICK" down wg0 2>/dev/null || true sudo "$WG_QUICK" up wg0 # Warm up handshake ping -c 3 10.99.0.1 >/dev/null 2>&1 || true echo "" echo "=== URLyup Tunnel Active ===" echo "Public URL: $URL" echo "Admin: $ADMIN" echo "Password: $ADMINPWD" echo "" echo "Test: python3 -m http.server 6000 --bind 0.0.0.0" echo "Then visit: https://6000-${URL#https://}" if [ -n "$AGENT" ]; then echo "" echo "===========================================" echo " UrlyUp Coding Agent" echo "===========================================" echo "" echo " $AGENT" echo "" echo " A fully hosted AI development environment" echo " — a replica of a self-hosted unit for" echo " building apps with AI. Accessible from the" echo " web anywhere, by you and anyone you share" echo " the link with, so they can watch or" echo " contribute using simple chat with no coding" echo " experience required." echo "" echo " The system can be exported to run in-house" echo " at any time with a single click, giving you" echo " a fully functional container accessible" echo " through the same URLs to cut costs." echo "" echo "===========================================" fi