added basic installation steps for oneagent

dynatrace
Daniel Mikula 2023-05-16 07:40:27 +02:00
parent a5d6439164
commit ae34e938ce
1 changed files with 13 additions and 118 deletions

131
setup.sh
View File

@ -1,126 +1,21 @@
#!/bin/sh
# Author : NTT Data AG
# Date : 11-05-2023
# Date : 16-05-2023
helm_install=false
app_name=""
# Installs dynatrace oneagent on target machine
# fetch helm resources
# docs: https://helm.sh/docs/intro/install/
install_helm () {
# curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
# chmod 700 get_helm.sh
# ./get_helm.sh
echo "Helm not support yet."
echo "Installing dynatrace oneagent"
if [ -z "$1" ]; then
echo "ERROR: no token provided."
exit 1
}
# install resources
# TODO: check if this works
install_k3s () {
sudo dnf install -y container-selinux
sudo dnf install -y https://rpm.rancher.io/k3s/stable/common/centos/8/noarch/k3s-selinux-1.2-2.el8.noarch.rpm
get_k3s
}
# install k3s
# docs: https://docs.k3s.io/installation/configuration
get_k3s () {
sudo curl -sfL https://get.k3s.io | INSTALL_K3S_SYMLINK="skip" K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="--disable=traefik" sh -
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
kubectl get pods -A
}
# install git
install_git () {
sudo dnf -y update
sudo dnf -y install git
}
install_sock_shop () {
git clone https://github.com/microservices-demo/microservices-demo.git
cd microservices-demo/deploy/kubernetes
kubectl create namespace sock-shop
kubectl apply -f complete-demo.yaml
echo "Getting Pods from sock-shop namespace"
kubectl get pods -n sock-shop
# TODO: create check if list with pods returns and if they are ready
}
show_help() {
cat <<EOF
Usage: $0 [options]
Options:
-h, --help Show help information
-m, --helm Install Helm. Set flag when you want to install helm.
-a, --app <app_name> Specify the app name
EOF
}
show_allowed_apps () {
cat <<EOF
Supported apps:
- socks_shop
EOF
}
while [ "$#" -gt 0 ]; do
case "$1" in
-h|--help)
show_help
exit 0
;;
-m|--helm)
helm_install=true
shift
;;
-a|--app)
if [ "$2" ]; then
app_name="$2"
shift 2
else
echo "Error: Missing argument for $1 option"
show_help
exit 1
fi
;;
*)
echo "Error: Unrecognized option $1"
show_help
exit 1
;;
esac
done
# Check if --helm was set
if [ "$helm_install" = true ]; then
install_helm
else
echo "Skipping helm"
fi
echo "Installing GIT"
# install_git
echo "Installing K3S"
# install_k3s
# Validate app names
if [ -z "$app_name" ]; then
echo "Please specify app"
else
case $app_name in
"sock_shop")
echo "Installing sock shop"
install_sock_shop
;;
*)
show_allowed_apps
exit 1
;;
esac
echo "Downloading oneagent..."
wget -O Dynatrace-OneAgent-Linux-1.265.137.sh "https://elw69065.live.dynatrace.com/api/v1/deployment/installer/agent/unix/default/latest?arch=x86&flavor=default" --header="Authorization: Api-Token $1"
echo "Verfiying signature"
wget https://ca.dynatrace.com/dt-root.cert.pem ; ( echo 'Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg="sha-256"; boundary="--SIGNED-INSTALLER"'; echo ; echo ; echo '----SIGNED-INSTALLER' ; cat Dynatrace-OneAgent-Linux-1.265.137.sh ) | openssl cms -verify -CAfile dt-root.cert.pem > /dev/null
echo "Running dynatrace oneagent"
sudo Dynatrace-OneAgent-Linux-1.265.137.sh --set-infra-only=false --set-app-log-content-access=true
echo "Please restart processes you want to monitor"
fi