Skip to content

Instantly share code, notes, and snippets.

@ittp
Forked from Noobzik/glpi.sh
Created May 2, 2023 12:45
Show Gist options
  • Save ittp/69c22ed11a820a47de7f4c1f7647fee9 to your computer and use it in GitHub Desktop.
Save ittp/69c22ed11a820a47de7f4c1f7647fee9 to your computer and use it in GitHub Desktop.
#!/bin/sh
if ! [ $(id -u) = 0 ]; then
echo "I am not root!"
exit 1
fi
echo "Checking for lamp"
if ! [ $(dpkg-query -W -f='${Status}' apache2 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
echo "Already installed"
else
echo "apache2 not installed, run the lamp script"
exit 1
fi
if ! [ $(dpkg-query -W -f='${Status}' mariadb-server 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
echo "Already installed"
else
echo "mariadb-server not installed, run the lamp script"
exit 1
fi
if ! [ $(dpkg-query -W -f='${Status}' phpmyadmin 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
echo "Already installed"
else
echo "phpmyadmin not installed, run the lamp script"
exit 1
fi
echo "Updating and installing prequists"
apt update
apt install php-imap php-ldap php-curl php-xmlrpc php-gd php-mysql php-cas apcupsd php-apcu -y
echo "Downloading glpi 9.4.5"
wget https://github.com/glpi-project/glpi/releases/download/9.4.5/glpi-9.4.5.tgz
echo "Extracting to /var/www/html"
tar -xvzf glpi-9.4.5.tgz -C /var/www/html
echo "fixing access rights"
chown -R www-data /var/www/html/glpi/
echo "deleting downloaded file"
rm glpi-9.4.5.tgz
echo "Creating sql access for glpi"
# Replace the password "root" by something else for more security
touch glpi.sql
echo "create database glpidb;" >> glpi.sql
echo "grant all privileges on glpidb.* to glpiuser@localhost identified by \"root\";" >> glpi.sql
mysql < glpi.sql
rm glpi.sql
echo "Generating an empty .htaccess"
touch /var/www/html/glpi/.htaccess
echo "Downloading fusionInventory"
wget https://github.com/fusioninventory/fusioninventory-for-glpi/archive/glpi9.4+2.3.tar.gz
echo "Installing fusionInventory"
tar -zxvf glpi9.4+2.3.tar.gz -C /var/www/html/glpi/plugins
mv /var/www/html/glpi/plugins/fusioninventory-for-glpi-glpi9.4-2.3 /var/www/html/glpi/plugins/fusioninventory
chown -R www-data /var/www/html/glpi/plugins
rm glpi9.4+2.3.tar.gz
echo "fixing crontabs"
echo "*/1 * * * * /usr/bin/php5 /var/www/html/glpi/front/cron.php &>/dev/null" >> /var/spool/cron/crontabs/www-data
echo "Restarting services"
/etc/init.d/apache2 restart
/etc/init.d/mysql restart
/etc/init.d/cron restart
echo "Installation finished"
echo "sql username: glpiuser | sql pass (if not modified): root"
echo "Pour effacer lerreur de cron, aller dans Configuration --> Action Auto --> Page 2 --> TaskScheduler --> Executer"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment