48 lines
1.7 KiB
Bash
48 lines
1.7 KiB
Bash
#!/bin/bash
|
|
|
|
## Script Location
|
|
SCRIPTDIR=$(dirname $0)
|
|
source "$SCRIPTDIR/common/colors.sh"
|
|
source "$SCRIPTDIR/common/functions.sh"
|
|
source "$SCRIPTDIR/common/load-defaults.sh"
|
|
|
|
printf "$COL_LIGHT_BLUE" "* Checking if system already has netdata installed"
|
|
install_netdata=0
|
|
if ! service_exists netdata
|
|
then
|
|
printf "$COL_YELLOW" "** $HOSTNAME appears to not have the netdata service"
|
|
install_netdata=$netdata_install
|
|
else
|
|
printf "$COL_GREEN" "** $HOSTNAME appears to already have the netdata service"
|
|
fi
|
|
|
|
if [ "$netdata_install" == "ask" ]; then
|
|
if (whiptail --title "Netdata Install" --yes-button "yes" --no-button "no" --yesno "Do You want to install netdata?" 10 80)
|
|
then
|
|
install_netdata=1
|
|
else
|
|
install_netdata=0
|
|
fi
|
|
fi
|
|
|
|
|
|
if [ "$install_netdata" == 1 ]; then
|
|
if [[ $HOSTNAME == *template* ]]; then
|
|
printf "$COL_RED" "** Hostname $HOSTNAME contains the word 'template', skipping netdata"
|
|
install_netdata=0
|
|
fi
|
|
fi
|
|
|
|
## netdata parent Join
|
|
if [ "$install_netdata" == 1 ]; then
|
|
printf "$COL_YELLOW" "** Setting up netdata."
|
|
# TODO deply a sed method to set the IP and API for the netdata parent
|
|
# netdata_parent_ip=$(whiptail --passwordbox "Please enter the ip address of the netdata parent." 8 78 --title "Netdata Parent Prompt" 3>&1 1>&2 2>&3)
|
|
# netdata_parent_api=$(whiptail --passwordbox "Please enter the api key of the netdata parent." 8 78 --title "Netdata Parent Prompt" 3>&1 1>&2 2>&3)
|
|
curl https://my-netdata.io/kickstart.sh > /tmp/netdata-kickstart.sh && sh /tmp/netdata-kickstart.sh
|
|
wget -O /etc/netdata/stream.conf http://10.0.69.250:89/stream.conf.hass
|
|
systemctl restart netdata
|
|
else
|
|
printf "$COL_CYAN" "** Skipping netdata setup"
|
|
fi
|