Merge remote-tracking branch 'lelutin/root_pw_no_arg' into shared
Conflicts: manifests/server/base.pp
This commit is contained in:
commit
e9ff8b6a23
3 changed files with 15 additions and 5 deletions
|
@ -1,12 +1,17 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
test $# -gt 0 || exit 1
|
test -f /root/.my.cnf || exit 1
|
||||||
|
|
||||||
|
rootpw=$(grep password /root/.my.cnf | sed -e 's/^[^=]*= *\(.*\) */\1/')
|
||||||
|
|
||||||
/sbin/service mysqld stop
|
/sbin/service mysqld stop
|
||||||
|
|
||||||
/usr/libexec/mysqld --skip-grant-tables --user=root --datadir=/var/lib/mysql/data --log-bin=/var/lib/mysql/mysql-bin &
|
/usr/libexec/mysqld --skip-grant-tables --user=root --datadir=/var/lib/mysql/data --log-bin=/var/lib/mysql/mysql-bin &
|
||||||
sleep 5
|
sleep 5
|
||||||
echo "USE mysql; UPDATE user SET Password=PASSWORD('$1') WHERE User='root' AND Host='localhost';" | mysql -u root
|
mysql -u root mysql <<EOF
|
||||||
|
UPDATE mysql.user SET Password=PASSWORD('$rootpw') WHERE User='root' AND Host='localhost';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
EOF
|
||||||
killall mysqld
|
killall mysqld
|
||||||
# chown to be on the safe side
|
# chown to be on the safe side
|
||||||
chown mysql.mysql /var/lib/mysql/mysql-bin.*
|
chown mysql.mysql /var/lib/mysql/mysql-bin.*
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
test $# -gt 0 || exit 1
|
test -f /root/.my.cnf || exit 1
|
||||||
|
|
||||||
|
rootpw=$(grep password /root/.my.cnf | sed -e 's/^[^=]*= *\(.*\) */\1/')
|
||||||
|
|
||||||
/etc/init.d/mysql stop
|
/etc/init.d/mysql stop
|
||||||
|
|
||||||
/usr/sbin/mysqld --skip-grant-tables --user=root --datadir=/var/lib/mysql --log-bin=/var/lib/mysql/mysql-bin &
|
/usr/sbin/mysqld --skip-grant-tables --user=root --datadir=/var/lib/mysql --log-bin=/var/lib/mysql/mysql-bin &
|
||||||
sleep 5
|
sleep 5
|
||||||
echo "USE mysql; UPDATE user SET Password=PASSWORD('$1') WHERE User='root' AND Host='localhost';" | mysql -u root
|
mysql -u root mysql <<EOF
|
||||||
|
UPDATE mysql.user SET Password=PASSWORD('$rootpw') WHERE User='root' AND Host='localhost';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
EOF
|
||||||
killall mysqld
|
killall mysqld
|
||||||
sleep 15
|
sleep 15
|
||||||
# chown to be on the safe side
|
# chown to be on the safe side
|
||||||
|
|
|
@ -55,7 +55,7 @@ class mysql::server::base {
|
||||||
}
|
}
|
||||||
|
|
||||||
exec { 'mysql_set_rootpw':
|
exec { 'mysql_set_rootpw':
|
||||||
command => "/usr/local/sbin/setmysqlpass.sh ${mysql_rootpw}",
|
command => "/usr/local/sbin/setmysqlpass.sh",
|
||||||
unless => "/usr/bin/mysqladmin -uroot status > /dev/null",
|
unless => "/usr/bin/mysqladmin -uroot status > /dev/null",
|
||||||
require => [ File['mysql_setmysqlpass.sh'], Package['mysql-server'] ],
|
require => [ File['mysql_setmysqlpass.sh'], Package['mysql-server'] ],
|
||||||
refreshonly => true,
|
refreshonly => true,
|
||||||
|
|
Loading…
Reference in a new issue