-
Notifications
You must be signed in to change notification settings - Fork 1
/
testConfigFile.sh
executable file
·54 lines (43 loc) · 1.21 KB
/
testConfigFile.sh
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
#!/bin/bash
## Source External Files ##
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" # parent folder of script
for resource in "${DIR}"/Resources/*.sh; do source "${resource}"; done
## Command line options/arguments ##
# Display help text to describe available command-line options
helpText () {
echo "Usage: $(basename "$0") [options] -c /OUTPUT/Path/file.cfg
-- Test a Jamf Pro API config file before trying to use it with one of the scripts
e.g. $(basename "$0") -v -c ~/Downloads/customer.cfg
options:
-h show this help text
-c [file path] input an existing config file
-v verbose output"
}
while getopts ":c:vh" opt; do
case $opt in
c)
CONFIG_FILE=$(realPath "$OPTARG")
;;
v)
VERBOSE=true
;;
h)
helpText
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
## MAIN SCRIPT ##
oldVerbose=$VERBOSE # Record previous value of VERBOSE flag
VERBOSE=true # Set VERBOSE to true so config file is output from this script
loadConfig
testServerConnection "/JSSResource/categories"
VERBOSE=oldVerbose # Restore the value of VERBOSE