Browse Source

expect script to change password for Drac interface

David Yurkiewicz 6 years ago
parent
commit
9e11f00e9e
1 changed files with 81 additions and 0 deletions
  1. 81 0
      linux/DracPass.exp

+ 81 - 0
linux/DracPass.exp

@@ -0,0 +1,81 @@
1
+#!/usr/bin/expect
2
+################################
3
+# Set Password for DRAC interface
4
+# by David Yurkiewicz
5
+# WWW.D87STUDIOS.COM
6
+# USAGE: expect DracPass.exp 192.168.0.10
7
+# Enter password when prompted. Script will assume the Drac's password is the default out the box ("calvin")
8
+
9
+# Settings for expect
10
+set timeout 8
11
+set ip [lindex $argv 0]
12
+set option [lindex $argv 2] 
13
+
14
+# Make sure we get the parameters
15
+if {[llength $argv] == 0} {
16
+	puts "\n Enter the IP of the DRAC interface e.g. 192.168.5.5. \n You will be prompted for a password\n"
17
+	exit 1
18
+}
19
+
20
+# Prompt for password
21
+	stty -echo
22
+	send_user -- "Password for Drac device on $argv: "
23
+	expect_user -re "(.*)\n"
24
+	send_user "\n"
25
+	stty echo
26
+	set password $expect_out(1,string)
27
+
28
+# SSH to the DRAC interface
29
+spawn ssh "root\@$ip"
30
+
31
+expect (yes/no)? { send "yes\r"}
32
+
33
+expect assword: { send "calvin\r" }
34
+puts "\n\n Looks like this device was already set. Please try to log in https//$ip\n"
35
+expect assword: { exit 1 }       
36
+
37
+expect ctn1->
38
+	
39
+send "racadm\r"
40
+
41
+expect adm>>
42
+
43
+send "racadm config -g cfgUserAdmin -o cfgUserAdminUserName -i 2 bookit\r"
44
+
45
+expect adm>>
46
+
47
+send "racadm config -g cfgUserAdmin -o cfgUserAdminPassword -i 2 $password\r"
48
+
49
+expect adm>>
50
+
51
+send "racadm config -g cfgUserAdmin -i 2 -o cfgUserAdminPrivilege 0x000001ff\r"
52
+
53
+expect adm>>
54
+
55
+send "racadm config -g cfgUserAdmin -i 2 -o cfgUserAdminIpmiLanPrivilege 4\r"
56
+
57
+expect adm>>
58
+
59
+send "racadm config -g cfgUserAdmin -i 2 -o cfgUserAdminIpmiSerialPrivilege 4\r"
60
+
61
+expect adm>>
62
+
63
+send "racadm config -g cfgUserAdmin -i 2 -o cfgUserAdminSolEnable 1\r"
64
+
65
+expect adm>>
66
+
67
+send "racadm config -g cfgUserAdmin -i 2 -o cfgUserAdminEnable 1\r"
68
+
69
+expect adm>>
70
+
71
+send "quit\r"
72
+
73
+expect n1->
74
+
75
+send "exit\r"
76
+
77
+expect closed
78
+puts "\n##############################################\n"
79
+puts "\nDone! Make sure that you can log in now. \n\nhttps://$ip\n"
80
+
81
+exit 0