#!/bin/bash
VERSION=1.1
GITUSR=gitgsb
GITPRJ=gsb
GITPATH=/home/${GITUSR}/${GITPRJ}.git

apt update && apt upgrade -y
apt install -y apache2 git 
getent passwd ${GITUSR} >> /dev/null
if [[ $? != 0 ]]; then
  echo "creation utilisateur ${GITUSR} ..."
  /sbin/useradd -m -d /home/${GITUSR} -s /bin/bash ${GITUSR} 
  echo "${GITUSR}:${GITUSR}" | /sbin/chpasswd 
fi
echo "--> ${GITPATH}"
if [[ -d ${GITPATH} ]]; then 
  rm -rf ${GITPATH} 
fi
su -c "git clone --bare http://sio.lyc-lecastel.fr/${GITPRJ}.git ${GITPATH}" ${GITUSR}

su -c "cd ${GITPATH}/hooks && cp post-update.sample post-update && bash post-update" ${GITUSR}
ln -s ${GITPATH} /var/www/html/${GITPRJ}.git
[[ -d /var/www/html/gsbstore ]]|| mkdir /var/www/html/gsbstore

cd /var/www/html && wget -O gsbboot http://sio.lyc-lecastel.fr/store/gsbboot 

(cat <<EOT > /var/www/html/gsbstore/getall
#!/bin/bash
GLPIREL=9.4.5
wget -nc https://github.com/glpi-project/glpi/releases/download/\${GLPIREL}/glpi-\${GLPIREL}.tgz
 
FIREL=9.4+2.3
wget -nc https://github.com/fusioninventory/fusioninventory-for-glpi/releases/download/glpi\${FIREL}/fusioninventory-\${FIREL}.tar.gz
 
FIAGREL=2.5.2 
wget -nc https://github.com/fusioninventory/fusioninventory-agent/releases/download/\${FIAGREL}/fusioninventory-agent_windows-x64_\${FIAGREL}.exe
 
wget -nc https://github.com/fusioninventory/fusioninventory-agent/releases/download/$FIAGREL/fusioninventory-agent_windows-x86_\${FIAGREL}.exe
 
FOGREL=1.5.7
wget -nc https://github.com/FOGProject/fogproject/archive/\${FOGREL}.tar.gz -O fogproject-\${FOGREL}.tar.gz
 
wget -nc https://fr.wordpress.org/wordpress-5.3.2-fr_FR.tar.gz

GOSSVER=v0.3.10
curl -L https://github.com/aelsabbahy/goss/releases/download/\${GOSSVER}/goss-linux-amd64 -o goss
chmod +x goss 
EOT
)
echo "fichier getall cree ..."
echo "pour recuperer les archives, lancer :"
echo "cd /var/www/html/gsbstore ; bash getall"
echo "pour installer une machine : curl adresse_depl/gsbboot | bash"

 
 

