mirror of
https://github.com/thelittlerocket/pve.git
synced 2025-03-03 17:27:17 +08:00
Update install_pve.sh
This commit is contained in:
parent
64153d5953
commit
6f0e319b38
1 changed files with 27 additions and 27 deletions
|
@ -129,33 +129,33 @@ hostname=$(hostname)
|
||||||
if [ "${hostname}" != "pve" ]; then
|
if [ "${hostname}" != "pve" ]; then
|
||||||
chattr -i /etc/hosts
|
chattr -i /etc/hosts
|
||||||
hosts=$(grep -E "^[^#]*\s+${hostname}\s+${hostname}\$" /etc/hosts | grep -v "${ip}")
|
hosts=$(grep -E "^[^#]*\s+${hostname}\s+${hostname}\$" /etc/hosts | grep -v "${ip}")
|
||||||
if [ -n "${hosts}" ]; then
|
if [ -n "${hosts}" ]; then
|
||||||
# 注释掉查询到的行
|
# 注释掉查询到的行
|
||||||
sudo sed -i "s/^$(echo ${hosts} | sed 's/\//\\\//g')/# &/" /etc/hosts
|
sudo sed -i "s/^$(echo ${hosts} | sed 's/\//\\\//g')/# &/" /etc/hosts
|
||||||
# 添加新行
|
# 添加新行
|
||||||
# echo "${ip} ${hostname} ${hostname}" | sudo tee -a /etc/hosts > /dev/null
|
# echo "${ip} ${hostname} ${hostname}" | sudo tee -a /etc/hosts > /dev/null
|
||||||
# _green "已将 ${ip} ${hostname} ${hostname} 添加到 /etc/hosts 文件中"
|
# _green "已将 ${ip} ${hostname} ${hostname} 添加到 /etc/hosts 文件中"
|
||||||
else
|
else
|
||||||
_blue "已存在 ${ip} ${hostname} ${hostname} 的记录,无需添加"
|
_blue "已存在 ${ip} ${hostname} ${hostname} 的记录,无需添加"
|
||||||
fi
|
fi
|
||||||
chattr -i /etc/hostname
|
chattr -i /etc/hostname
|
||||||
hostnamectl set-hostname pve
|
hostnamectl set-hostname pve
|
||||||
chattr +i /etc/hostname
|
chattr +i /etc/hostname
|
||||||
hostname=$(hostname)
|
hostname=$(hostname)
|
||||||
if ! grep -q "::1 localhost" /etc/hosts; then
|
if ! grep -q "::1 localhost" /etc/hosts; then
|
||||||
echo "::1 localhost" >> /etc/hosts
|
echo "::1 localhost" >> /etc/hosts
|
||||||
echo "Added ::1 localhost to /etc/hosts"
|
echo "Added ::1 localhost to /etc/hosts"
|
||||||
fi
|
fi
|
||||||
# if grep -q "^127\.0\.0\.1 localhost$" /etc/hosts; then
|
if grep -q "^127\.0\.1\.1" /etc/hosts; then
|
||||||
# sed -i '/^127\.0\.0\.1 localhost$/ s/^/#/' /etc/hosts
|
sed -i '/^127\.0\.1\.1/s/^/#/' /etc/hosts
|
||||||
# echo "Commented out 127.0.0.1 localhost in /etc/hosts"
|
echo "Commented out lines starting with 127.0.1.1 in /etc/hosts"
|
||||||
# fi
|
fi
|
||||||
if ! grep -q "^127\.0\.0\.1 localhost\.localdomain localhost$" /etc/hosts; then
|
if ! grep -q "^127\.0\.0\.1 localhost\.localdomain localhost$" /etc/hosts; then
|
||||||
# 127.0.1.1
|
# 127.0.1.1
|
||||||
echo "${ip} ${hostname}.localdomain ${hostname}" >> /etc/hosts
|
echo "${ip} ${hostname}.localdomain ${hostname}" >> /etc/hosts
|
||||||
echo "Added ${ip} ${hostname}.localdomain ${hostname} to /etc/hosts"
|
echo "Added ${ip} ${hostname}.localdomain ${hostname} to /etc/hosts"
|
||||||
fi
|
fi
|
||||||
chattr +i /etc/hosts
|
chattr +i /etc/hosts
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## 更改网络优先级为IPV4优先
|
## 更改网络优先级为IPV4优先
|
||||||
|
|
Loading…
Reference in a new issue