Compare commits

...

4 Commits

3 changed files with 47 additions and 7 deletions

45
scrutinty.sh Normal file
View File

@@ -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

View File

@@ -22,16 +22,11 @@ else
OS_VERSION=$(hostnamectl | awk '/Operating System/ {print $5}')
fi
if [ "${VIRTUALIZATION}" == "vmware" ]; then
if [ "${VIRTUALIZATION}" == "vmware" ] || [ "${VIRTUALIZATION}" == "kvm" ]; then
VM="true"
else
VM="false"
fi
if [ "${VIRTUALIZATION}" == "kvm" ]; then
KVM="true"
else
KVM="false"
fi
# set custom bash settings system wide
cat <<EOF > /etc/profile.d/gaunt_custom_bash.sh

View File

@@ -23,7 +23,7 @@ else
OS_VERSION=$(hostnamectl | awk '/Operating System/ {print $5}')
fi
if [ "${VM}" == "vmware" ] || [ "${VM}" == "kvm" ] ; then
if [ "${VM}" == "vmware" ] || [ "${VM}" == "kvm" ] || [ "${VM}" == "lxc" ]; then
VM="true"
else
VM="false"