teamspeak-server module: Create data directory by
leveraging users.users.<user>.createHome instead of a preStart script. preStart script is still required to ensure proper creation of logging directory.
This commit is contained in:
parent
b874447eef
commit
11b0972544
@ -16,7 +16,6 @@ in
|
|||||||
options = {
|
options = {
|
||||||
|
|
||||||
services.teamspeak3 = {
|
services.teamspeak3 = {
|
||||||
|
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
@ -96,17 +95,17 @@ in
|
|||||||
|
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkMerge [
|
||||||
|
(mkIf cfg.enable {
|
||||||
users.extraUsers.teamspeak =
|
users.users.teamspeak = {
|
||||||
{ name = "teamspeak";
|
|
||||||
description = "Teamspeak3 voice communication server daemon";
|
description = "Teamspeak3 voice communication server daemon";
|
||||||
group = group;
|
group = group;
|
||||||
uid = config.ids.uids.teamspeak;
|
uid = config.ids.uids.teamspeak;
|
||||||
|
home = cfg.dataDir;
|
||||||
|
createHome = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
users.extraGroups.teamspeak =
|
users.groups.teamspeak = {
|
||||||
{ name = "teamspeak";
|
|
||||||
gid = config.ids.gids.teamspeak;
|
gid = config.ids.gids.teamspeak;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -116,14 +115,12 @@ in
|
|||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
preStart = ''
|
preStart = ''
|
||||||
mkdir -p ${cfg.dataDir}
|
|
||||||
mkdir -p ${cfg.logPath}
|
mkdir -p ${cfg.logPath}
|
||||||
chown ${user}:${group} ${cfg.dataDir}
|
|
||||||
chown ${user}:${group} ${cfg.logPath}
|
chown ${user}:${group} ${cfg.logPath}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
serviceConfig =
|
serviceConfig = {
|
||||||
{ ExecStart = ''
|
ExecStart = ''
|
||||||
${ts3}/bin/ts3server \
|
${ts3}/bin/ts3server \
|
||||||
dbsqlpath=${ts3}/lib/teamspeak/sql/ logpath=${cfg.logPath} \
|
dbsqlpath=${ts3}/lib/teamspeak/sql/ logpath=${cfg.logPath} \
|
||||||
voice_ip=${cfg.voiceIP} default_voice_port=${toString cfg.defaultVoicePort} \
|
voice_ip=${cfg.voiceIP} default_voice_port=${toString cfg.defaultVoicePort} \
|
||||||
@ -133,10 +130,12 @@ in
|
|||||||
WorkingDirectory = cfg.dataDir;
|
WorkingDirectory = cfg.dataDir;
|
||||||
User = user;
|
User = user;
|
||||||
Group = group;
|
Group = group;
|
||||||
PermissionsStartOnly = true; # preStart needs to run with root permissions
|
PermissionsStartOnly = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
})
|
||||||
};
|
{
|
||||||
|
meta.maintainers = with lib.maintainers; [ arobyn ];
|
||||||
|
}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user