From e15ffa9e3c5a1059b8840338ffc33dda46f28c4e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 4 Sep 2008 20:28:02 +0000 Subject: Add `gnunetd' Upstart job. svn path=/nixos/trunk/; revision=12802 --- upstart-jobs/gnunet.nix | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 upstart-jobs/gnunet.nix (limited to 'upstart-jobs/gnunet.nix') diff --git a/upstart-jobs/gnunet.nix b/upstart-jobs/gnunet.nix new file mode 100644 index 00000000000..3b3de2d97b3 --- /dev/null +++ b/upstart-jobs/gnunet.nix @@ -0,0 +1,64 @@ +{ gnunet, gnunetConfig, lib, writeText }: + +assert gnunetConfig.enable; + +{ + name = "gnunetd"; + + users = [ + { name = "gnunetd"; + uid = (import ../system/ids.nix).uids.gnunetd; + description = "GNUnet Daemon User"; + home = "/var/empty"; + } + ]; + + job = + with gnunetConfig; + let configFile = writeText "gnunetd.conf" '' + [PATHS] + GNUNETD_HOME = ${home} + + [GNUNETD] + HOSTLISTURL = ${lib.concatStringsSep " " hostLists} + APPLICATIONS = ${lib.concatStringsSep " " applications} + TRANSPORTS = ${lib.concatStringsSep " " transports} + + [LOAD] + MAXNETDOWNBPSTOTAL = ${toString load.maxNetDownBandwidth} + MAXNETUPBPSTOTAL = ${toString load.maxNetUpBandwidth} + HARDUPLIMIT = ${toString load.hardNetUpBandwidth} + MAXCPULOAD = ${toString load.maxCPULoad} + INTERFACES = ${lib.concatStringsSep " " load.interfaces} + + [FS] + QUOTA = ${toString fileSharing.quota} + ACTIVEMIGRATION = ${if fileSharing.activeMigration then "YES" else "NO"} + + [MODULES] + sqstore = sqstore_sqlite + dstore = dstore_sqlite + topology = topology_default + + ${extraOptions} + ''; + + in '' +description "The GNUnet Daemon" + +start on network-interfaces/started +stop on network-interfaces/stop + +start script + test -d "${home}" || \ + ( mkdir -m 755 -p "${home}" && chown -R gnunetd:users "${home}") +end script + +respawn ${gnunet}/bin/gnunetd \ + ${if debug then "--debug" else "" } \ + --user="gnunetd" \ + --config="${configFile}" \ + --log="${logLevel}" +''; + +} -- cgit 1.4.1