summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsavelocaltweaks31
1 files changed, 31 insertions, 0 deletions
diff --git a/savelocaltweaks b/savelocaltweaks
index 3ce2bd0..aff588a 100755
--- a/savelocaltweaks
+++ b/savelocaltweaks
@@ -2,12 +2,38 @@
set -e
+PRG=$(basename "$0")
+
+TEMP="`getopt -s sh -o t:f -l target:,force -n "$PRG" -- "$@"`"
+if [ $? != 0 ] ; then echo >&2 "ERROR: Internal getopt error." ; exit 1 ; fi
+eval set -- "$TEMP"
+
+realtargetdir=''
+force='no'
+while true ; do
+ case "$1" in
+ -t|--target) realtargetdir="$2" ; shift 2 ;;
+ -f|--force) force="yes" ; shift ;;
+ --) shift ; break ;;
+ *) echo >&2 "ERROR: Internal error resolving options." ; exit 1 ;;
+ esac
+done
+
basedir="/etc"
targetdir="$(mktemp -td localtweaks.XXXXXX)"
includefile="/etc/local/localtweaks.include"
excludefile="/etc/local/localtweaks.exclude"
extensions=".orig .old"
+if [ -n "$realtargetdir" ] && [ -e "$realtargetdir" ]; then
+ if [ "$force" = "yes" ]; then
+ rm -rf "$realtargetdir"
+ else
+ echo >&2 "Error: Target directory exists already."
+ exit 1
+ fi
+fi
+
for ext in $extensions; do
extfiles="$(find $basedir -name "*$ext")"
for extfile in $extfiles; do
@@ -63,3 +89,8 @@ for file in $files; do
chmod a-x "$targetdir/$basedir/$file.diff"
fi
done
+
+if [ -n "$realtargetdir" ]; then
+ mv "$targetdir" "$realtargetdir"
+ rm -rf "$targetdir"
+fi