Ultima attività 6 months ago

Revisione 35f7951a15445fb204853e3cdd47b79ffa4cc130

create_debian-sys-maint_for_mysqladmin.sh Raw
1#!/bin/sh
2MYSQLADMIN_CFG="/etc/mysql/mariadb.conf.d/90-mysqladmin.cnf"
3# generate password
4PASS=$(perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)');
5# adjust /etc/mysql/debian.cnf (used as defaults file by system scripts)
6sed -i "s/^password =.*$/password = ${PASS}/" /etc/mysql/debian.cnf
7sed -i "s/^user =.*$/user = debian-sys-maint/" /etc/mysql/debian.cnf
8# create config file for mysqladmin itself (maybe not needed)
9umask 066
10cat > ${MYSQLADMIN_CFG} <<EOF
11[mysqladmin]
12host = localhost
13user = debian-sys-maint
14password = ${PASS}
15socket = /var/run/mysqld/mysqld.sock
16EOF
17umask 022
18chown 0:0 ${MYSQLADMIN_CFG}; chmod 0600 ${MYSQLADMIN_CFG}
19# update credentials
20mysql -u root -p -e "GRANT ALL ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '${PASS}' WITH GRANT OPTION;"
21