#!/bin/sh
# Pour install l'agent GLPI

GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NOCOLOR='\033[0m'

echo "${YELLOW} ** ${NOCOLOR} Début du script : 04-glpi"
echo "${NOCOLOR}"

echo "${YELLOW} * ${NOCOLOR} Déclaration du proxy"
echo "${NOCOLOR}"

export http_proxy='http://serv-proxy.fr.dgs.group:3128'
export https_proxy='http://serv-proxy.fr.dgs.group:3128'
export ftp_proxy='http://serv-proxy.fr.dgs.group:3128'

echo "${YELLOW} * ${NOCOLOR} Déclaration du proxy : ${GREEN} OK"
echo "${NOCOLOR}"

echo "${YELLOW} * ${NOCOLOR} Installation Wget"
echo "${NOCOLOR}"

apt install -y wget >> /dev/null

echo "${YELLOW} * ${NOCOLOR}Installation Wget : ${GREEN} OK"
echo "${NOCOLOR}"

echo "${YELLOW} * ${NOCOLOR} Copie du certificat"
echo "${NOCOLOR}"

cp 04-agent-glpi/root-ca.cer /etc/ssl/certs/root-ca.cer >> /dev/null

echo "${YELLOW} * ${NOCOLOR} Copie du certificat : ${GREEN} OK"
echo "${NOCOLOR}"

echo "${YELLOW} * ${NOCOLOR} Telechargement de l'installer"
echo "${NOCOLOR}"

wget https://github.com/glpi-project/glpi-agent/releases/download/1.11/glpi-agent-1.11-linux-installer.pl  >> /dev/null

echo "${YELLOW} * ${NOCOLOR} Telechargement de l'installer : ${GREEN} OK"
echo "${NOCOLOR}"

echo "${YELLOW} * ${NOCOLOR} Installation"
echo "${NOCOLOR}"

perl glpi-agent-1.11-linux-installer.pl --reinstall -s "https://glpi.fr.dgs.group/marketplace/glpiinventory/" -t "ServeurProd" --ca-cert-file=/etc/ssl/certs/root-ca.cer --type=all -v  >> /dev/null

echo "${YELLOW} * ${NOCOLOR} Installation : ${GREEN} OK"
echo "${NOCOLOR}"

echo "${YELLOW} ** ${NOCOLOR} Fin du script : 04-glpi"
echo "${NOCOLOR}"