summaryrefslogtreecommitdiffstats
path: root/helper/functions.common.sh
diff options
context:
space:
mode:
authorJonathan Bauer2013-02-19 14:54:39 +0100
committerJonathan Bauer2013-02-19 14:54:39 +0100
commitd1bf7e56ff20d1d02fe9878eb651bbfd20a4de3e (patch)
tree837c7e84e362669389ed5330be39933381a9745a /helper/functions.common.sh
parentfixes (diff)
downloadtm-scripts-d1bf7e56ff20d1d02fe9878eb651bbfd20a4de3e.tar.gz
tm-scripts-d1bf7e56ff20d1d02fe9878eb651bbfd20a4de3e.tar.xz
tm-scripts-d1bf7e56ff20d1d02fe9878eb651bbfd20a4de3e.zip
functions common
Diffstat (limited to 'helper/functions.common.sh')
-rw-r--r--helper/functions.common.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/helper/functions.common.sh b/helper/functions.common.sh
new file mode 100644
index 00000000..de33363c
--- /dev/null
+++ b/helper/functions.common.sh
@@ -0,0 +1,44 @@
+
+QUIET=0
+
+LOG_DIR=${ROOT_DIR}/logs
+
+mkdir -p $LOG_DIR
+
+set_quiet () {
+ if [ "x$DEBUG" != "x1" -a "x$QUIET" != "x1" ]; then
+ exec 6>&1 > $LOG_DIR/stdout.log
+ exec 2> $LOG_DIR/stderr.log
+ QUIET="1"
+ fi
+}
+
+unset_quiet () {
+ if [ "x$QUIET" = "x1" ]; then
+ exec 1>&6 6>&-
+ exec 2>&-
+ QUIET="0"
+ fi
+}
+
+
+pinfo () {
+ unset_quiet
+ echo -e "[info] $1"
+ set_quiet
+}
+perror () {
+ unset_quiet
+ echo -e "[error] $1"
+ set_quiet
+}
+pecho () {
+ unset_quiet
+ echo -e "[user] $1"
+ set_quiet
+}
+pechon () {
+ unset_quiet
+ echo -e -n "[user] $1"
+ set_quiet
+}