X-Git-Url: https://git.cyclocoop.org/?p=lhc%2Fateliers.git;a=blobdiff_plain;f=vm_hosted;h=b1299938e768bb69cfe65a4d20453b3d419fb739;hp=df6f6dbd6564cea3df16c9e6fa6ac2d0c727ff0d;hb=4699cb3295e62b8035110ad473cd379d25dc8fdf;hpb=30fcfa9a18a93d1447059a759c5c62a4d6d55e06 diff --git a/vm_hosted b/vm_hosted index df6f6db..b129993 100755 --- a/vm_hosted +++ b/vm_hosted @@ -8,6 +8,7 @@ tool=${tool%/*} . "$tool"/lib/rule.sh . "$tool"/etc/vm.sh export TRACE=1 +cd / rule_help () { # SYNTAX: [--hidden] local hidden; [ ${1:+set} ] || hidden=set @@ -308,6 +309,7 @@ rule_boot_configure () { } rule_dovecot_configure () { rule apt_get_install dovecot-imapd dovecot-managesieved dovecot-sieve + rule insserv_remove dovecot local hint="run vm_remote dovecot_key_send before" assert "sudo test -f /etc/dovecot/\"$vm_domainname\"/imap/x509/key.pem" hint sudo install -m 400 -o root -g root \ @@ -385,7 +387,8 @@ rule_dovecot_configure () { EOF sudo install -m 664 -o root -g root /dev/stdin /etc/postgrey/whitelist_recipients.local <<-EOF EOF - sudo service dovecot restart + rule runit_sv_configure dovecot + rule runit_sv_restart dovecot } rule_etckeeper_configure () { sudo install -m 644 -o root -g root /dev/stdin /etc/etckeeper/etckeeper.conf <<-EOF @@ -482,6 +485,13 @@ rule_initramfs_configure () { # NOTE: clefs générées par Debian sudo update-initramfs -u } +rule_insserv_remove () { # SYNTAX: $sv + local sv="$1" + sudo chmod u+x /etc/init.d/"$sv" + sudo insserv --force --remove "$sv" + sudo /etc/init.d/"$sv" stop + sudo chmod ugo-x /etc/init.d/"$sv" + } rule_gitolite_configure () { sudo debconf-set-selections <<-EOF gitolite gitolite/gituser string git @@ -587,7 +597,7 @@ rule_gitolite_configure () { do test ! -d /home/git/etc/gitolite/"$d" || rmdir /home/git/etc/gitolite/"$d" done - sudo service tmpfs restart + rule tmpfs_configure } rule_locales_configure () { sudo debconf-set-selections <<-EOF @@ -705,6 +715,7 @@ rule_mail_configure () { } rule_mysql_configure () { rule apt_get_install mysql-server-5.5 + rule insserv_remove mysql rule adduser mysql \ --disabled-login \ --disabled-password \ @@ -743,41 +754,30 @@ rule_mysql_configure () { --datadir=/home/mysql/data \ --no-defaults fi - sudo service tmpfs restart - sudo insserv -r mysql - sudo chmod ugo-x /etc/init.d/mysql - case $(sudo sv status mysql || true) in - (''|run:*|*"s, normally up;"*) - rule runit_sv_restart mysql - while case $(sudo inotifywait -e create -- /run/mysqld/sock/) in - ("/run/mysqld/sock/ CREATE mysql") false;; - (*) true;; - esac - do true; done - ( - cd / - # NOTE: - # - ajoute l'accès par socket Unix à mysql - # - ajoute les droits de super-utilisateur à mysql - # - supprime l'accès par mot-de-passe à root - # - supprime les bases de données de l'utilisateurice anonyme - # - supprime l'utilisateurice anonyme - # NOTE: mémo : - # GRANT USAGE ON *.* TO 'root'@'*' IDENTIFIED WITH auth_socket; - # CREATE USER 'root'@'localhost' IDENTIFIED WITH auth_socket; - # UPDATE mysql.user SET Password='' WHERE user='root'; - # 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; - 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 = ''; - FLUSH PRIVILEGES; - EOF - ) - ;; - esac + rule tmpfs_configure + rule runit_sv_configure mysql + rule runit_sv_restart mysql + while ! sudo -u mysql mysql -u mysql