| @@ -1,25 +1,26 @@ | |||
| #!/bin/bash | |||
| # Define the CentOS Vault base URL (use appropriate version and architecture) | |||
| # Define the CentOS Vault base URL | |||
| VAULT_BASEURL="http://vault.centos.org/" | |||
| # Iterate over all repo files in /etc/yum.repos.d | |||
| # for repo_file in /etc/yum.repos.d/*.repo; do | |||
| # if [ -f "$repo_file" ]; then | |||
| # echo "Processing $repo_file..." | |||
| # Prompt for the file pattern with a default value | |||
| read -p "Enter the file pattern for repo files (default: /etc/yum.repos.d/*.repo): " repo_pattern | |||
| repo_pattern="${repo_pattern:-/etc/yum.repos.d/*.repo}" | |||
| # # Comment out any mirrorlist line | |||
| # sudo sed -i 's/^mirrorlist=/#mirrorlist=/' "$repo_file" | |||
| # # Replace any baseurl starting with http://mirror.centos.org/.* with the Vault base URL | |||
| # sudo sed -i "s|^baseurl=http://mirror.centos.org/.*|baseurl=$VAULT_BASEURL|" "$repo_file" | |||
| # Iterate over all repo files based on the user input or the default | |||
| for repo_file in $repo_pattern; do | |||
| if [ -f "$repo_file" ]; then | |||
| echo "Processing $repo_file..." | |||
| # Comment out any mirrorlist line | |||
| sudo sed -i 's/^mirrorlist=/#mirrorlist=/' "$repo_file" | |||
| # # If there's no baseurl line, add the Vault base URL at the end of the file | |||
| # if ! grep -q "^baseurl=" "$repo_file"; then | |||
| # echo "baseurl=$VAULT_BASEURL" | sudo tee -a "$repo_file" > /dev/null | |||
| # fi | |||
| # fi | |||
| # done | |||
| # Replace baseurl starting with http://mirror.centos.org/ and retain everything after it | |||
| sudo sed -i 's|^#baseurl=http://mirror.centos.org/\(.*\)|baseurl=http://vault.centos.org/\1|' "$repo_file" | |||
| else | |||
| echo "No repo files found matching the pattern $repo_pattern" | |||
| fi | |||
| done | |||
| echo "Completed updating all .repo files." | |||
| @@ -85,4 +86,3 @@ sync_appstream_repo | |||
| perform_system_update | |||
| echo "AppStream sync process completed!" | |||