X-Git-Url: https://git.cyclocoop.org/?p=lhc%2Fateliers.git;a=blobdiff_plain;f=vm_hosted;h=54e7257050fa5c1aa982e54a1afde1daac211576;hp=3259ef132315706d286b4d4f187ffad5bf510621;hb=2e5bb0ff5df2b7a5d527a4f896b802df31d3c6bc;hpb=1b63122dd097c575896b4c4158ed5439eeca1563 diff --git a/vm_hosted b/vm_hosted index 3259ef1..54e7257 100755 --- a/vm_hosted +++ b/vm_hosted @@ -622,7 +622,21 @@ rule_mysql_configure () { # DELETE FROM mysql.user WHERE user = 'root' AND host NOT IN ('localhost', '127.0.0.1', '::1'); sudo mysql -u root --batch --verbose <<-EOF DELETE FROM mysql.user WHERE user = 'root' and plugin = ''; - GRANT ALL PRIVILEGES ON *.* TO 'mysql'@'localhost' IDENTIFIED WITH auth_socket; + DROP PROCEDURE IF EXISTS mysql.create_user_mysql; + DELIMITER // + CREATE PROCEDURE mysql.create_user_mysql () + BEGIN + IF NOT (EXISTS (SELECT User + FROM mysql.user + WHERE User='mysql' + AND Host='localhost' + LIMIT 1)) + THEN GRANT ALL PRIVILEGES ON *.* TO 'mysql'@'localhost' IDENTIFIED WITH auth_socket; + END IF; + END; + // + CALL mysql.create_user_mysql(); + DROP PROCEDURE mysql.create_user_mysql; UPDATE mysql.user SET grant_priv='Y',super_priv='Y' WHERE user='mysql'; DELETE FROM mysql.db WHERE user = ''; DELETE FROM mysql.user WHERE user = ''; @@ -995,189 +1009,6 @@ rule_postfix_configure () { sudo postmap hash:/etc/postfix/$vm_domainname/virtual_alias rule runit_configure postfix } -rule_postgresql_configure () { - # DOC: http://wiki.postgresql.org/wiki/Shared_Database_Hosting - rule apt_get_install postgresql-9.1 - rule insserv_remove postgresql - rule adduser postgres \ - --disabled-login \ - --disabled-password \ - --group \ - --home /home/postgresql \ - --shell /bin/false \ - --system - rule adduser postgres-data \ - --disabled-login \ - --disabled-password \ - --group \ - --home /home/postgresql/data \ - --no-create-home \ - --shell /bin/false \ - --system - sudo usermod --home /home/postgresql postgres - sudo adduser postgres postgres-data - sudo rm -rf \ - /etc/postgresql - sudo install -d -m 1751 -o postgres -g postgres-data \ - /home/postgresql \ - /home/postgresql/etc \ - /etc/postgresql \ - /etc/postgresql/9.1 \ - /etc/postgresql/9.1/main - sudo ln -fns \ - /etc/postgresql \ - /home/postgresql/etc/postgresql - sudo install -d -m 2770 -o postgres -g log-postgres \ - /home/postgresql/log \ - /home/postgresql/log/9.1 \ - /home/postgresql/log/9.1/main - if sudo test ! -d /home/postgresql/data - then - sudo install -d -m 750 -o postgres -g postgres \ - /home/postgresql/data - sudo -u postgres pg_createcluster \ - --datadir=/home/postgresql/data \ - --logfile=/home/postgresql/log/9.1/main/cluster.log \ - --socketdir=/run/postgresql \ - 9.1 main - fi - - sudo install -m 640 -o postgres -g postgres /dev/stdin \ - /etc/postgresql/9.1/main/pg_ctl.conf <<-EOF - pg_ctl_options = '' - EOF - sudo install -m 640 -o postgres -g postgres /dev/stdin \ - /etc/postgresql/9.1/main/pg_ident.conf <<-EOF - # MAPNAME SYSTEM-USERNAME PG-USERNAME - EOF - sudo install -m 640 -o postgres -g postgres /dev/stdin \ - /etc/postgresql/9.1/main/start.conf <<-EOF - EOF - sudo install -m 640 -o postgres -g postgres /dev/stdin \ - /etc/postgresql/9.1/main/pg_hba.conf <<-EOF - local all postgres peer - local all all peer - EOF - sudo install -m 640 -o postgres -g postgres-data \ - "$tool"/etc/postgresql/9.1/main/postgresql.conf \ - /etc/postgresql/9.1/main/postgresql.conf - rule runit_configure postgres - while ! sudo -u postgres psql