refactor: move config loading to shared directory

This commit is contained in:
syntaxbullet
2026-01-08 16:15:55 +01:00
parent 88b266f81b
commit 2b641c952d
23 changed files with 15 additions and 219 deletions

View File

@@ -0,0 +1,43 @@
#!/bin/bash
# Load environment variables
if [ -f .env ]; then
set -a
source .env
set +a
fi
if [ -z "$VPS_HOST" ] || [ -z "$VPS_USER" ]; then
echo "Error: VPS_HOST and VPS_USER must be set in .env"
echo "Please add them to your .env file:"
echo "VPS_USER=your-username"
echo "VPS_HOST=your-ip-address"
exit 1
fi
DASHBOARD_PORT=${DASHBOARD_PORT:-3000}
echo "🌐 Establishing secure tunnel to Aurora Dashboard..."
echo "📊 Dashboard will be accessible at: http://localhost:$DASHBOARD_PORT"
echo "Press Ctrl+C to stop the connection."
echo ""
# Function to open browser (cross-platform)
open_browser() {
sleep 2
if command -v open &> /dev/null; then
open "http://localhost:$DASHBOARD_PORT"
elif command -v xdg-open &> /dev/null; then
xdg-open "http://localhost:$DASHBOARD_PORT"
fi
}
# Check if autossh is available
if command -v autossh &> /dev/null; then
SSH_CMD="autossh -M 0 -o ServerAliveInterval=30 -o ServerAliveCountMax=3"
else
SSH_CMD="ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=3"
fi
open_browser &
$SSH_CMD -N -L $DASHBOARD_PORT:127.0.0.1:$DASHBOARD_PORT $VPS_USER@$VPS_HOST

25
shared/scripts/remote-studio.sh Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
# Load environment variables
if [ -f .env ]; then
# export $(grep -v '^#' .env | xargs) # Use a safer way if possible, but for simple .env this often works.
# Better way to source .env without exporting everything to shell if we just want to use them in script:
set -a
source .env
set +a
fi
if [ -z "$VPS_HOST" ] || [ -z "$VPS_USER" ]; then
echo "Error: VPS_HOST and VPS_USER must be set in .env"
echo "Please add them to your .env file:"
echo "VPS_USER=your-username"
echo "VPS_HOST=your-ip-address"
exit 1
fi
echo "🔮 Establishing secure tunnel to Drizzle Studio..."
echo "📚 Studio will be accessible at: https://local.drizzle.studio"
echo "Press Ctrl+C to stop the connection."
# -N means "Do not execute a remote command". -L is for local port forwarding.
ssh -N -L 4983:127.0.0.1:4983 $VPS_USER@$VPS_HOST

61
shared/scripts/remote.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/bash
# Load environment variables
if [ -f .env ]; then
set -a
source .env
set +a
fi
if [ -z "$VPS_HOST" ] || [ -z "$VPS_USER" ]; then
echo "Error: VPS_HOST and VPS_USER must be set in .env"
echo "Please add them to your .env file:"
echo "VPS_USER=your-username"
echo "VPS_HOST=your-ip-address"
exit 1
fi
DASHBOARD_PORT=${DASHBOARD_PORT:-3000}
STUDIO_PORT=${STUDIO_PORT:-4983}
echo "🚀 Establishing secure tunnels to Aurora services..."
echo ""
echo "📊 Dashboard: http://localhost:$DASHBOARD_PORT"
echo "🔮 Studio: http://localhost:$STUDIO_PORT (https://local.drizzle.studio)"
echo ""
echo "Press Ctrl+C to stop all connections."
echo ""
# Function to open browser (cross-platform)
open_browser() {
sleep 2 # Wait for tunnel to establish
if command -v open &> /dev/null; then
# macOS
open "http://localhost:$DASHBOARD_PORT"
elif command -v xdg-open &> /dev/null; then
# Linux
xdg-open "http://localhost:$DASHBOARD_PORT"
elif command -v start &> /dev/null; then
# Windows (Git Bash)
start "http://localhost:$DASHBOARD_PORT"
fi
}
# Check if autossh is available for auto-reconnection
if command -v autossh &> /dev/null; then
echo "✅ Using autossh for automatic reconnection"
SSH_CMD="autossh -M 0 -o ServerAliveInterval=30 -o ServerAliveCountMax=3"
else
echo "💡 Tip: Install autossh for automatic reconnection (brew install autossh)"
SSH_CMD="ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=3"
fi
# Open browser in background
open_browser &
# Start both tunnels
# -N means "Do not execute a remote command". -L is for local port forwarding.
$SSH_CMD -N \
-L $DASHBOARD_PORT:127.0.0.1:$DASHBOARD_PORT \
-L $STUDIO_PORT:127.0.0.1:$STUDIO_PORT \
$VPS_USER@$VPS_HOST