Skip to content

Instantly share code, notes, and snippets.

@metaxis
Forked from FlorianHeigl/ipmi-setup.sh
Created September 7, 2018 18:55
Show Gist options
  • Save metaxis/aba4016261603c29601e4876c4fb73e0 to your computer and use it in GitHub Desktop.
Save metaxis/aba4016261603c29601e4876c4fb73e0 to your computer and use it in GitHub Desktop.
script for ipmi setup
#!/usr/bin/env bash
# Base ipmi access setup script to be run from BMC
set -u
tgtip=xxx.xxx.xxx.xxx
tgtnet=$(echo $tgtip | cut -f1-3 -d\.)
# intel S2600: 2
# supermicro: 0
lanchannel=2
identify_sys(){
sleep 30 ; ipmitool chassis identify
}
show_current_cfg() {
ipmitool lan print 2
ipmitool user list 2
}
set_nic_to_shared() {
# here is the command for supermicro
# for intel, the channel ID seems to be sufficient.
# this info is from the following thread (as usual, scroll down for the valuable answers)
# https://serverfault.com/questions/361940/configuring-supermicro-ipmi-to-use-one-of-the-lan-interfaces-instead-of-the-ipmi
# To get LAN mode: ipmitool raw 0x30 0x70 0x0c 0.
# To set LAN mode dedicated: ipmitool raw 0x30 0x70 0x0c 1 0.
# To set LAN mode onboard/shared: ipmitool raw 0x30 0x70 0x0c 1 1.
# To set LAN mode failover: ipmitool raw 0x30 0x70 0x0c 1 2.
echo "not implemented"
}
set_ip_params(){
ipmitool lan set "${lanchannel}" ipaddr "${tgtip}"
ipmitool lan set "${lanchannel}" netmask 255.255.255.0
ipmitool lan set "${lanchannel}" defgw ipaddr ${tgtnet}.1
}
set_user_params() {
ipmitool user set password "${lanchannel}" superuser
ipmitool lan set "${lanchannel}" access on
ipmitool user enable "${lanchannel}"
ipmitool lan set "${lanchannel}" user
}
main() {
identify_sys
show_current_cfg
set_ip_params
set_user_params
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment