Summary Files Commits Branches @commit @diff @stats
path: root / scripts
diff options
context:
space:
mode:
2 files changed, 58 insertions, 0 deletions
-rwxr-xr-xscripts/archive29
-rwxr-xr-xscripts/unarchive29
diff --git a/scripts/archive b/scripts/archive
new file mode 100755
index 0000000..ba50216
--- /dev/null
+++ b/scripts/archive
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+if [ -z "$1" ]
+then
+ printf 'Repository: '
+ read
+ set "$REPLY"
+fi
+
+set "$(echo -e "a\n$1\n.\n1s|\.\+/||g\n1s|/\+|/|g\n1p\nQ" | ed -s)"
+
+if [ ! -d "$1" ]
+then
+ echo 'Not a directory!'
+ exit 1
+fi
+
+__rec_ro() {
+ while read -r f
+ do
+ [ ! -w "$f" ] && continue
+ chwrite -w "$f"
+ [ -d "$f" ] && __rec_ro "$f"
+ done <<FILES
+$(ls -A1 "$1")
+FILES
+}
+
+__rec_ro "$1"
diff --git a/scripts/unarchive b/scripts/unarchive
new file mode 100755
index 0000000..08688da
--- /dev/null
+++ b/scripts/unarchive
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+if [ -z "$1" ]
+then
+ printf 'Repository: '
+ read
+ set "$REPLY"
+fi
+
+set "$(echo -e "a\n$1\n.\n1s|\.\+/||g\n1s|/\+|/|g\n1p\nQ" | ed -s)"
+
+if [ ! -d "$1" ]
+then
+ echo 'Not a directory!'
+ exit 1
+fi
+
+__rec_ro() {
+ while read -r f
+ do
+ [ ! -w "$f" ] && continue
+ chwrite +w "$f"
+ [ -d "$f" ] && __rec_ro "$f"
+ done <<FILES
+$(ls -A1 "$1")
+FILES
+}
+
+__rec_ro "$1"