Initial commit: Digital signage system for transit departures, weather, and news ticker
This commit is contained in:
44
update-weather-location.sh
Normal file
44
update-weather-location.sh
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/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/<h3>[^<]*<\/h3>/<h3>$LOCATION_NAME<\/h3>/g" index.html
|
||||
fi
|
||||
|
||||
echo "Weather location updated successfully!"
|
||||
echo "Latitude: $LATITUDE"
|
||||
echo "Longitude: $LONGITUDE"
|
||||
if [ ! -z "$LOCATION_NAME" ]; then
|
||||
echo "Location Name: $LOCATION_NAME"
|
||||
fi
|
||||
echo ""
|
||||
echo "Restart the application to see the changes."
|
||||
echo "You can find latitude and longitude for any location at: https://www.latlong.net/"
|
||||
Reference in New Issue
Block a user