forked from yindun/ansible-devops
更新 scripts/system_optimize.sh
This commit is contained in:
parent
a9888b8de5
commit
a337fcc88d
|
|
@ -151,6 +151,13 @@ update_grub_configuration() {
|
|||
log_info "GRUB配置已更新"
|
||||
}
|
||||
|
||||
#修改主机名
|
||||
rename_hostname(){
|
||||
IP=$(ip addr | awk '/^[0-9]+: / {}; /inet.*global/ {print gensub(/(.*)\/(.*)/, "\\1", "g", $2)}' | grep `ip route | grep default | awk '{print $3}' | awk -F. '{print $1"."$2}' | head -1` | head -1 | sed 's/\./-/g')
|
||||
hostnamectl set-hostname ${IP}
|
||||
}
|
||||
|
||||
|
||||
# 主函数:按顺序执行所有配置步骤
|
||||
main() {
|
||||
log_info "开始系统配置..."
|
||||
|
|
@ -161,6 +168,7 @@ main() {
|
|||
synchronize_hardware_clock
|
||||
disable_nouveau_driver
|
||||
update_grub_configuration
|
||||
rename_hostname
|
||||
log_info "系统配置完成!"
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue