From 1ed212274bdb026e86921a091fa64bbd471e8333 Mon Sep 17 00:00:00 2001 From: Egor Alexandrovich Gorelyshev <142100707+egorelyshev@users.noreply.github.com> Date: Fri, 16 Feb 2024 17:37:43 +0300 Subject: [PATCH] Create Update-Timezone-AGIXT.sh (#1106) 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 <142100707+pegas07770@users.noreply.github.com> Co-authored-by: pegas07770 <142100707+pegas07770@users.noreply.github.com> Co-authored-by: Josh XT <102809327+Josh-XT@users.noreply.github.com> --- Update-Timezone-AGIXT.sh | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Update-Timezone-AGIXT.sh diff --git a/Update-Timezone-AGIXT.sh b/Update-Timezone-AGIXT.sh new file mode 100644 index 000000000000..8962caa5035c --- /dev/null +++ b/Update-Timezone-AGIXT.sh @@ -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.