supybot.service: tidy up
This commit is contained in:
parent
6e093113fe
commit
5b25c5a181
@ -136,6 +136,7 @@ in
|
|||||||
scanner = 59;
|
scanner = 59;
|
||||||
nginx = 60;
|
nginx = 60;
|
||||||
systemd-journal = 62;
|
systemd-journal = 62;
|
||||||
|
supybot = 63;
|
||||||
|
|
||||||
# When adding a gid, make sure it doesn't match an existing uid.
|
# When adding a gid, make sure it doesn't match an existing uid.
|
||||||
|
|
||||||
|
@ -10,8 +10,6 @@ in
|
|||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
###### interface
|
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
services.supybot = {
|
services.supybot = {
|
||||||
@ -22,44 +20,33 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
stateDir = mkOption {
|
stateDir = mkOption {
|
||||||
default = "/var/lib/supybot";
|
# Setting this to /var/lib/supybot caused useradd to fail
|
||||||
description = "
|
default = "/home/supybot";
|
||||||
|
description = "The root directory, logs and plugins are stored here";
|
||||||
";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
configFile = mkOption {
|
configFile = mkOption {
|
||||||
type = types.path;
|
type = types.path;
|
||||||
default = /dev/null;
|
|
||||||
description = ''
|
description = ''
|
||||||
Verbatim contents of the supybot config, this can be
|
Path to a supybot config file. This can be generated by
|
||||||
generated by supybot-wizard
|
running supybot-wizard.
|
||||||
|
|
||||||
|
Note: all paths should include the full path to the stateDir
|
||||||
|
directory (backup conf data logs logs/plugins plugins tmp web).
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
user = mkOption {
|
|
||||||
default = "supybot";
|
|
||||||
description = "User account under which supybot runs.";
|
|
||||||
};
|
|
||||||
|
|
||||||
group = mkOption {
|
|
||||||
default = "supybot";
|
|
||||||
description = "Group account under which supybot runs.";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
###### implementation
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
environment.systemPackages = [ pkgs.pythonPackages.limnoria ];
|
environment.systemPackages = [ pkgs.pythonPackages.limnoria ];
|
||||||
|
|
||||||
users.extraUsers = singleton
|
users.extraUsers = singleton {
|
||||||
{ name = cfg.user;
|
name = "supybot";
|
||||||
uid = config.ids.uids.supybot;
|
uid = config.ids.uids.supybot;
|
||||||
group = "supybot";
|
group = "supybot";
|
||||||
description = "Supybot IRC bot user";
|
description = "Supybot IRC bot user";
|
||||||
@ -67,27 +54,29 @@ in
|
|||||||
createHome = true;
|
createHome = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
users.extraGroups.supybot = {};
|
users.extraGroups.supybot = {
|
||||||
|
name = "supybot";
|
||||||
|
gid = config.ids.gids.supybot;
|
||||||
|
};
|
||||||
|
|
||||||
systemd.services.supybot =
|
systemd.services.supybot = {
|
||||||
{ description = "Supybot IRC bot";
|
description = "Supybot, an IRC bot";
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
path = [ pkgs.pythonPackages.limnoria ];
|
path = [ pkgs.pythonPackages.limnoria ];
|
||||||
preStart = ''
|
preStart = ''
|
||||||
mkdir -m 0755 -p ${cfg.stateDir}
|
|
||||||
chown ${cfg.user}:${cfg.group} ${cfg.stateDir}
|
|
||||||
cd ${cfg.stateDir}
|
cd ${cfg.stateDir}
|
||||||
mkdir -p logs/plugins backup conf data plugins tmp
|
mkdir -p backup conf data plugins logs/plugins tmp web
|
||||||
ln -sf ${cfg.configFile} supybot.cfg
|
ln -sf ${cfg.configFile} supybot.cfg
|
||||||
|
# This needs to be created afresh every time
|
||||||
rm -f supybot.cfg.bak
|
rm -f supybot.cfg.bak
|
||||||
'';
|
'';
|
||||||
serviceConfig =
|
|
||||||
{ ExecStart =
|
serviceConfig = {
|
||||||
"${pkgs.pythonPackages.limnoria}/bin/supybot ${cfg.stateDir}/supybot.cfg";
|
ExecStart = "${pkgs.pythonPackages.limnoria}/bin/supybot ${cfg.stateDir}/supybot.cfg";
|
||||||
PIDFile = "/run/supybot.pid";
|
PIDFile = "/run/supybot.pid";
|
||||||
User = "${cfg.user}";
|
User = "supybot";
|
||||||
Group = "${cfg.group}";
|
Group = "supybot";
|
||||||
UMask = "0007";
|
UMask = "0007";
|
||||||
Restart = "on-abort";
|
Restart = "on-abort";
|
||||||
StartLimitInterval = "5m";
|
StartLimitInterval = "5m";
|
||||||
@ -96,5 +85,4 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user