#!/bin/bash # Script to update the site ID for the SL Transport API # Check if a site ID was provided if [ -z "$1" ]; then echo "Error: No site ID provided." echo "Usage: ./update-site-id.sh SITE_ID" echo "Example: ./update-site-id.sh 1234" exit 1 fi # Validate that the site ID is numeric if ! [[ "$1" =~ ^[0-9]+$ ]]; then echo "Error: Site ID must be a number." echo "Usage: ./update-site-id.sh SITE_ID" echo "Example: ./update-site-id.sh 1234" exit 1 fi SITE_ID=$1 SITE_NAME="" # Ask for site name (optional) read -p "Enter site name (optional, press Enter to skip): " SITE_NAME # Update server.js echo "Updating server.js with site ID: $SITE_ID" sed -i "s|const API_URL = 'https://transport.integration.sl.se/v1/sites/[0-9]*/departures'|const API_URL = 'https://transport.integration.sl.se/v1/sites/$SITE_ID/departures'|g" server.js # Update index.html if site name was provided if [ ! -z "$SITE_NAME" ]; then echo "Updating index.html with site name: $SITE_NAME" sed -i "s|

.*

|

$SITE_NAME (Site ID: $SITE_ID)

|g" index.html fi # Update title in index.html if [ ! -z "$SITE_NAME" ]; then echo "Updating page title in index.html" sed -i "s|SL Transport Departures - .*|SL Transport Departures - $SITE_NAME ($SITE_ID)|g" index.html fi echo "Update complete!" echo "Site ID: $SITE_ID" if [ ! -z "$SITE_NAME" ]; then echo "Site Name: $SITE_NAME" fi echo "Restart the server for changes to take effect: node server.js"