ipmitool user set password 2 '*****'
ipmitool lan set 1 defgw ipaddr 172.20.1.1
ipmitool lan set 1 netmask 255.255.255.0
ipmitool lan set 1 ipaddr 172.20.1.*
#!/bin/bash
install_ipmitool() {
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.bak
# 修改为阿里源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 安装epel repo源
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
# 其他
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
# 刷新缓存
yum clean all
yum makecache
}
source /etc/os-release
case $ID in
centos)
if [ ! -f "/usr/bin/ipmitool" ];then
if [ $VERSION_ID == 8 ];then
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
else
install_ipmitool
fi
yum install ipmitool -y
fi
ipmitool mc setsysinfo system_name $(ip a|grep -o '172\.20\.[0-9]*\.[0-9]*'|egrep -v '255|^127')
ipmitool mc setsysinfo os_name $ID
ipmitool mc setsysinfo delloem_os_version $VERSION_ID
echo OK
;;
debian)
if [ ! -f "/usr/bin/ipmitool" ];then
mv /etc/apt/sources.list /etc/apt/sources.list.bak
curl -o /etc/apt/sources.list http://172.20.2.250:666/zt/zt/RPM/ipmitool/sources.list
apt update
apt-get install ipmitool -y
fi
ipmitool mc setsysinfo system_name $(ip a|grep -o '172\.20\.[0-9]*\.[0-9]*'|egrep -v '255|^127')
ipmitool mc setsysinfo os_name $ID
ipmitool mc setsysinfo delloem_os_version $VERSION_ID
echo OK
;;
*)
echo OK
;;
esac