2008-06-25 21:58:51 +00:00
|
|
|
{pkgs, config}:
|
2008-01-28 14:34:29 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2008-06-25 21:58:51 +00:00
|
|
|
cfg = config.services.mysql;
|
|
|
|
|
|
|
|
mysql = pkgs.mysql;
|
|
|
|
|
|
|
|
pidFile = "${cfg.pidDir}/mysqld.pid";
|
|
|
|
|
|
|
|
mysqldOptions =
|
|
|
|
"--user=${cfg.user} --datadir=${cfg.dataDir} " +
|
|
|
|
"--log-error=${cfg.logError} --pid-file=${pidFile}";
|
2008-01-28 14:34:29 +00:00
|
|
|
|
|
|
|
in
|
2008-06-25 21:58:51 +00:00
|
|
|
|
2008-01-28 14:34:29 +00:00
|
|
|
{
|
2008-06-25 21:58:51 +00:00
|
|
|
name = "mysql";
|
|
|
|
|
|
|
|
users = [
|
|
|
|
{ name = "mysql";
|
|
|
|
description = "MySQL server user";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
extraPath = [mysql];
|
|
|
|
|
|
|
|
job = ''
|
|
|
|
description "MySQL server"
|
|
|
|
|
|
|
|
stop on shutdown
|
|
|
|
|
|
|
|
start script
|
|
|
|
if ! test -e ${cfg.dataDir}; then
|
|
|
|
mkdir -m 0700 -p ${cfg.dataDir}
|
|
|
|
chown -R ${cfg.user} ${cfg.dataDir}
|
|
|
|
${mysql}/bin/mysql_install_db ${mysqldOptions}
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -m 0700 -p ${cfg.pidDir}
|
|
|
|
chown -R ${cfg.user} ${cfg.pidDir}
|
|
|
|
end script
|
2008-01-28 14:34:29 +00:00
|
|
|
|
2008-06-25 21:58:51 +00:00
|
|
|
respawn ${mysql}/bin/mysqld ${mysqldOptions}
|
2008-01-28 14:34:29 +00:00
|
|
|
|
2008-06-25 21:58:51 +00:00
|
|
|
stop script
|
|
|
|
pid=$(cat ${pidFile})
|
|
|
|
kill "$pid"
|
|
|
|
${mysql}/bin/mysql_waitpid "$pid" 1000
|
|
|
|
end script
|
|
|
|
'';
|
2008-01-28 14:34:29 +00:00
|
|
|
}
|