Skip to content

Instantly share code, notes, and snippets.

@guesslin
Last active May 16, 2017 09:51
Show Gist options
  • Save guesslin/1a5d49ada07be3cda1bf652f01c82305 to your computer and use it in GitHub Desktop.
Save guesslin/1a5d49ada07be3cda1bf652f01c82305 to your computer and use it in GitHub Desktop.
#!/bin/bash
# ssh -i <ssh_key> azureuser@<acs_fqdn> bash install-omsagent.sh -w <oms_wid> -s <oms_sharedkey> -ssh=</path/to/ssh-key-file>
while [[ $# -gt 0 ]]; do
key="$1"
case "$key" in
-w)
OMS_WORKSPACE="$2"
shift
;;
-s)
OMS_SHAREDKEY="$2"
shift
;;
-ssh=*)
SSH_KEY="${key#*=}"
;;
*)
;;
esac
# Shift after checking all the cases to get the next option
shift
done
oms_url="https://github.com/Microsoft/OMS-Agent-for-Linux/releases/download/OMSAgent-201704-v1.3.3-15/omsagent-1.3.3-15.universal.x64.sh"
check_oms() {
if [ -z $OMS_WORKSPACE ] || [ -z $OMS_SHAREDKEY ]; then
echo "You Must Give OMS WorkspaceID and SharedKey"
exit
fi
}
check_ssh() {
if [ -z SSH_KEY ]; then
echo "You Must Give SSH Key"
exit
fi
}
nodes=$(kubectl get nodes | awk 'NR==2,NR==-1 {print $1}')
check_oms
check_ssh
for node in $nodes; do
echo "Start setup oms in ACS Node $node"
ssh -i SSH_KEY $node curl -L -O $oms_url
ssh -i SSH_KEY $node sudo bash omsagent-1.3.3-15.universal.x64.sh --install
ssh -i SSH_KEY $node sudo /opt/microsoft/omsagent/bin/omsadmin.sh -w $OMS_WORKSPACE -s OMS_SHAREDKEY
echo "End setup oms in ACS Node $node"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment