Created
August 27, 2020 09:38
-
-
Save subfission/7ec6ca4eeac8479a48422e9b8a26a52a to your computer and use it in GitHub Desktop.
Icinga turnkey installer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Coded By: Zach Jetson | |
# | |
# This script installs icinga director and dependencies for CentOS 7. | |
# | |
# Requirements | |
# - icinga2, mysql, clean install | |
# | |
# usage: bash icinga_director_installer.sh | |
# | |
MODULES=( | |
"ipl 0.5.0" | |
"incubator 0.5.0" | |
"reactbundle 0.7.0" | |
"director 1.7.2" | |
) | |
MODULES_PATH="/usr/share/icingaweb2/modules" | |
echo "This script installs icinga director and dependencies for CentOS 7." | |
echo "Assuming MySQL is used..." | |
echo "generating secure credentials..." | |
DIRECTORPW=$(< /dev/urandom tr -dc A-Za-z-0-9 | head -c${1:-32};echo;) | |
mysql -p -e "CREATE DATABASE director CHARACTER SET 'utf8'; | |
CREATE USER director@localhost IDENTIFIED BY '${DIRECTORPW}'; | |
GRANT ALL ON director.* TO director@localhost;" | |
echo "installing binary dependencies..." | |
yum install -y wget rh-php73-php-process rh-php73-php-curl tar epel-release 1>/dev/null | |
echo "[✓] binaries installed" | |
echo "installing source module dependencies..." | |
install -d -m 0755 "${MODULES_PATH}/" | |
IFS_OLD=$IFS | |
for i in ${!MODULES[*]}; do | |
IFS=' ' read MODULE_NAME MODULE_VERSION <<< ${MODULES[$i]} | |
IFS=$IFS_OLD | |
MODULE_PATH="${MODULES_PATH}/${MODULE_NAME}" | |
rm -rf "$MODULE_PATH" | |
mkdir -p "$MODULE_PATH" | |
RELEASES="https://github.com/Icinga/icingaweb2-module-${MODULE_NAME}/archive/v${MODULE_VERSION}.tar.gz" | |
wget -q $RELEASES -O - \ | |
| tar xfz - -C "$MODULE_PATH" --strip-components 1 | |
icingacli module enable "${MODULE_NAME}" | |
sleep 1 | |
echo "[✓] ${MODULE_NAME} installed" | |
done | |
echo "Now run the graphical kickstart wizard" | |
echo "Choose either Icinga Director directly from the main menu" | |
echo "or navigate into Configuration / Modules / director and" | |
echo "select the Configuration tab." | |
APIPW=$(< /dev/urandom tr -dc A-Za-z-0-9 | head -c${1:-32};echo;) | |
cat << EOF > /etc/icinga2/conf.d/api-users.conf | |
object ApiUser "director" { | |
password = "${APIPW}" | |
permissions = [ "*" ] | |
//client_cn = "" | |
} | |
EOF | |
echo "[✓] Set API User config: /etc/icinga2/conf.d/api-users.conf" | |
echo "-----------------------------" | |
echo "Credentials for DB resource:" | |
echo " Database: director" | |
echo " Username: director" | |
echo " Password: $DIRECTORPW" | |
echo "Credentials for API resource:" | |
echo " Username: director" | |
echo " Password: $APIPW" | |
echo "-----------------------------" | |
echo "[✓] done" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment