2015-07-31 04:22:44 +00:00
|
|
|
{ config, lib, pkgs, ...}:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.gateone;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.gateone = {
|
2022-08-28 19:18:44 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "GateOne server");
|
2015-07-31 04:22:44 +00:00
|
|
|
pidDir = mkOption {
|
|
|
|
default = "/run/gateone";
|
|
|
|
type = types.path;
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "Path of pid files for GateOne.";
|
2015-07-31 04:22:44 +00:00
|
|
|
};
|
|
|
|
settingsDir = mkOption {
|
|
|
|
default = "/var/lib/gateone";
|
|
|
|
type = types.path;
|
2022-07-28 21:19:15 +00:00
|
|
|
description = lib.mdDoc "Path of configuration files for GateOne.";
|
2015-07-31 04:22:44 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = with pkgs.pythonPackages; [
|
2015-12-17 18:17:49 +00:00
|
|
|
gateone pkgs.openssh pkgs.procps pkgs.coreutils pkgs.cacert];
|
2015-07-31 04:22:44 +00:00
|
|
|
|
2018-06-29 23:58:35 +00:00
|
|
|
users.users.gateone = {
|
2015-07-31 04:22:44 +00:00
|
|
|
description = "GateOne privilege separation user";
|
|
|
|
uid = config.ids.uids.gateone;
|
|
|
|
home = cfg.settingsDir;
|
|
|
|
};
|
2018-06-29 23:58:35 +00:00
|
|
|
users.groups.gateone.gid = config.ids.gids.gateone;
|
2015-07-31 04:22:44 +00:00
|
|
|
|
|
|
|
systemd.services.gateone = with pkgs; {
|
|
|
|
description = "GateOne web-based terminal";
|
|
|
|
path = [ pythonPackages.gateone nix openssh procps coreutils ];
|
|
|
|
preStart = ''
|
|
|
|
if [ ! -d ${cfg.settingsDir} ] ; then
|
|
|
|
mkdir -m 0750 -p ${cfg.settingsDir}
|
2022-05-05 20:09:00 +00:00
|
|
|
chown -R gateone:gateone ${cfg.settingsDir}
|
2015-08-07 04:43:29 +00:00
|
|
|
fi
|
|
|
|
if [ ! -d ${cfg.pidDir} ] ; then
|
|
|
|
mkdir -m 0750 -p ${cfg.pidDir}
|
2022-05-05 20:09:00 +00:00
|
|
|
chown -R gateone:gateone ${cfg.pidDir}
|
2015-07-31 04:22:44 +00:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
#unitConfig.RequiresMountsFor = "${cfg.settingsDir}";
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = ''${pythonPackages.gateone}/bin/gateone --settings_dir=${cfg.settingsDir} --pid_file=${cfg.pidDir}/gateone.pid --gid=${toString config.ids.gids.gateone} --uid=${toString config.ids.uids.gateone}'';
|
|
|
|
User = "gateone";
|
|
|
|
Group = "gateone";
|
|
|
|
WorkingDirectory = cfg.settingsDir;
|
|
|
|
};
|
|
|
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
requires = [ "network.target" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
2020-08-07 13:43:58 +00:00
|
|
|
|