From f1be508a09f3d8a05c0326bb9ecbe25cdb40d04e Mon Sep 17 00:00:00 2001 From: Attila Sztupak Date: Fri, 26 Sep 2014 15:33:17 +0100 Subject: [PATCH 1/3] crashplan: [new-package] an online/offline backup solution --- .../backup/crashplan/CrashPlanEngine.patch | 37 +++++++++ .../applications/backup/crashplan/default.nix | 77 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 3 files changed, 116 insertions(+) create mode 100644 pkgs/applications/backup/crashplan/CrashPlanEngine.patch create mode 100644 pkgs/applications/backup/crashplan/default.nix diff --git a/pkgs/applications/backup/crashplan/CrashPlanEngine.patch b/pkgs/applications/backup/crashplan/CrashPlanEngine.patch new file mode 100644 index 000000000000..de2afe2da684 --- /dev/null +++ b/pkgs/applications/backup/crashplan/CrashPlanEngine.patch @@ -0,0 +1,37 @@ +--- ./scripts/CrashPlanEngine 2014-02-19 23:17:19.000000000 +0000 ++++ ./scripts/CrashPlanEngine.1 2014-07-24 17:36:37.330333581 +0100 +@@ -11,7 +11,7 @@ + + cd $TARGETDIR + +- nice -n 19 $JAVACOMMON $SRV_JAVA_OPTS -classpath $FULL_CP com.backup42.service.CPService > $TARGETDIR/log/engine_output.log 2> $TARGETDIR/log/engine_error.log & ++ nice -n 19 $JAVACOMMON $SRV_JAVA_OPTS -classpath $FULL_CP com.backup42.service.CPService > $VARDIR/log/engine_output.log 2> $VARDIR/log/engine_error.log & + + if [[ $! -gt 0 ]]; then + echo $! > $PIDFILE +@@ -26,7 +26,7 @@ + + echo "Using Ubuntu 9.04 startup" + +- start-stop-daemon -v --pidfile $PIDFILE --make-pidfile --background --chdir $TARGETDIR --start --nicelevel 19 --exec $JAVACOMMON -- $SRV_JAVA_OPTS -classpath $FULL_CP com.backup42.service.CPService > $TARGETDIR/log/engine_output.log 2> $TARGETDIR/log/engine_error.log ++ start-stop-daemon -v --pidfile $PIDFILE --make-pidfile --background --chdir $TARGETDIR --start --nicelevel 19 --exec $JAVACOMMON -- $SRV_JAVA_OPTS -classpath $FULL_CP com.backup42.service.CPService > $VARDIR/log/engine_output.log 2> $VARDIR/log/engine_error.log + + # This test isn't as useful as one might like; start-stop-daemon can't accurately report the state of child processes when --background is used. + # We use this mainly to report the specific error value returned by start-stop-daemon if something goes wrong, but be aware that a return value +@@ -91,7 +91,6 @@ + DESC="CrashPlan Engine" + NAME=CrashPlanEngine + DAEMON=$TARGETDIR/lib/com.backup42.desktop.jar +-PIDFILE="$TARGETDIR/${NAME}.pid" + + if [[ -f $TARGETDIR/install.vars ]]; then + . $TARGETDIR/install.vars +@@ -100,6 +99,8 @@ + exit 1 + fi + ++PIDFILE="$VARDIR/${NAME}.pid" ++ + if [[ ! -f $DAEMON ]]; then + echo "Could not find JAR file $DAEMON" + exit 0 diff --git a/pkgs/applications/backup/crashplan/default.nix b/pkgs/applications/backup/crashplan/default.nix new file mode 100644 index 000000000000..7988042fe4f6 --- /dev/null +++ b/pkgs/applications/backup/crashplan/default.nix @@ -0,0 +1,77 @@ +{ stdenv, fetchurl, makeWrapper, jre, cpio, gawk, gnugrep, gnused, procps, swt, gtk2, glib, libXtst }: + +let version = "3.6.3"; + +in stdenv.mkDerivation rec { + name = "crashplan-${version}"; + + crashPlanArchive = fetchurl { + url = "http://download.crashplan.com/installs/linux/install/CrashPlan/CrashPlan_${version}_Linux.tgz"; + sha256 = "0v01fzc62bxr6lpamnxg1nb7vh4a8ky6mahbq76kmjxfqv7q0mb0"; + }; + + srcs = [ crashPlanArchive ]; + + meta = { + description = "An online/offline backup solution"; + homepage = "http://www.crashplan.org"; + license = stdenv.lib.licenses.unfree; + }; + + buildInputs = [ makeWrapper cpio ]; + + vardir = "/var/lib/crashplan"; + + manifestdir = "${vardir}/manifest"; + + patches = [ ./CrashPlanEngine.patch ]; + + installPhase = '' + mkdir $out + zcat -v CrashPlan_${version}.cpi | (cd $out; cpio -i -d -v --no-preserve-owner) + + # sed -i "s|manifest|${manifestdir}|g" $out/conf/default.service.xml + + # Fix for encoding troubles (CrashPlan ticket 178827) + # Make sure the daemon is running using the same localization as + # the (installing) user + echo "" >> run.conf + echo "export LC_ALL=en_US.UTF-8" >> run.conf + + install -d -m 755 unpacked $out + + install -D -m 644 EULA.txt $out/EULA.txt + install -D -m 644 run.conf $out/bin/run.conf + install -D -m 755 scripts/CrashPlanDesktop $out/bin/CrashPlanDesktop + install -D -m 755 scripts/CrashPlanEngine $out/bin/CrashPlanEngine + + rm -r $out/log + ln -s $vardir/log $out/log + ln -s $vardir/cache $out/cache + ln -s $vardir/backupArchives $out/backupArchives + ln -s $vardir/conf/service.model $out/conf/service.model + ln -s $vardir/conf/my.service.xml $out/conf/my.service.xml + + echo "JAVACOMMON=${jre}/bin/java" > $out/install.vars + echo "APP_BASENAME=CrashPlan" >> $out/install.vars + echo "TARGETDIR=$out" >> $out/install.vars + echo "BINSDIR=$out/bin" >> $out/install.vars + echo "MANIFESTDIR=${manifestdir}" >> $out/install.vars + echo "VARDIR=${vardir}" >> $out/install.vars + echo "INITDIR=" >> $out/install.vars + echo "RUNLVLDIR=" >> $out/install.vars + echo "INSTALLDATE=" >> $out/install.vars + ''; + + postFixup = '' + for f in $out/bin/CrashPlanDesktop $out/bin/CrashPlanEngine; do + echo "substitutions in $f" + substituteInPlace $f --replace /bin/ps ${procps}/bin/ps + substituteInPlace $f --replace awk ${gawk}/bin/awk + substituteInPlace $f --replace sed ${gnused}/bin/sed + substituteInPlace $f --replace grep ${gnugrep}/bin/grep + done + + wrapProgram $out/bin/CrashPlanDesktop --prefix LD_LIBRARY_PATH ":" "${gtk2}/lib:${glib}/lib:${libXtst}/lib" + ''; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 82b06349a8db..ea29c465d252 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11625,6 +11625,8 @@ let cups_pdf_filter = callPackage ../misc/cups/pdf-filter.nix { }; + crashplan = callPackage ../applications/backup/crashplan { }; + gutenprint = callPackage ../misc/drivers/gutenprint { }; gutenprintBin = callPackage ../misc/drivers/gutenprint/bin.nix { }; From 90a326eecd8988abe82b14168c894f5e3a72d407 Mon Sep 17 00:00:00 2001 From: Attila Sztupak Date: Fri, 26 Sep 2014 15:33:36 +0100 Subject: [PATCH 2/3] crashplan: nixos module for backup service --- nixos/modules/module-list.nix | 1 + nixos/modules/services/backup/crashplan.nix | 63 +++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 nixos/modules/services/backup/crashplan.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index deec9fd1bb77..470b78381988 100755 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -92,6 +92,7 @@ ./services/audio/mopidy.nix ./services/backup/almir.nix ./services/backup/bacula.nix + ./services/backup/crashplan.nix ./services/backup/mysql-backup.nix ./services/backup/postgresql-backup.nix ./services/backup/rsnapshot.nix diff --git a/nixos/modules/services/backup/crashplan.nix b/nixos/modules/services/backup/crashplan.nix new file mode 100644 index 000000000000..1862709b1365 --- /dev/null +++ b/nixos/modules/services/backup/crashplan.nix @@ -0,0 +1,63 @@ +{ config, pkgs, ... }: + +let + cfg = config.services.crashplan; + crashplan = pkgs.crashplan; + varDir = "/var/lib/crashplan"; +in + +with pkgs.lib; + +{ + 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" ]; + after = [ "network.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 ${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 + ''; + + 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; + }; + }; + }; +} \ No newline at end of file From de7da7c4fe08f891ae6207d48f5ac147a42a4859 Mon Sep 17 00:00:00 2001 From: Attila Sztupak Date: Sat, 27 Sep 2014 13:04:41 +0100 Subject: [PATCH 3/3] crashplan: added myself as maintainer --- lib/maintainers.nix | 1 + pkgs/applications/backup/crashplan/default.nix | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/maintainers.nix b/lib/maintainers.nix index da67717ce094..ca846282a702 100644 --- a/lib/maintainers.nix +++ b/lib/maintainers.nix @@ -120,6 +120,7 @@ skeidel = "Sven Keidel "; smironov = "Sergey Mironov "; sprock = "Roger Mason "; + sztupi = "Attila Sztupak "; tailhook = "Paul Colomiets "; thammers = "Tobias Hammerschmidt "; the-kenny = "Moritz Ulrich "; diff --git a/pkgs/applications/backup/crashplan/default.nix b/pkgs/applications/backup/crashplan/default.nix index 7988042fe4f6..8359c0dbc392 100644 --- a/pkgs/applications/backup/crashplan/default.nix +++ b/pkgs/applications/backup/crashplan/default.nix @@ -12,10 +12,11 @@ in stdenv.mkDerivation rec { srcs = [ crashPlanArchive ]; - meta = { + meta = with stdenv.lib; { description = "An online/offline backup solution"; homepage = "http://www.crashplan.org"; - license = stdenv.lib.licenses.unfree; + license = licenses.unfree; + maintainers = with maintainers; [ sztupi ]; }; buildInputs = [ makeWrapper cpio ];