#!/bin/bash # Script to update the weather location in the SL Transport Departures Display # Check if latitude and longitude were provided if [ -z "$1" ] || [ -z "$2" ]; then echo "Error: Latitude and longitude must be provided." echo "Usage: ./update-weather-location.sh LATITUDE LONGITUDE [LOCATION_NAME]" echo "Example: ./update-weather-location.sh 59.3293 18.0686 Stockholm" exit 1 fi # Validate that the latitude and longitude are numeric if ! [[ "$1" =~ ^-?[0-9]+(\.[0-9]+)?$ ]] || ! [[ "$2" =~ ^-?[0-9]+(\.[0-9]+)?$ ]]; then echo "Error: Latitude and longitude must be numbers." echo "Usage: ./update-weather-location.sh LATITUDE LONGITUDE [LOCATION_NAME]" echo "Example: ./update-weather-location.sh 59.3293 18.0686 Stockholm" exit 1 fi LATITUDE=$1 LONGITUDE=$2 LOCATION_NAME=${3:-""} # Update index.html with new latitude and longitude echo "Updating weather location in index.html..." sed -i "s/latitude: [0-9.-]\+/latitude: $LATITUDE/g" index.html sed -i "s/longitude: [0-9.-]\+/longitude: $LONGITUDE/g" index.html # Update location name in the weather widget if provided if [ ! -z "$LOCATION_NAME" ]; then echo "Updating location name to: $LOCATION_NAME" # This is a more complex replacement that might need manual verification sed -i "s/