mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2025-01-07 22:11:45 +03:00
nixos/mysql: move ExecStartPost into postStart
This commit is contained in:
parent
e3c210dfd1
commit
f08049e712
@ -375,19 +375,10 @@ in
|
|||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
serviceConfig = {
|
postStart = let
|
||||||
Type = if hasNotify then "notify" else "simple";
|
|
||||||
Restart = "on-abort";
|
|
||||||
RestartSec = "5s";
|
|
||||||
# The last two environment variables are used for starting Galera clusters
|
|
||||||
ExecStart = "${cfg.package}/bin/mysqld --defaults-file=/etc/my.cnf ${mysqldOptions} $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION";
|
|
||||||
ExecStartPost =
|
|
||||||
let
|
|
||||||
# The super user account to use on *first* run of MySQL server
|
# The super user account to use on *first* run of MySQL server
|
||||||
superUser = if isMariaDB then cfg.user else "root";
|
superUser = if isMariaDB then cfg.user else "root";
|
||||||
setupScript = pkgs.writeScript "mysql-setup" ''
|
in ''
|
||||||
#!${pkgs.runtimeShell} -e
|
|
||||||
|
|
||||||
${optionalString (!hasNotify) ''
|
${optionalString (!hasNotify) ''
|
||||||
# Wait until the MySQL server is available for use
|
# Wait until the MySQL server is available for use
|
||||||
count=0
|
count=0
|
||||||
@ -407,7 +398,7 @@ in
|
|||||||
|
|
||||||
if [ -f ${cfg.dataDir}/mysql_init ]
|
if [ -f ${cfg.dataDir}/mysql_init ]
|
||||||
then
|
then
|
||||||
# While MariaDB comes with a 'mysql' super user account since 10.4.x MySQL does not
|
# While MariaDB comes with a 'mysql' super user account since 10.4.x, MySQL does not
|
||||||
# Since we don't want to run this service as 'root' we need to ensure the account exists on first run
|
# Since we don't want to run this service as 'root' we need to ensure the account exists on first run
|
||||||
( echo "CREATE USER IF NOT EXISTS '${cfg.user}'@'localhost' IDENTIFIED WITH ${if isMariaDB then "unix_socket" else "auth_socket"};"
|
( echo "CREATE USER IF NOT EXISTS '${cfg.user}'@'localhost' IDENTIFIED WITH ${if isMariaDB then "unix_socket" else "auth_socket"};"
|
||||||
echo "GRANT ALL PRIVILEGES ON *.* TO '${cfg.user}'@'localhost' WITH GRANT OPTION;"
|
echo "GRANT ALL PRIVILEGES ON *.* TO '${cfg.user}'@'localhost' WITH GRANT OPTION;"
|
||||||
@ -485,8 +476,13 @@ in
|
|||||||
) | ${cfg.package}/bin/mysql -N
|
) | ${cfg.package}/bin/mysql -N
|
||||||
'') cfg.ensureUsers}
|
'') cfg.ensureUsers}
|
||||||
'';
|
'';
|
||||||
in
|
|
||||||
"${setupScript}";
|
serviceConfig = {
|
||||||
|
Type = if hasNotify then "notify" else "simple";
|
||||||
|
Restart = "on-abort";
|
||||||
|
RestartSec = "5s";
|
||||||
|
# The last two environment variables are used for starting Galera clusters
|
||||||
|
ExecStart = "${cfg.package}/bin/mysqld --defaults-file=/etc/my.cnf ${mysqldOptions} $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION";
|
||||||
# User and group
|
# User and group
|
||||||
User = cfg.user;
|
User = cfg.user;
|
||||||
Group = cfg.group;
|
Group = cfg.group;
|
||||||
|
Loading…
Reference in New Issue
Block a user