diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-12-18 13:40:04 +0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2012-12-18 13:45:25 +0100 |
commit | 75c67b01946b53c711e775db766f53f334927d63 (patch) | |
tree | e288e50c4c0aebcb85026f691538e09d223d020e /modules/services/databases/mysql.nix | |
parent | 251f8546c938e18f6cfa7e073aad32b7f76a11cc (diff) | |
download | nixpkgs-75c67b01946b53c711e775db766f53f334927d63.tar nixpkgs-75c67b01946b53c711e775db766f53f334927d63.tar.gz nixpkgs-75c67b01946b53c711e775db766f53f334927d63.tar.bz2 nixpkgs-75c67b01946b53c711e775db766f53f334927d63.tar.lz nixpkgs-75c67b01946b53c711e775db766f53f334927d63.tar.xz nixpkgs-75c67b01946b53c711e775db766f53f334927d63.tar.zst nixpkgs-75c67b01946b53c711e775db766f53f334927d63.zip |
mysql: Port to systemd
Diffstat (limited to 'modules/services/databases/mysql.nix')
-rw-r--r-- | modules/services/databases/mysql.nix | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/modules/services/databases/mysql.nix b/modules/services/databases/mysql.nix index 2c35c13255e..ef29d563c72 100644 --- a/modules/services/databases/mysql.nix +++ b/modules/services/databases/mysql.nix @@ -91,6 +91,7 @@ in description = "A file containing SQL statements to be executed on the first startup. Can be used for granting certain permissions on the database"; }; + # FIXME: remove this option; it's a really bad idea. rootPassword = mkOption { default = null; description = "Path to a file containing the root password, modified on the first startup. Not specifying a root password will leave the root password empty."; @@ -140,10 +141,12 @@ in environment.systemPackages = [mysql]; - jobs.mysql = - { description = "MySQL server"; + boot.systemd.services.mysql = + { description = "MySQL Server"; - startOn = "filesystem"; + wantedBy = [ "multi-user.target" ]; + + unitConfig.RequiresMountsFor = "${cfg.dataDir}"; preStart = '' @@ -156,9 +159,12 @@ in mkdir -m 0700 -p ${cfg.pidDir} chown -R ${cfg.user} ${cfg.pidDir} - - ${mysql}/libexec/mysqld --defaults-extra-file=${myCnf} ${mysqldOptions} & + ''; + serviceConfig.ExecStart = "${mysql}/libexec/mysqld --defaults-extra-file=${myCnf} ${mysqldOptions}"; + + postStart = + '' # Wait until the MySQL server is available for use count=0 while [ ! -e /tmp/mysql.sock ] @@ -183,7 +189,7 @@ in echo "Creating initial database: ${database.name}" ( echo "create database ${database.name};" echo "use ${database.name};" - + if [ -f "${database.schema}" ] then cat ${database.schema} @@ -204,7 +210,7 @@ in ${optionalString (cfg.rootPassword != null) '' # Change root password - + ( echo "use mysql;" echo "update user set Password=password('$(cat ${cfg.rootPassword})') where User='root';" echo "flush privileges;" @@ -213,14 +219,10 @@ in rm /tmp/mysql_init fi - ''; - - postStop = "${mysql}/bin/mysqladmin ${optionalString (cfg.rootPassword != null) "--user=root --password=\"$(cat ${cfg.rootPassword})\""} shutdown"; - - # !!! Need a postStart script to wait until mysqld is ready to - # accept connections. + ''; # */ - extraConfig = "kill timeout 60"; + serviceConfig.ExecStop = + "${mysql}/bin/mysqladmin ${optionalString (cfg.rootPassword != null) "--user=root --password=\"$(cat ${cfg.rootPassword})\""} shutdown"; }; }; |