commit a3fde4d1e9ce272f714efc64712d9ffdd1826118
parent dfb36c26467e6922d8362256ae34a46869090f3e
Author: rsiddharth <s@ricketyspace.net>
Date: Tue, 18 Apr 2017 23:16:44 +0000
Add .bin/annex-gnus-mail
Experimental.
Diffstat:
1 file changed, 53 insertions(+), 0 deletions(-)
diff --git a/.bin/annex-gnus-mail b/.bin/annex-gnus-mail
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+# Copyright (C) 2017 rsiddharth <s@ricketyspace.net>
+#
+# This program is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program (see COPYING). If not, see
+# <http://www.gnu.org/licenses/>.
+
+# this script is meant to be run by a cron job in the annex directory.
+
+# git-annex binary
+GIT_ANNEX=$HOME'/.bin/git-annex'
+
+if [ ! -f $GIT_ANNEX ]; then
+ echo $GIT_ANNEX
+ echo 'ERROR: git-annex not found.'
+ exit 1
+fi
+
+# paths
+GNUS_MAIL_PATHS=$HOME'/Mail '$HOME'/News'
+TARBALL='mail/gnus.tar'
+COMPRESSED_TARBALL='mail/gnus.tar.xz'
+
+if [ -f $COMPRESSED_TARBALL ]; then
+ # unlock compressed tar ball
+ $GIT_ANNEX unlock $COMPRESSED_TARBALL &&
+ # uncompress tar ball
+ unxz $COMPRESSED_TARBALL &&
+ # update tar ball
+ tar uvf $TARBALL $GNUS_MAIL_PATHS &&
+ # compress updated tar ball
+ xz $TARBALL &&
+ # annex the updated compressed tar ball
+ $GIT_ANNEX add $COMPRESSED_TARBALL &&
+ git commit -m 'Update mail/gnus.tar.xz'
+else
+ # mail/gnus.tar.gz does not exists, create it.
+ tar cvJf $COMPRESSED_TARBALL $GNUS_MAIL_PATHS &&
+ # annex the compressed tar ball.
+ $GIT_ANNEX add $COMPRESSED_TARBALL &&
+ git commit -m 'Add mail/gnus.tar.xz'
+fi