2015-11-10 04:15:34 -05:00
|
|
|
#!/usr/bin/expect -f
|
|
|
|
|
|
|
|
set timeout 10
|
|
|
|
spawn mysql_secure_installation
|
2015-12-08 02:23:58 -08:00
|
|
|
expect {
|
|
|
|
timeout { send_user "\nFailed to get 'Enter current password for root (enter for none):' prompt\n"; exit 1 }
|
|
|
|
eof { send_user "\nFailed to get 'Enter current password for root (enter for none):' prompt\n"; exit 1 }
|
|
|
|
"Enter current password for root (enter for none):"
|
|
|
|
}
|
2015-11-10 04:15:34 -05:00
|
|
|
send "\r"
|
2015-12-08 02:23:58 -08:00
|
|
|
expect {
|
|
|
|
timeout { send_user "\nFailed to get 'Set root password?' prompt\n"; exit 1 }
|
|
|
|
eof { send_user "\nFailed to get 'Set root password?' prompt\n"; exit 1 }
|
|
|
|
"Set root password?"
|
|
|
|
}
|
2015-11-10 04:15:34 -05:00
|
|
|
send "y\r"
|
2015-12-08 02:23:58 -08:00
|
|
|
expect {
|
|
|
|
timeout { send_user "\nFailed to get 'New password:' prompt\n"; exit 1 }
|
|
|
|
eof { send_user "\nFailed to get 'New password:' prompt\n"; exit 1 }
|
|
|
|
"New password:"
|
|
|
|
}
|
2015-11-10 04:15:34 -05:00
|
|
|
send "$env(DB_ROOT_PASSWORD)\r"
|
2015-12-08 02:23:58 -08:00
|
|
|
|
|
|
|
expect {
|
|
|
|
timeout { send_user "\nFailed to get 'Re-enter new password:' prompt\n"; exit 1 }
|
|
|
|
eof { send_user "\nFailed to get 'Re-enter new password:' prompt\n"; exit 1 }
|
|
|
|
"Re-enter new password:"
|
|
|
|
}
|
2015-11-10 04:15:34 -05:00
|
|
|
send "$env(DB_ROOT_PASSWORD)\r"
|
2015-12-08 02:23:58 -08:00
|
|
|
|
|
|
|
expect {
|
|
|
|
timeout { send_user "\nFailed to get 'Remove anonymous users?' prompt\n"; exit 1 }
|
|
|
|
eof { send_user "\nFailed to get 'Remove anonymous users?' prompt\n"; exit 1 }
|
|
|
|
"Remove anonymous users?"
|
|
|
|
}
|
2015-11-10 04:15:34 -05:00
|
|
|
send "y\r"
|
2015-12-08 02:23:58 -08:00
|
|
|
|
|
|
|
expect {
|
|
|
|
timeout { send_user "\nFailed to get 'Disallow root login remotely?' prompt\n"; exit 1 }
|
|
|
|
eof { send_user "\nFailed to get 'Disallow root login remotely?' prompt\n"; exit 1 }
|
|
|
|
"Disallow root login remotely?"
|
|
|
|
}
|
2015-11-10 04:15:34 -05:00
|
|
|
send "n\r"
|
2015-12-08 02:23:58 -08:00
|
|
|
|
|
|
|
expect {
|
|
|
|
timeout { send_user "\nFailed to get 'Remove test database and access to it?' prompt\n"; exit 1 }
|
|
|
|
eof { send_user "\nFailed to get 'Remove test database and access to it?' prompt\n"; exit 1 }
|
|
|
|
"Remove test database and access to it?"
|
|
|
|
}
|
2015-11-10 04:15:34 -05:00
|
|
|
send "y\r"
|
2015-12-08 02:23:58 -08:00
|
|
|
|
|
|
|
expect {
|
|
|
|
timeout { send_user "\nFailed to get 'Reload privilege tables now?' prompt\n"; exit 1 }
|
|
|
|
eof { send_user "\nFailed to get 'Reload privilege tables now?' prompt\n"; exit 1 }
|
|
|
|
"Reload privilege tables now?"
|
|
|
|
}
|
2015-11-10 04:15:34 -05:00
|
|
|
send "y\r"
|
|
|
|
expect eof
|