Merge pull request #32761 from xvapx/crashplan-small-business

crashplan-small-business: init at 6.6.0

authored by

Joachim F and committed by
GitHub
b30fae01 af37d083

+193
+1
nixos/modules/module-list.nix
··· 157 157 ./services/backup/almir.nix 158 158 ./services/backup/bacula.nix 159 159 ./services/backup/crashplan.nix 160 + ./services/backup/crashplan-small-business.nix 160 161 ./services/backup/mysql-backup.nix 161 162 ./services/backup/postgresql-backup.nix 162 163 ./services/backup/rsnapshot.nix
+89
nixos/modules/services/backup/crashplan-small-business.nix
··· 1 + { config, pkgs, lib, ... }: 2 + 3 + let 4 + cfg = config.services.crashplansb; 5 + crashplansb = pkgs.crashplansb.override { maxRam = cfg.maxRam; }; 6 + varDir = "/var/lib/crashplan"; 7 + in 8 + 9 + with lib; 10 + 11 + { 12 + options = { 13 + services.crashplansb = { 14 + enable = mkOption { 15 + default = false; 16 + type = types.bool; 17 + description = '' 18 + Starts crashplan for small business background service. 19 + ''; 20 + }; 21 + maxRam = mkOption { 22 + default = "1024m"; 23 + example = "2G"; 24 + type = types.str; 25 + description = '' 26 + Maximum amount of that the crashplan engine should use. 27 + ''; 28 + }; 29 + openPorts = mkOption { 30 + description = "Open ports in the firewall for crashplan."; 31 + default = true; 32 + type = types.bool; 33 + }; 34 + ports = mkOption { 35 + # https://support.code42.com/Administrator/6/Planning_and_installing/TCP_and_UDP_ports_used_by_the_Code42_platform 36 + # used ports can also be checked in the desktop app console using the command connection.info 37 + description = "which ports to open."; 38 + default = [ 4242 4243 4244 4247 ]; 39 + type = types.listOf types.int; 40 + }; 41 + }; 42 + }; 43 + 44 + config = mkIf cfg.enable { 45 + environment.systemPackages = [ crashplansb ]; 46 + networking.firewall.allowedTCPPorts = mkIf cfg.openPorts cfg.ports; 47 + 48 + systemd.services.crashplansb = { 49 + description = "CrashPlan Backup Engine"; 50 + 51 + wantedBy = [ "multi-user.target" ]; 52 + after = [ "network.target" "local-fs.target" ]; 53 + 54 + preStart = '' 55 + ensureDir() { 56 + dir=$1 57 + mode=$2 58 + 59 + if ! test -e $dir; then 60 + ${pkgs.coreutils}/bin/mkdir -m $mode -p $dir 61 + elif [ "$(${pkgs.coreutils}/bin/stat -c %a $dir)" != "$mode" ]; then 62 + ${pkgs.coreutils}/bin/chmod $mode $dir 63 + fi 64 + } 65 + 66 + ensureDir ${crashplansb.vardir} 755 67 + ensureDir ${crashplansb.vardir}/conf 700 68 + ensureDir ${crashplansb.manifestdir} 700 69 + ensureDir ${crashplansb.vardir}/cache 700 70 + ensureDir ${crashplansb.vardir}/backupArchives 700 71 + ensureDir ${crashplansb.vardir}/log 777 72 + cp -avn ${crashplansb}/conf.template/* ${crashplansb.vardir}/conf 73 + #for x in bin install.vars lang lib libc42archive64.so libc42core.so libjniwrap64.so libjtux64.so libleveldb64.so libnetty-tcnative.so share upgrade; do 74 + # rm -f ${crashplansb.vardir}/$x; 75 + # ln -sf ${crashplansb}/$x ${crashplansb.vardir}/$x; 76 + #done 77 + ''; 78 + 79 + serviceConfig = { 80 + Type = "forking"; 81 + EnvironmentFile = "${crashplansb}/bin/run.conf"; 82 + ExecStart = "${crashplansb}/bin/CrashPlanEngine start"; 83 + ExecStop = "${crashplansb}/bin/CrashPlanEngine stop"; 84 + PIDFile = "${crashplansb.vardir}/CrashPlanEngine.pid"; 85 + WorkingDirectory = crashplansb; 86 + }; 87 + }; 88 + }; 89 + }
+102
pkgs/applications/backup/crashplan/crashplan-small-business.nix
··· 1 + { stdenv, fetchurl, makeWrapper, getopt, jre, cpio, gawk, gnugrep, gnused, 2 + procps, which, gtk2, atk, glib, pango, gdk_pixbuf, cairo, freetype, 3 + fontconfig, dbus, gconf, nss, nspr, alsaLib, cups, expat, libudev, 4 + libX11, libxcb, libXi, libXcursor, libXdamage, libXrandr, libXcomposite, 5 + libXext, libXfixes, libXrender, libXtst, libXScrnSaver, nodePackages, 6 + maxRam ? "1024m" }: 7 + 8 + stdenv.mkDerivation rec { 9 + version = "6.6.0"; 10 + rev = "1506661200660_4347"; 11 + pname = "CrashPlanSmb"; 12 + name = "${pname}_${version}_${rev}"; 13 + 14 + src = fetchurl { 15 + url = "https://web-eam-msp.crashplanpro.com/client/installers/${name}_Linux.tgz"; 16 + sha256 = "1zzx60fpmi2nlzpq80x4hfgspsrgd7ycfcvc6w391wxr0qzf2i9k"; 17 + }; 18 + 19 + nativeBuildInputs = [ makeWrapper cpio nodePackages.asar ]; 20 + buildInputs = [ getopt which ]; 21 + 22 + vardir = "/var/lib/crashplan"; 23 + manifestdir = "${vardir}/manifest"; 24 + 25 + postPatch = '' 26 + # patch scripts/CrashPlanEngine 27 + substituteInPlace scripts/CrashPlanEngine \ 28 + --replace /bin/ps ${procps}/bin/ps \ 29 + --replace awk ${gawk}/bin/awk \ 30 + --replace '`sed' '`${gnused}/bin/sed' \ 31 + --replace grep ${gnugrep}/bin/grep \ 32 + --replace TARGETDIR/log VARDIR/log \ 33 + --replace TARGETDIR/\''${NAME} VARDIR/\''${NAME} \ 34 + --replace \$TARGETDIR/bin/run.conf $out/bin/run.conf \ 35 + --replace \$VARDIR ${vardir} 36 + 37 + # patch scripts/CrashPlanDesktop 38 + substituteInPlace scripts/CrashPlanDesktop \ 39 + --replace awk ${gawk}/bin/awk \ 40 + --replace "\"\$SCRIPTDIR/..\"" "$out" \ 41 + --replace "\$(dirname \$SCRIPT)" "$out" \ 42 + --replace "\''${TARGETDIR}/log" ${vardir}/log \ 43 + --replace "\''${TARGETDIR}" "$out" 44 + ''; 45 + 46 + installPhase = '' 47 + mkdir $out 48 + zcat -v ${pname}_${version}.cpi | (cd $out; cpio -i -d -v --no-preserve-owner) 49 + 50 + install -D -m 755 scripts/CrashPlanDesktop $out/bin/CrashPlanDesktop 51 + install -D -m 755 scripts/CrashPlanEngine $out/bin/CrashPlanEngine 52 + install -D -m 644 scripts/run.conf $out/bin/run.conf 53 + install -D -m 644 scripts/CrashPlan.desktop $out/share/applications/CrashPlan.desktop 54 + 55 + # unpack, patch and repack app.asar to stop electron from creating /usr/local/crashplan/log to store the ui logs. 56 + asar e $out/app.asar $out/app.asar-unpacked 57 + rm -v $out/app.asar 58 + substituteInPlace $out/app.asar-unpacked/shared_modules/shell/platform_paths.js \ 59 + --replace "getLogFileParentPath();" "\"$vardir/log\";" 60 + asar p $out/app.asar-unpacked $out/app.asar 61 + 62 + mv -v $out/*.asar $out/electron/resources 63 + chmod 755 "$out/electron/crashplan" 64 + 65 + rm -r $out/log 66 + mv -v $out/conf $out/conf.template 67 + ln -s $vardir/log $out/log 68 + ln -s $vardir/cache $out/cache 69 + ln -s $vardir/conf $out/conf 70 + 71 + substituteInPlace $out/bin/run.conf \ 72 + --replace "-Xmx1024m" "-Xmx${maxRam}" 73 + 74 + echo "JAVACOMMON=${jre}/bin/java" > $out/install.vars 75 + echo "APP_BASENAME=CrashPlan" >> $out/install.vars 76 + echo "TARGETDIR=$out" >> $out/install.vars 77 + echo "BINSDIR=$out/bin" >> $out/install.vars 78 + echo "MANIFESTDIR=${manifestdir}" >> $out/install.vars 79 + echo "VARDIR=${vardir}" >> $out/install.vars 80 + echo "INITDIR=" >> $out/install.vars 81 + echo "RUNLVLDIR=" >> $out/install.vars 82 + echo "INSTALLDATE=" >> $out/install.vars 83 + 84 + ''; 85 + 86 + postFixup = '' 87 + patchelf --set-interpreter ${stdenv.glibc}/lib/ld-linux-x86-64.so.2 $out/electron/crashplan 88 + wrapProgram $out/bin/CrashPlanDesktop --prefix LD_LIBRARY_PATH ":" "${stdenv.lib.makeLibraryPath [ 89 + stdenv.cc.cc.lib gtk2 atk glib pango gdk_pixbuf cairo freetype 90 + fontconfig dbus gconf nss nspr alsaLib cups expat libudev 91 + libX11 libxcb libXi libXcursor libXdamage libXrandr libXcomposite 92 + libXext libXfixes libXrender libXtst libXScrnSaver]}" 93 + ''; 94 + 95 + meta = with stdenv.lib; { 96 + description = "An online backup solution"; 97 + homepage = http://www.crashplan.com/business/; 98 + license = licenses.unfree; 99 + maintainers = with maintainers; [ xvapx ]; 100 + }; 101 + 102 + }
+1
pkgs/top-level/all-packages.nix
··· 19884 19884 cups-toshiba-estudio = callPackage ../misc/cups/drivers/estudio {}; 19885 19885 19886 19886 crashplan = callPackage ../applications/backup/crashplan { }; 19887 + crashplansb = callPackage ../applications/backup/crashplan/crashplan-small-business.nix { inherit (gnome3) gconf; }; 19887 19888 19888 19889 colort = callPackage ../applications/misc/colort { }; 19889 19890