about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorJoachim F <joachifm@users.noreply.github.com>2018-02-20 19:19:22 +0000
committerGitHub <noreply@github.com>2018-02-20 19:19:22 +0000
commitb30fae01cddee73473a7b2eca9254b4c755741bd (patch)
tree7685c98f05309f56b557e8ce52d4f3de12ce9cfd /nixos
parentaf37d08381a5b26e6daddbd2682bcb9a4ddeb2b8 (diff)
parentf24b642587db32d0e857e398e54831550bfb6556 (diff)
Merge pull request #32761 from xvapx/crashplan-small-business
crashplan-small-business: init at 6.6.0
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/backup/crashplan-small-business.nix89
2 files changed, 90 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 795f6fda30539..fabe686ff4b43 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -157,6 +157,7 @@
   ./services/backup/almir.nix
   ./services/backup/bacula.nix
   ./services/backup/crashplan.nix
+  ./services/backup/crashplan-small-business.nix
   ./services/backup/mysql-backup.nix
   ./services/backup/postgresql-backup.nix
   ./services/backup/rsnapshot.nix
diff --git a/nixos/modules/services/backup/crashplan-small-business.nix b/nixos/modules/services/backup/crashplan-small-business.nix
new file mode 100644
index 0000000000000..c6002b6a3f6b4
--- /dev/null
+++ b/nixos/modules/services/backup/crashplan-small-business.nix
@@ -0,0 +1,89 @@
+{ config, pkgs, lib, ... }:
+
+let
+  cfg = config.services.crashplansb;
+  crashplansb = pkgs.crashplansb.override { maxRam = cfg.maxRam; };
+  varDir = "/var/lib/crashplan";
+in
+
+with lib;
+
+{
+  options = {
+    services.crashplansb = {
+      enable = mkOption {
+        default = false;
+        type = types.bool;
+        description = ''
+          Starts crashplan for small business background service.
+        '';
+      };
+      maxRam = mkOption {
+        default = "1024m";
+        example = "2G";
+        type = types.str;
+        description = ''
+          Maximum amount of that the crashplan engine should use.
+        '';
+      };
+      openPorts = mkOption {
+        description = "Open ports in the firewall for crashplan.";
+        default = true;
+        type = types.bool;
+      };
+      ports =  mkOption {
+        # https://support.code42.com/Administrator/6/Planning_and_installing/TCP_and_UDP_ports_used_by_the_Code42_platform
+        # used ports can also be checked in the desktop app console using the command connection.info
+        description = "which ports to open.";
+        default = [ 4242 4243 4244 4247 ];
+        type = types.listOf types.int;
+      };
+    };
+  };
+
+  config = mkIf cfg.enable {
+    environment.systemPackages = [ crashplansb ];
+    networking.firewall.allowedTCPPorts = mkIf cfg.openPorts cfg.ports;
+
+    systemd.services.crashplansb = {
+      description = "CrashPlan Backup Engine";
+
+      wantedBy = [ "multi-user.target" ];
+      after    = [ "network.target" "local-fs.target" ];
+
+      preStart = ''
+        ensureDir() {
+          dir=$1
+          mode=$2
+
+          if ! test -e $dir; then
+            ${pkgs.coreutils}/bin/mkdir -m $mode -p $dir
+          elif [ "$(${pkgs.coreutils}/bin/stat -c %a $dir)" != "$mode" ]; then
+            ${pkgs.coreutils}/bin/chmod $mode $dir
+          fi
+        }
+
+        ensureDir ${crashplansb.vardir} 755
+        ensureDir ${crashplansb.vardir}/conf 700
+        ensureDir ${crashplansb.manifestdir} 700
+        ensureDir ${crashplansb.vardir}/cache 700
+        ensureDir ${crashplansb.vardir}/backupArchives 700
+        ensureDir ${crashplansb.vardir}/log 777
+        cp -avn ${crashplansb}/conf.template/* ${crashplansb.vardir}/conf
+        #for x in bin install.vars lang lib libc42archive64.so libc42core.so libjniwrap64.so libjtux64.so libleveldb64.so libnetty-tcnative.so share upgrade; do
+        #  rm -f ${crashplansb.vardir}/$x;
+        #  ln -sf ${crashplansb}/$x ${crashplansb.vardir}/$x;
+        #done
+      '';
+
+      serviceConfig = {
+        Type = "forking";
+        EnvironmentFile = "${crashplansb}/bin/run.conf";
+        ExecStart = "${crashplansb}/bin/CrashPlanEngine start";
+        ExecStop = "${crashplansb}/bin/CrashPlanEngine stop";
+        PIDFile = "${crashplansb.vardir}/CrashPlanEngine.pid";
+        WorkingDirectory = crashplansb;
+      };
+    };
+  };
+}