2014-11-17 17:30:37 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
2014-09-26 14:33:36 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.crashplan;
|
|
|
|
crashplan = pkgs.crashplan;
|
|
|
|
varDir = "/var/lib/crashplan";
|
|
|
|
in
|
|
|
|
|
2014-11-17 17:30:37 +00:00
|
|
|
with lib;
|
2014-09-26 14:33:36 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.crashplan = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
type = types.bool;
|
|
|
|
description = ''
|
|
|
|
Starts crashplan background service.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ crashplan ];
|
|
|
|
|
|
|
|
systemd.services.crashplan = {
|
|
|
|
description = "CrashPlan Backup Engine";
|
|
|
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2016-08-14 09:56:21 +00:00
|
|
|
after = [ "network.target" "local-fs.target" ];
|
2014-09-26 14:33:36 +00:00
|
|
|
|
|
|
|
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 ${crashplan.vardir} 755
|
|
|
|
ensureDir ${crashplan.vardir}/conf 700
|
|
|
|
ensureDir ${crashplan.manifestdir} 700
|
|
|
|
ensureDir ${crashplan.vardir}/cache 700
|
|
|
|
ensureDir ${crashplan.vardir}/backupArchives 700
|
|
|
|
ensureDir ${crashplan.vardir}/log 777
|
2016-03-19 00:53:37 +00:00
|
|
|
cp -avn ${crashplan}/conf.template/* ${crashplan.vardir}/conf
|
2016-11-13 19:04:43 +00:00
|
|
|
for x in app.asar bin install.vars lang lib libc42archive64.so libc52archive.so libjniwrap64.so libjniwrap.so libjtux64.so libjtux.so libleveldb64.so libleveldb.so libmd564.so libmd5.so share skin upgrade; do
|
2016-04-25 16:04:57 +00:00
|
|
|
rm -f ${crashplan.vardir}/$x;
|
|
|
|
ln -sf ${crashplan}/$x ${crashplan.vardir}/$x;
|
2016-03-19 00:53:37 +00:00
|
|
|
done
|
2014-09-26 14:33:36 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "forking";
|
|
|
|
EnvironmentFile = "${crashplan}/bin/run.conf";
|
|
|
|
ExecStart = "${crashplan}/bin/CrashPlanEngine start";
|
|
|
|
ExecStop = "${crashplan}/bin/CrashPlanEngine stop";
|
|
|
|
PIDFile = "${crashplan.vardir}/CrashPlanEngine.pid";
|
|
|
|
WorkingDirectory = crashplan;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2014-11-17 17:30:37 +00:00
|
|
|
}
|