Updates to the scripts. Adding setting of the password.
This commit is contained in:
@@ -22,5 +22,6 @@ minix.postinst.8g.img:minix.base.8g.img
|
||||
cp minix.base.8g.img minix.postinst.8g.tmp.img
|
||||
post-install/01-reconfigure-net.expect
|
||||
post-install/02-setup.expect
|
||||
post-install/03-keesj.expect
|
||||
mv minix.postinst.8g.tmp.img minix.postinst.8g.img
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ for {} 1 {} {
|
||||
}
|
||||
"dirty, performing fsck" {puts "resetting timeout as the file system in dirty" }
|
||||
#Starting networking: dhcpd nonamed.
|
||||
"nonamed." {
|
||||
"nonamed" {
|
||||
#send a break signal
|
||||
sleep 1
|
||||
send "\003"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/expect -f
|
||||
#
|
||||
spawn qemu-system-i386 -m 512 -hda minix.postinst.8g..tmp.img -curses
|
||||
spawn qemu-system-i386 -m 512 -hda minix.postinst.8g.tmp.img -curses
|
||||
|
||||
set timeout 5
|
||||
|
||||
@@ -116,6 +116,7 @@ expect {
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
set timeout 20
|
||||
#shutdown
|
||||
send "shutdown\n"
|
||||
expect "Choose an option; RETURN for default; SPACE to stop countdown."
|
||||
|
||||
106
projects/autoinstall/post-install/03-keesj.expect
Executable file
106
projects/autoinstall/post-install/03-keesj.expect
Executable file
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/expect -f
|
||||
#
|
||||
spawn qemu-system-i386 -m 512 -hda minix.postinst.8g.tmp.img -curses
|
||||
|
||||
set timeout 5
|
||||
|
||||
puts "Performing post install keesj"
|
||||
#
|
||||
#--- Welcome to MINIX 3. This is the boot monitor. ---
|
||||
expect "\\-\\-\\- Welcome to MINIX 3. This is the boot monitor. \\-\\-\\-"
|
||||
|
||||
#
|
||||
#Check we have a normal boot loader
|
||||
#1. Start MINIX 3
|
||||
expect "1. Start MINIX 3"
|
||||
|
||||
expect "Choose an option; RETURN for default; SPACE to stop countdown." {
|
||||
send "\n"
|
||||
}
|
||||
|
||||
|
||||
# when this script is stated the previous one probably has installed openssh
|
||||
# and ssh keys will be generated
|
||||
set timeout 120
|
||||
|
||||
#
|
||||
for {} 1 {} {
|
||||
puts "Waiting for a prompt"
|
||||
expect {
|
||||
#minix login:
|
||||
#but later if it worked ip-address login:
|
||||
"login:" {
|
||||
send "root\n"
|
||||
break
|
||||
}
|
||||
"dirty, performing fsck" {puts "resetting timeout as the file system in dirty" }
|
||||
timeout {
|
||||
puts "Failed to catch login command"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
set timeout 5
|
||||
expect "#"
|
||||
|
||||
|
||||
#
|
||||
# put a run command in /tmp that echoes RESULT-OK or RESULT-FAIL based on the
|
||||
# return value of the command launched
|
||||
#
|
||||
set send_human {.1 .3 1 .05 2}
|
||||
expect -re $
|
||||
# the shell can't handle all this output at once so sending it as "human"
|
||||
send -h "echo '#/bin/sh' > /tmp/runcmd.sh ; echo 'if $* ; then echo RESULT-OK ; else echo RESULT-FAIL ; fi' >> /tmp/runcmd.sh ; chmod +x /tmp/runcmd.sh\n"
|
||||
expect "#"
|
||||
|
||||
|
||||
#
|
||||
# Try and read password from a file called ~/bin/.minix.passwd
|
||||
# if that is not present inform the user we are using a default
|
||||
# password. (This becomes nasty when we have ssh installed)
|
||||
#
|
||||
set passwd "dev"
|
||||
if { [file exists "~/bin/.minix.passwd" ] == 1} {
|
||||
puts "**Reading password from file **"
|
||||
set fd [open "~/bin/.minix.passwd" "r"]
|
||||
set passwd [read $fd]
|
||||
close $fd
|
||||
} else {
|
||||
puts "**WARNING using default password **"
|
||||
}
|
||||
|
||||
|
||||
#read the full buffer so the next line does not match RESULT-FAIL
|
||||
set timeout 60
|
||||
expect -re $
|
||||
# passwd
|
||||
#Changing local password for root.
|
||||
#New password:
|
||||
send -h "/tmp/runcmd.sh passwd\n"
|
||||
for {} 1 {} {
|
||||
puts "Passwd loop"
|
||||
expect {
|
||||
"New password:" {
|
||||
send -h "$passwd\n"
|
||||
}
|
||||
"Retype new password:" {
|
||||
send -h "$passwd\n"
|
||||
}
|
||||
"RESULT-OK" {
|
||||
puts "Updated password"
|
||||
break;
|
||||
}
|
||||
timeout {
|
||||
puts "Failed to set password"
|
||||
interact
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
expect -re $
|
||||
set timeout 20
|
||||
#shutdown
|
||||
send "shutdown\n"
|
||||
expect "Choose an option; RETURN for default; SPACE to stop countdown."
|
||||
Reference in New Issue
Block a user