summaryrefslogtreecommitdiffstats
path: root/kickstart/ipmi.sh
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2018-02-27 07:11:59 +0100
committerSuren A. Chilingaryan <csa@suren.me>2018-02-27 07:11:59 +0100
commit1becded19ae6ca07e9f1483d8dcc14258bfb0b23 (patch)
treef51226f9a79a537f68fcaa28dda32a92bd5042e2 /kickstart/ipmi.sh
parent4e5b055d02f7ab1f618fb2426cfff9ebc1c9678a (diff)
downloadands-1becded19ae6ca07e9f1483d8dcc14258bfb0b23.tar.gz
ands-1becded19ae6ca07e9f1483d8dcc14258bfb0b23.tar.bz2
ands-1becded19ae6ca07e9f1483d8dcc14258bfb0b23.tar.xz
ands-1becded19ae6ca07e9f1483d8dcc14258bfb0b23.zip
Kickstart
Diffstat (limited to 'kickstart/ipmi.sh')
-rwxr-xr-xkickstart/ipmi.sh144
1 files changed, 144 insertions, 0 deletions
diff --git a/kickstart/ipmi.sh b/kickstart/ipmi.sh
new file mode 100755
index 0000000..4ccd749
--- /dev/null
+++ b/kickstart/ipmi.sh
@@ -0,0 +1,144 @@
+user="ADMIN"
+pass='$ipepdv$'
+sleep=0.5
+
+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 '$ipepdv$' "$@"
+
+}
+
+function configure {
+ 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
+
+ configure $host
+ ipmi $host power on
+ sleep $sleep
+}
+
+function reboot {
+ host=$1
+
+ ipmi $host power off
+ sleep 10
+ ipmi $host power on
+ sleep $sleep
+}
+
+
+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
+else
+ servers=$(seq 1 3)
+fi
+iip=$(for i in $servers ; do echo "192.168.26.4$i" ; done)
+
+shift=1
+if [ -z "$1" ]; then
+ echo "$0 [#-#] <config|install|reboot|boot|wait>"
+ echo "$0 [#] <cmd>"
+ exit
+elif [[ "$1" =~ config ]]; then
+ action="configure"
+elif [[ "$1" =~ install ]]; then
+ action="install"
+elif [[ "$1" =~ reboot ]]; then
+ action="reboot"
+elif [[ "$1" =~ boot ]]; then
+ action="boot"
+elif [[ "$1" =~ status ]]; then
+ action="status"
+elif [[ "$1" =~ wait ]]; then
+ action="wait_off"
+else
+ shift=0
+ action="cmd"
+fi
+
+if [ $shift -eq 1 ]; then
+ shift
+fi
+
+for ip in $iip; do
+ eval "$action" "$ip" "$@"
+done
+
+if [ $action = "install" ]; then
+ sleep 30
+ for ip in $iip; do
+ wait_off "$ip" "$@"
+ configure "$ip" "$@"
+# boot "$iip" "$@"
+ done
+fi