Merge pull request #210 from cillianderoiste/master

Add Supybot (IRC bot) service
This commit is contained in:
cillianderoiste 2013-08-04 13:14:21 -07:00
commit ab4472e70e
3 changed files with 91 additions and 0 deletions

View File

@ -78,6 +78,7 @@ in
chrony = 61;
smtpd = 63;
smtpq = 64;
supybot = 65;
# When adding a uid, make sure it doesn't match an existing gid.
@ -139,6 +140,7 @@ in
systemd-journal = 62;
smtpd = 63;
smtpq = 64;
supybot = 65;
# When adding a gid, make sure it doesn't match an existing uid.

View File

@ -170,6 +170,7 @@
./services/networking/rdnssd.nix
./services/networking/rpcbind.nix
./services/networking/sabnzbd.nix
./services/networking/supybot.nix
./services/networking/ssh/lshd.nix
./services/networking/ssh/sshd.nix
./services/networking/tftpd.nix

View File

@ -0,0 +1,88 @@
{ config, pkgs, ... }:
with pkgs.lib;
let
cfg = config.services.supybot;
in
{
options = {
services.supybot = {
enable = mkOption {
default = false;
description = "Enable Supybot, an IRC bot";
};
stateDir = mkOption {
# Setting this to /var/lib/supybot caused useradd to fail
default = "/home/supybot";
description = "The root directory, logs and plugins are stored here";
};
configFile = mkOption {
type = types.path;
description = ''
Path to a supybot config file. This can be generated by
running supybot-wizard.
Note: all paths should include the full path to the stateDir
directory (backup conf data logs logs/plugins plugins tmp web).
'';
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.pythonPackages.limnoria ];
users.extraUsers = singleton {
name = "supybot";
uid = config.ids.uids.supybot;
group = "supybot";
description = "Supybot IRC bot user";
home = cfg.stateDir;
createHome = true;
};
users.extraGroups.supybot = {
name = "supybot";
gid = config.ids.gids.supybot;
};
systemd.services.supybot = {
description = "Supybot, an IRC bot";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
path = [ pkgs.pythonPackages.limnoria ];
preStart = ''
cd ${cfg.stateDir}
mkdir -p backup conf data plugins logs/plugins tmp web
ln -sf ${cfg.configFile} supybot.cfg
# This needs to be created afresh every time
rm -f supybot.cfg.bak
'';
serviceConfig = {
ExecStart = "${pkgs.pythonPackages.limnoria}/bin/supybot ${cfg.stateDir}/supybot.cfg";
PIDFile = "/run/supybot.pid";
User = "supybot";
Group = "supybot";
UMask = "0007";
Restart = "on-abort";
StartLimitInterval = "5m";
StartLimitBurst = "1";
};
};
};
}