-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboot-from-iso.sh
executable file
·65 lines (51 loc) · 1.82 KB
/
boot-from-iso.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
set -euoE pipefail
usage() {
echo "${@}"
echo "Usage: $0 -r idrac-hostname -u user -p password -i http://iso-url" 1>&2;
exit 1;
}
if [[ $# -ne 8 ]]; then
usage "Insufficinet number of parameters"
fi
while getopts ":r:u:p:i:" o; do
case "${o}" in
r)
HOST=${OPTARG};;
u)
USER=${OPTARG};;
p)
PASSWORD=${OPTARG};;
i)
ISO_URL=${OPTARG}
[[ $ISO_URL =~ http://.* ]] || usage "Iso should be with http prefix"
;;
*)
usage;;
esac
done
shift $((OPTIND-1))
echo HOST = $HOST
echo USER = $USER
echo PASSWORD = $PASSWORD
echo ISO_URL = $ISO_URL
if ! curl --output /dev/null --silent --head --fail "$ISO_URL"; then
usage "******* ISO does not exist in the provided url: $ISO_URL"
fi
echo '******* Disconnecting existing image (just in case)'
/opt/dell/srvadmin/bin/idracadm7 -r $HOST -u $USER -p $PASSWORD remoteimage -d
echo '******* Showing idrac remoteimage status'
/opt/dell/srvadmin/bin/idracadm7 -r $HOST -u $USER -p $PASSWORD remoteimage -s
echo "******* Connecting remote iso $ISO_URL to boot from"
/opt/dell/srvadmin/bin/idracadm7 -r $HOST -u $USER -p $PASSWORD remoteimage -c -l $ISO_URL
echo '******* Showing idrac remoteimage status'
/opt/dell/srvadmin/bin/idracadm7 -r $HOST -u $USER -p $PASSWORD remoteimage -s
if ! /opt/dell/srvadmin/bin/idracadm7 -r $HOST -u $USER -p $PASSWORD remoteimage -s | grep $ISO_URL; then
usage 'ISO was not configured correctly'
fi
echo '******* Setting idrac to boot once from the attached iso'
/opt/dell/srvadmin/bin/idracadm7 -r $HOST -u admin -p et-o3xaeC7oe set iDRAC.VirtualMedia.BootOnce 1
/opt/dell/srvadmin/bin/idracadm7 -r $HOST -u admin -p et-o3xaeC7oe set iDRAC.ServerBoot.FirstBootDevice VCD-DVD
echo '******* Rebooting the server'
/opt/dell/srvadmin/bin/idracadm7 -r $HOST -u admin -p et-o3xaeC7oe serveraction powercycle
echo '******* Done'