deploy netdata v1
This commit is contained in:
parent
80394faf08
commit
913c6d6257
47
80-Deploy_Netdata.sh
Normal file
47
80-Deploy_Netdata.sh
Normal file
@ -0,0 +1,47 @@
|
||||
#!/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
|
||||
@ -4,3 +4,4 @@ unattended_upgrades_priority="low"
|
||||
systemd_journaling="ask"
|
||||
freeipa_join_realm="ask"
|
||||
freeipa_ca="ask"
|
||||
netdata_install="ask"
|
||||
|
||||
@ -4,3 +4,4 @@ unattended_upgrades_priority="medium"
|
||||
systemd_journaling_tweak=1
|
||||
freeipa_join_realm=1
|
||||
freeipa_ca=1
|
||||
netdata_install=1
|
||||
|
||||
@ -87,3 +87,13 @@ install_pkg() {
|
||||
|
||||
"${PKG_INSTALL[@]}" "${pkg_to_install}"
|
||||
}
|
||||
|
||||
|
||||
service_exists() {
|
||||
local n=$1
|
||||
if [[ $(systemctl list-units --all -t service --full --no-legend "$n.service" | sed 's/^\s*//g' | cut -f1 -d' ') == $n.service ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user