diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2018-07-05 06:46:09 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2018-07-05 06:46:09 +0200 |
commit | d65dd50278fec1b253fcd3fe4cfcdab533f20cc8 (patch) | |
tree | c7d91ab246242b85b41267d110150be0ec40fd31 | |
download | ipmiboot-d65dd50278fec1b253fcd3fe4cfcdab533f20cc8.tar.gz ipmiboot-d65dd50278fec1b253fcd3fe4cfcdab533f20cc8.tar.bz2 ipmiboot-d65dd50278fec1b253fcd3fe4cfcdab533f20cc8.tar.xz ipmiboot-d65dd50278fec1b253fcd3fe4cfcdab533f20cc8.zip |
Spliting from Ands
-rw-r--r-- | README | 9 | ||||
-rw-r--r-- | config.sh | 28 | ||||
l--------- | ipmi-camera.sh | 1 | ||||
l--------- | ipmi-katrin.sh | 1 | ||||
-rwxr-xr-x | ipmi.sh | 183 |
5 files changed, 222 insertions, 0 deletions
@@ -0,0 +1,9 @@ +Actions +======= +1) We need to build a CD which will request kickstart file from the web server +2) This CD should be programmed in IPMI interface + => Currently placed in /virtual/images/centos74-ands.iso on ipepdvsrv2 +3) The installation is triggered by ipmi commands +4) The web server runs a php script which detects connecting server and templates appropriate kickstart file + => It is installed on ufo.kit.edu in /srv/www/htdocs/ands/kickstart + => Detction is based on MAC address headers which are sent by CentOS CD diff --git a/config.sh b/config.sh new file mode 100644 index 0000000..f60c8a6 --- /dev/null +++ b/config.sh @@ -0,0 +1,28 @@ +sleep=0.5 +itm=~/devops/itm/ +user="ADMIN" +passpath="KIT/Ands/ipmi" + +if [[ $0 =~ "ipmi-katrin.sh" ]]; then + [ -n "$servers" ] || servers=$(seq 1 3) + iip=$(for i in $servers ; do echo "192.168.26.4$i" ; done) + hip=$(for i in $servers ; do echo "192.168.26.$i" ; done) +elif [[ $0 =~ "ipmi-camera.sh" ]]; then + [ -n "$servers" ] || servers=$(seq 3 4) + iip=$(for i in $servers ; do echo "192.168.26.10$i" ; done) + hip=$(for i in $servers ; do echo "192.168.26.8$i" ; done) + passpath="KIT/Ands/ipmi-desktop" +elif [[ $0 =~ "ipmi-student.sh" ]]; then + [ -n "$servers" ] || servers=$(seq 1 7) + hip=$(for i in $servers ; do echo "192.168.26.6$i" ; done) +elif [ -n "$servers" ]; then + iip=$(for i in $servers ; do echo "192.168.26.$i" ; done) + hip=$(for i in $servers ; do echo "192.168.26.$i" ; done) +elif [ -n "$1" ]; then + iip=$1 + hip=$1 + shift +else + echo "No server is specified..." + exit +fi diff --git a/ipmi-camera.sh b/ipmi-camera.sh new file mode 120000 index 0000000..6c161b4 --- /dev/null +++ b/ipmi-camera.sh @@ -0,0 +1 @@ +ipmi.sh
\ No newline at end of file diff --git a/ipmi-katrin.sh b/ipmi-katrin.sh new file mode 120000 index 0000000..6c161b4 --- /dev/null +++ b/ipmi-katrin.sh @@ -0,0 +1 @@ +ipmi.sh
\ No newline at end of file @@ -0,0 +1,183 @@ +function configure { + hosts=$1 + shift + + if [ -n "$1" -a -f "ansible/$1.yml" ]; then + play="$1.yml" + shift + else + play="install.yml" + fi + + ( + cd $itm || { echo "ITM (Ansible scripts) are not found"; exit 1; } +# ansible-playbook -i inventories/ipe.erb -l localhost,$hosts ssh.yml + ansible-playbook -i inventories/ipe.erb -l $hosts $play "$@" + ) +} + +function smipmi_cmd { + echo "- Running: SMCIPMITool " + echo "$@" + /opt/smcipmi/SMCIPMITool "$@" +} + +function smipmi { + host=$1 + shift + smipmi_cmd $host ADMIN '$ipepdv$' "$@" +} + + +function ipmi_cmd { + echo -n "- Running: ipmitool " + echo "$@" + /usr/sbin/ipmitool "$@" +} + +function ipmi { + host=$1 + shift + ipmi_cmd -H $host -U ADMIN -P $pass "$@" + +} + +function set_bootdev { + host=$1 + + ipmi $host chassis bootdev disk persistent cons_redirect=enable verbose=default + sleep 0.5 +} + +function install { + host=$1 + +# Requires license +# smipmi $host wsiso mount 192.168.26.134 /images/centos74-ands.iso + + ipmi $host power off + sleep 10 + ipmi $host chassis bootdev cdrom + sleep $sleep + ipmi $host power on +} + +function boot { + host=$1 + + set_bootdev $host + ipmi $host power on + sleep $sleep +} + +function reboot { + host=$1 + + ipmi $host power off + sleep 10 + + set_bootdev $host + ipmi $host power on + sleep $sleep +} + +function bios { + host=$1 + + ipmi $host power off + sleep 10 + ipmi $host chassis bootdev bios + sleep $sleep + ipmi $host power on +} + + + +function status { + host=$1 + + ipmi $host power status | grep "off" &> /dev/null + if [ $? -ne 0 ]; then echo 1; else echo 0; fi +} + +function wait_off { + host=$1 + + on=1 + while [ 1 ]; do + on=$(status $host) + [ "$on" -eq 0 ] && break + echo " - $host still running..." + sleep 5 + done +} + +function cmd { + ipmi "$@" +} + + +if [[ "$1" =~ ^[0-9\-]+$ ]]; then + IFS='-' read -ra range <<< "$1" + + if [ -n "${range[1]}" ]; then + servers=$(seq ${range[0]} ${range[1]}) + else + servers=$(seq ${range[0]} ${range[0]}) + fi + shift +fi + +source config.sh +pass=$(pass $passpath | head -n 1) + + +shift=1 +if [ -z "$1" ]; then + echo "$0 [#-#] <config|install|reboot|boot|wait>" + echo "$0 [#] <cmd>" + exit +elif [[ "$1" =~ set_bootdev ]]; then + action="set_bootdev" +elif [[ "$1" =~ install ]]; then + action="install" +elif [[ "$1" =~ reboot ]]; then + action="reboot" +elif [[ "$1" =~ boot ]]; then + action="boot" +elif [[ "$1" =~ bios ]]; then + action="bios" +elif [[ "$1" =~ status ]]; then + action="status" +elif [[ "$1" =~ wait ]]; then + action="wait_off" +elif [[ "$1" =~ config ]]; then + action="configure" +else + shift=0 + action="cmd" +fi + +if [ $shift -eq 1 ]; then + shift +fi + + +if [ $action = "configure" ]; then + list=$(echo $hip | sed -re 's/\s+/ /g' | tr ' ' ',') + eval "$action" "$list" "$@" + exit +fi + +for ip in $iip; do + eval "$action" "$ip" "$@" +done + +if [ $action = "install" ]; then + sleep 30 + for ip in $iip; do + wait_off "$ip" "$@" + set_bootdev "$ip" "$@" +# boot "$iip" "$@" + done +fi |