Файловый менеджер - Редактировать - /var/opt/nydus/ops/customer_local_ops/operating_system/resources/update_dns_linux.sh
Назад
#!/usr/bin/env bash invalid_resolvers1=$1 invalid_resolvers2=$2 valid_resolvers1=$3 valid_resolvers2=$4 if [[ -z "$invalid_resolvers1" ]] || [[ -z "$invalid_resolvers2" ]] || [[ -z "$valid_resolvers1" ]] || [[ -z "$valid_resolvers2" ]] then echo "usage: ./update_dns_centos.sh INVALID_RESOLVERS_1 INVALID_RESOLVERS_2 VALID_RESOLVERS_1 VALID_RESOLVERS_2" exit 2 fi check_net_mgr="$(ps -e | grep -i networkmanager)" if [[ ! -z "$check_net_mgr" ]] then echo "Network Manager is running on the box, skipping changes" >/dev/stderr exit 1 fi check_dns1="$(grep "$invalid_resolvers1" /etc/resolv.conf)" check_dns2="$(grep "$invalid_resolvers2" /etc/resolv.conf)" err_msg="no servers could be reached" if [[ ! -z "$check_dns1" ]] || [[ ! -z "$check_dns2" ]] then echo "resolv.conf has invalid resolvers" chk_domain_resolv="$(dig google.com +short)" if [[ ! -z "$chk_domain_resolv" ]] && [[ "$chk_domain_resolv" != *"$err_msg"* ]] then echo "Domain getting resolved successfully with invalid resolvers" cp /etc/resolv.conf /var/tmp echo "resolv.conf backup created at /var/tmp" echo "Updating invalid resolvers with valid ones" sed -i "s/$invalid_resolvers1/$valid_resolvers1/g" /etc/resolv.conf success_check1=$? sed -i "s/$invalid_resolvers2/$valid_resolvers2/g" /etc/resolv.conf success_check2=$? if [[ "$success_check1" -ne 0 ]] || [[ "$success_check2" -ne 0 ]] then echo "DNS resolvers could not be replaced, restoring backup" >/dev/stderr cp /var/tmp/resolv.conf /etc/resolv.conf exit_code=2 else check_domain="$(dig google.com +short)" if [[ -z "$check_domain" ]] || [[ "$check_domain" == *"$err_msg"* ]] then echo "Valid resolvers could not resolve domain, restoring backup" >/dev/stderr cp /var/tmp/resolv.conf /etc/resolv.conf exit_code=2 else echo "Valid resolvers resolved the domain successfully" exit_code=0 fi fi echo "Deleting backup" rm /var/tmp/resolv.conf exit "$exit_code" else echo "Invalid resolvers did not resolve domain, skipping changes" >/dev/stderr exit 2 fi else echo "resolv.conf does not have invalid resolvers, skipping changes" exit 0 fi
| ver. 1.4 |
Github
|
.
| PHP 8.0.30 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка