diff options
author | 2017-02-14 15:12:08 +0000 | |
---|---|---|
committer | 2017-02-14 15:12:10 +0000 | |
commit | a84b847a3409df445482674feffa2872a8cbae83 (patch) | |
tree | a4f2dcaef92e0fb09402f2f28f793928d0a16bfd /dcae-controller-core/dcae-controller-core-utils/src/main/server/bin/common.funcs | |
parent | e6bca17737d1897675e6403e196fc2a61f335651 (diff) |
Init dcae.controller
Change-Id: I460f09494faa84b55d9c5d54112e098b0e74d007
Signed-off-by: lj1412 <lji@research.att.com>
Diffstat (limited to 'dcae-controller-core/dcae-controller-core-utils/src/main/server/bin/common.funcs')
-rw-r--r-- | dcae-controller-core/dcae-controller-core-utils/src/main/server/bin/common.funcs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/dcae-controller-core/dcae-controller-core-utils/src/main/server/bin/common.funcs b/dcae-controller-core/dcae-controller-core-utils/src/main/server/bin/common.funcs new file mode 100644 index 0000000..dc7f280 --- /dev/null +++ b/dcae-controller-core/dcae-controller-core-utils/src/main/server/bin/common.funcs @@ -0,0 +1,35 @@ +# +# common shell functions +# + +_die() { + printf "$(date):FATAL:$1\n" + exit 2; +} + +_fail() { + _die "$1"; +} + +_warn() { + printf "$(date):WARN:$1\n"; +} + +_print() { + printf "$(date):INFO:$1\n"; +} + +_info() { + _print "$1"; +} + +_isRoot() { + [ $(whoami) != "root" ] && _fail "This script needs to be run by root"; +} + +fail() { + rc=$1 + shift; + echo "ERROR: $@" + exit $rc +} |