#!/usr/bin/env bash set -e # ------------------------------- # DockShip Installer # ------------------------------- clear echo "\x1b[34m" cat public/ascii.txt echo "\x1b[0m\n\n" echo "Welcome to the DockShip installer!" if [ -f .env ]; then echo "\x1b[31m'.env' file already exists\x1b[0m" exit fi # Prompt for Lite Mode read -p "Do you want to enable Lite Mode? (API only, no UI) [y/N]: " lite_mode if [[ "$lite_mode" =~ ^([yY][eE][sS]|[yY])$ ]]; then echo "DOCKSHIP_LITE=true" > .env else echo "DOCKSHIP_LITE=false" > .env fi # Prompt for port read -p "Enter the port DockShip should run on [3000]: " PORT PORT=${PORT:-3000} echo "PORT=$PORT" >> .env # Prompt for ORIGIN type echo "" echo "Choose the origin IP for DockShip:" echo "1) Local IP (Recommended)" echo "2) Public IP (Unsafe)" read -p "Enter choice [1/2]: " ip_choice if [[ "$ip_choice" == "1" ]]; then # Get local IP (first non-loopback IP) LOCAL_IP=$(hostname -I | awk '{print $1}') ORIGIN="http://$LOCAL_IP:$PORT" elif [[ "$ip_choice" == "2" ]]; then # Get public IP via external service PUBLIC_IP=$(curl -s https://api.ipify.org) ORIGIN="http://$PUBLIC_IP:$PORT" else echo "\x1b[31mInvalid choice. Exiting.\x1b[0m" exit 1 fi # Append ORIGIN to .env echo "ORIGIN=$ORIGIN" >> .env echo "Set ORIGIN to $ORIGIN" # Display GitHub OAuth info BASE_URL=$ORIGIN REDIRECT_URL="$BASE_URL/api/auth/callback/github" echo "" echo "To integrate with GitHub, create a GitHub OAuth App here:" echo " https://github.com/settings/applications/new" echo "" echo "Use the following URLs:" echo " Base URL: $BASE_URL" echo " Redirect URL: $REDIRECT_URL" echo "" # Prompt for GitHub Client ID and Secret read -p "Enter your GitHub Client ID: " GITHUB_CLIENT_ID read -p "Enter your GitHub Client Secret: " GITHUB_CLIENT_SECRET # Append to .env echo "GITHUB_CLIENT_ID=$GITHUB_CLIENT_ID" >> .env echo "GITHUB_CLIENT_SECRET=$GITHUB_CLIENT_SECRET" >> .env # Install dependencies echo "" echo "Installing npm dependencies..." npm install # Build the app echo "" echo "Building DockShip..." npm run build # Create systemd service SERVICE_FILE="/etc/systemd/system/dockship.service" INSTALL_DIR=$(pwd) NODE_PATH=$(which node) USER_NAME=$(whoami) echo "" echo "Creating systemd service at $SERVICE_FILE..." sudo tee $SERVICE_FILE > /dev/null <