Skip to content

Commit

Permalink
Create Update-Timezone-AGIXT.sh (#1106)
Browse files Browse the repository at this point in the history
Script to update the timezone in specified AGiXT Docker Compose files to the current server timezone.

# Explanation of the script:

# Determine Current Timezone:
# Use timedatectl to retrieve information about the current server timezone.
# awk extracts the timezone information from the output.

# Function to Replace Timezone:
# Define a function replace_timezone that takes a file as an argument and uses sed to replace the timezone pattern in the file.
# The pattern TZ=${TZ-[^}]*} matches strings like TZ=${TZ-America/New_York} or similar.

# Array of Files:
# Create an array compose_files containing the names of Docker Compose files to be updated.

# Update Each File:
# Iterate through the array of files and call the replace_timezone function for each file.

# Display Success Message:
# Print a message indicating that the timezone in the files has been successfully updated to the current server timezone.

# This script ensures that the timezone pattern in the specified Docker Compose files is replaced with the current server timezone.

Signed-off-by: pegas07770 <[email protected]>
Co-authored-by: pegas07770 <[email protected]>
Co-authored-by: Josh XT <[email protected]>
  • Loading branch information
3 people authored Feb 16, 2024
1 parent f4633e8 commit 1ed2122
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions Update-Timezone-AGIXT.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
# Script to update the timezone in specified AGiXT Docker Compose files to the current server timezone.

# Determine the current server timezone
current_timezone=$(timedatectl | awk '/Time zone/ {print $3}')

# Function to replace the timezone in a file
replace_timezone() {
local file="$1"
# Use sed to replace the timezone pattern in the file
sed -i "s|TZ=\${TZ-[^}]*}|TZ=\${TZ-$current_timezone}|g" "$file"
}

# Array of files to be updated
compose_files=("docker-compose.yml" "docker-compose-dev.yml" "docker-compose-dev-cuda.yml" "docker-compose-local-nvidia.yml" "docker-compose-local-nvidia-sd.yml")

# Update each file in the array
for file in "${compose_files[@]}"; do
replace_timezone "$file"
done

# Display a message indicating successful update
echo "Timezone in files successfully updated to the current server timezone: $current_timezone"



# Explanation of the script:

# Determine Current Timezone:
# Use timedatectl to retrieve information about the current server timezone.
# awk extracts the timezone information from the output.

# Function to Replace Timezone:
# Define a function replace_timezone that takes a file as an argument and uses sed to replace the timezone pattern in the file.
# The pattern TZ=${TZ-[^}]*} matches strings like TZ=${TZ-America/New_York} or similar.

# Array of Files:
# Create an array compose_files containing the names of Docker Compose files to be updated.

# Update Each File:
# Iterate through the array of files and call the replace_timezone function for each file.

# Display Success Message:
# Print a message indicating that the timezone in the files has been successfully updated to the current server timezone.

# This script ensures that the timezone pattern in the specified Docker Compose files is replaced with the current server timezone.

0 comments on commit 1ed2122

Please sign in to comment.