-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoc
executable file
·56 lines (45 loc) · 1.34 KB
/
noc
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
# ----------------------------------------------------------------------
# NOC CLI
# ----------------------------------------------------------------------
# Copyright (C) 2007-2020 The NOC Project
# See LICENSE for details
# ----------------------------------------------------------------------
cd "$(dirname "${0}")" || exit
NOC_CMD="$0"
export NOC_CMD
CMD="$1"
error_exit ( ) {
printf "\\033[1;31m%s: ${1:-'Unknown error'}\\033[0m\\n" "$PROGNAME" 1>&2
exit 1
}
if [ -f "$PWD/.env" ]; then
# shellcheck disable=SC1091
. "$PWD/.env"
fi
if [ ! -z "${NOC_PYTHON_INTERPRETER}" ]; then
export PYTHON_INTERPRETER="${NOC_PYTHON_INTERPRETER}"
fi
if [ -z "${PYTHON_INTERPRETER}" ] && [ -f "./bin/python3" ]; then
export PYTHON_INTERPRETER="./bin/python3"
fi
if [ -z "${PYTHON_INTERPRETER}" ]; then
export PYTHON_INTERPRETER='/usr/bin/env python3'
fi
if [ -f "${CUSTOM_PATH}/commands/$CMD.sh" ]; then
shift
exec /bin/sh "${CUSTOM_PATH}/commands/$CMD.sh" "$@"
fi
if [ -f "${CUSTOM_PATH}/commands/$CMD.py" ]; then
shift
exec ${PYTHON_INTERPRETER} "${CUSTOM_PATH}/commands/$CMD.py" "$@"
fi
if [ -f "./commands/$CMD.sh" ]; then
shift
exec /bin/sh "./commands/$CMD.sh" "$@"
fi
if [ -f "./commands/$CMD.py" ]; then
shift
exec ${PYTHON_INTERPRETER} "./commands/$CMD.py" "$@"
fi
error_exit "Invalid command $1"