-
Notifications
You must be signed in to change notification settings - Fork 311
/
onboard_agent.sh
executable file
·103 lines (87 loc) · 2.81 KB
/
onboard_agent.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh
#
# Easy download/install/onboard script for the OMSAgent for Linux
#
# Values to be updated upon each new release
GITHUB_RELEASE="https://github.com/Microsoft/OMS-Agent-for-Linux/releases/download/OMSAgent_v1.9.0-0/"
BUNDLE_X64="omsagent-1.9.0-0.universal.x64.sh"
BUNDLE_X86="omsagent-1.9.0-0.universal.x86.sh"
usage()
{
echo "usage: $1 [OPTIONS]"
echo "Options:"
echo " -w id, --id id Use workspace ID <id> for automatic onboarding."
echo " -s key, --shared key Use <key> as the shared key for automatic onboarding."
echo " -d dmn, --domain dmn Use <dmn> as the OMS domain for onboarding. Optional."
echo " default: opinsights.azure.com"
echo " ex: opinsights.azure.us (for FairFax)"
echo " -p conf, --proxy conf Use <conf> as the proxy configuration."
echo " ex: -p [protocol://][user:password@]proxyhost[:port]"
echo " --purge Uninstall the package and remove all related data."
echo " -? | -h | --help shows this usage text."
}
# Extract parameters
while [ $# -ne 0 ]
do
case "$1" in
-d|--domain)
topLevelDomain=$2
shift 2
;;
-s|--shared)
onboardKey=$2
shift 2
;;
-w|--id)
onboardID=$2
shift 2
;;
--purge)
purgeAgent="true"
break;
;;
-p|--proxy)
proxyConf=$2
shift 2
;;
-\? | -h | --help)
usage `basename $0` >&2
exit 0
;;
*)
echo "Unknown argument: '$1'" >&2
echo "Use -h or --help for usage" >&2
exit 1
;;
esac
done
# Assemble parameters
bundleParameters="--upgrade"
if [ -n "$onboardID" ]; then
bundleParameters="${bundleParameters} -w $onboardID"
fi
if [ -n "$onboardKey" ]; then
bundleParameters="${bundleParameters} -s $onboardKey"
fi
if [ -n "$topLevelDomain" ]; then
bundleParameters="${bundleParameters} -d $topLevelDomain"
fi
if [ -n "$purgeAgent" ]; then
bundleParameters="--purge"
fi
if [ -n "$proxyConf" ]; then
bundleParameters="${bundleParameters} -p $proxyConf"
fi
# We need to use sudo for commands in the following block, if not running as root
SUDO=''
if (( $EUID != 0 )); then
SUDO='sudo'
fi
# Download, install, and onboard OMSAgent for Linux, depending on architecture of machine
if [ $(uname -m) = 'x86_64' ]; then
# x64 architecture
wget -O ${BUNDLE_X64} ${GITHUB_RELEASE}${BUNDLE_X64} && $SUDO sh ./${BUNDLE_X64} ${bundleParameters}
else
# x86 architecture
wget -O ${BUNDLE_X86} ${GITHUB_RELEASE}${BUNDLE_X86} && $SUDO sh ./${BUNDLE_X86} ${bundleParameters}
fi