aboutsummaryrefslogtreecommitdiffstats
path: root/dcae-controller-core/dcae-controller-core-utils/src/main/server/bin/common.funcs
blob: dc7f280c10b7d3a6a58dbd6505c974a3f5057392 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
}