Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- source ./myvars.rc
- if [[ $(rpm -q mysql-server) == *"not installed"* ]]
- then
- echo "mysql-server not installed, aborting..."
- exit
- fi
- if [[ $(/etc/init.d/mysqld) != *running* ]]
- then
- echo "Starting mysql-server..."
- echo "$(/etc/init.d/mysqld start)"
- else
- exit
- fi
- echo "Running mysql_secure_installation..."
- sleep 2
- echo "$DBPASS"
- echo "$(export $DBPASS)"
- SECURE_MYSQL=$(expect -c "
- spawn mysql_secure_installation
- expect \"Enter current password for root (enter for none):\"
- send \"\r\"
- expect \"Set root password?\"
- send \"y\r\"
- expect \"New password: \"
- send \"$DBPASS\r\"
- expect \"Re-enter new password: \"
- send \"$DBPASS\r\"
- expect \"Remove anonymous users?\"
- send \"y\r\"
- expect \"Disallow root login remotely?\"
- send \"y\r\"
- expect \"Remove test database and access to it?\"
- send \"y\r\"
- expect \"Reload privilege tables now?\"
- send \"y\r\"
- expect eof
- ")
- echo "$SECURE_MYSQL"
- echo "Replacing password in /tmp/openstack/.my.cnf file..."
- echo "$DBPASS"
- # echo "$(sed -i "s/pass=/pass=$KEYSTONE_DBPASS/g" "/tmp/openstack/.my.cnf")"
- # echo "Copying to ~/.my.cnf..."
- # echo "$(/bin/cp -f /tmp/openstack/.my.cnf ~/.my.cnf)"
- exit 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement