summaryrefslogtreecommitdiffstats
path: root/helper/fileutil.inc
diff options
context:
space:
mode:
authorSimon Rettberg2013-02-22 15:20:10 +0100
committerSimon Rettberg2013-02-22 15:20:10 +0100
commit73289c75b5858fa89e152957abdf641870f25aa8 (patch)
treebd8bb88a717622847a3932ec56b4ff7e456aa8a5 /helper/fileutil.inc
parent 1. New logging/output system - use functions provided by helper/logging.inc (diff)
downloadtm-scripts-73289c75b5858fa89e152957abdf641870f25aa8.tar.gz
tm-scripts-73289c75b5858fa89e152957abdf641870f25aa8.tar.xz
tm-scripts-73289c75b5858fa89e152957abdf641870f25aa8.zip
Added helper/fileutil.inc that provides tarcopy, an error-checking version of "tar cp xx | tar xp -C xx"
Added add_group function Changed add_user to update an existing user's password if called with a password Updated base.build to use new logging system
Diffstat (limited to 'helper/fileutil.inc')
-rw-r--r--helper/fileutil.inc17
1 files changed, 17 insertions, 0 deletions
diff --git a/helper/fileutil.inc b/helper/fileutil.inc
new file mode 100644
index 00000000..40bc42d5
--- /dev/null
+++ b/helper/fileutil.inc
@@ -0,0 +1,17 @@
+# copy list of files using tar
+tarcopy () {
+ [ $# -ne 2 ] && perror "Sanity check failed: tarcopy needs exactly two params, but $# were given."
+ if [ -z $1 ]; then
+ pwarning "tarcopy called with empty input list (dest was '$2')"
+ return
+ fi
+ local SHORT=$1
+ [ ${#SHORT} -gt 18 ] && SHORT=$(echo "$SHORT" | cut -c-13)...$(echo "$SHORT" | cut -c${#SHORT}-)
+ [ -z $2 ] && perror "tarcopy called with empty destination."
+ tar -cp "$1" | tar -xp -C "$2"
+ local PS1=$PIPESTATUS[0]
+ local PS2=$PIPESTATUS[1]
+ [ $PS1 -ne 0 ] && perror "packing-part of tar-copy from '$SHORT' to '$2' failed."
+ [ $PS2 -ne 0 ] && perror "unpacking-part of tar-copy from '$SHORT' to '$2' failed."
+}
+