diff --git a/scrutinty.sh b/scrutinty.sh new file mode 100644 index 0000000..ba71ed3 --- /dev/null +++ b/scrutinty.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# make sure we are running as sudo +if [ "$EUID" -ne 0 ]; then + echo "Please run as root" + exit +fi + +# get OS ditro and version +OS=$(hostnamectl | awk '/Operating System/ {print $3}') +VM=$(hostnamectl | awk '/Virtualization/ {print $2}') +if [ ${OS} == 'Ubuntu' ]; then + OS_VERSION=$(hostnamectl | awk '/Operating System/ {print $4}') +else + OS_VERSION=$(hostnamectl | awk '/Operating System/ {print $5}') +fi + +if [ "${VM}" == "vmware" ] || [ "${VM}" == "kvm" ] || [ "${VM}" == "lxc" ]; then + VM="true" + echo "This should only be installed with physical hosts" + exit +fi + +# scrutiny web directory +SCRUTINY_DIRECTORY="/opt/scrutiny" +# download srouce code of latest releases page +HTML_SOURCE=$(wget -O - https://api.github.com/repos/AnalogJ/scrutiny/releases/latest) +# version +VERSION=$(echo ${HTML_SOURCE} | jq -r .tag_name) +# get assets +ASSETS=$(echo ${HTML_SOURCE} | jq -r .assets[]) + +jq -c .assets[] <<< ${HTML_SOURCE}| while read i; do + name=$(echo ${i} | jq -r .name) + downloadUrl=$(echo ${i} | jq -r .browser_download_url) + if [ ${name} == 'scrutiny-collector-metrics-linux-amd64' ]; then + wget -O "${SCRUTINY_DIRECTORY}/${name}" ${downloadUrl} + chmod +x "${SCRUTINY_DIRECTORY}/${name}" + cat << EOF > /etc/cron.daily/scrutiny +#!/bin/bash +"${SCRUTINY_DIRECTORY}/${name}" run --api-endpoint="http://10.0.20.20:8080" --host-id $(hostname) +EOF + chmod +x /etc/cron.daily/scrutiny + fi +done \ No newline at end of file