3
0
Fork 0
forked from mirrors/nixpkgs

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:
Alexei Robyn 2016-05-12 15:10:17 +10:00
parent b874447eef
commit 11b0972544

View file

@ -10,13 +10,12 @@ let
in
{
###### interface
options = {
services.teamspeak3 = {
enable = mkOption {
type = types.bool;
default = false;
@ -96,34 +95,32 @@ in
###### implementation
config = mkIf cfg.enable {
users.extraUsers.teamspeak =
{ name = "teamspeak";
config = mkMerge [
(mkIf cfg.enable {
users.users.teamspeak = {
description = "Teamspeak3 voice communication server daemon";
group = group;
uid = config.ids.uids.teamspeak;
home = cfg.dataDir;
createHome = true;
};
users.extraGroups.teamspeak =
{ name = "teamspeak";
users.groups.teamspeak = {
gid = config.ids.gids.teamspeak;
};
systemd.services.teamspeak3-server = {
description = "Teamspeak3 voice communication server daemon";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
systemd.services.teamspeak3-server = {
description = "Teamspeak3 voice communication server daemon";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
preStart = ''
mkdir -p ${cfg.dataDir}
mkdir -p ${cfg.logPath}
chown ${user}:${group} ${cfg.dataDir}
chown ${user}:${group} ${cfg.logPath}
'';
preStart = ''
mkdir -p ${cfg.logPath}
chown ${user}:${group} ${cfg.logPath}
'';
serviceConfig =
{ ExecStart = ''
serviceConfig = {
ExecStart = ''
${ts3}/bin/ts3server \
dbsqlpath=${ts3}/lib/teamspeak/sql/ logpath=${cfg.logPath} \
voice_ip=${cfg.voiceIP} default_voice_port=${toString cfg.defaultVoicePort} \
@ -133,10 +130,12 @@ in
WorkingDirectory = cfg.dataDir;
User = user;
Group = group;
PermissionsStartOnly = true; # preStart needs to run with root permissions
PermissionsStartOnly = true;
};
};
};
})
{
meta.maintainers = with lib.maintainers; [ arobyn ];
}
];
}