标签:The rip 服务器 file pts ash version 输入 脚本
脚本内容↓
[root@clsn scripts]# cat xiugaizhuji.sh
#!/bin/bash
#############################################################
# File Name: jiaohu.sh
# Version: V1.0
# Author: clsn
# Organization: http://blog.znix.top
# Created Time : 2017-12-05 10:55:42
# Description:
#############################################################
ethFile=/etc/sysconfig/network-scripts/ifcfg-eth[01]
Now_eth=`hostname -I|awk -F "[. ]+" ‘{print $4}‘`
read -p "请输入主机名:" Hostname
read -p "请输入IP地址的主机位:" HostIP
hostnamectl set-hostname $Hostname
sed -i "s#${Now_eth}#${HostIP}#g" $ethFile
read -p "是否重启服务器:{yes/no}" REboot
if [ $REboot == yes ]
then
echo "系统将在10秒后重启!"
shutdown -r 10
else
echo "请稍后手动重启系统!"
fi
脚本测试结果
[root@clsn scripts]# sh xiugaizhuji.sh
请输入主机名:clsn
请输入IP地址的主机位:180
是否重启服务器:{yes/no}yes
系统将在10秒后重启!
[root@clsn scripts]# sh xiugaizhuji.sh
请输入主机名:clsn
请输入IP地址的主机位:180
是否重启服务器:{yes/no}no
请稍后手动重启!
标签:The rip 服务器 file pts ash version 输入 脚本
原文地址:https://www.cnblogs.com/zhangjiaqing/p/11097587.html