2025-01-06 11:09:12 -03:00
#!/usr/bin/env bash
2026-01-06 13:28:12 +01:00
# Copyright (c) 2021-2026 community-scripts ORG
2025-01-06 11:09:12 -03:00
# Author: Nícolas Pastorello (opastorello)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
2025-03-04 17:54:20 +01:00
# Source: https://www.glpi-project.org/
2025-01-06 11:09:12 -03:00
source /dev/stdin <<< " $FUNCTIONS_FILE_PATH "
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
2025-10-18 00:46:19 +02:00
$STD apt install -y \
2025-05-27 15:32:22 +02:00
git \
apache2 \
2025-10-13 14:26:55 -03:00
php8.4-{ apcu,cli,common,curl,gd,ldap,mysql,xmlrpc,xml,mbstring,bcmath,intl,zip,redis,bz2,soap} \
2025-05-27 15:32:22 +02:00
php-cas \
libapache2-mod-php
2025-01-06 11:09:12 -03:00
msg_ok "Installed Dependencies"
2025-06-18 12:03:00 +02:00
setup_mariadb
2025-05-27 15:32:22 +02:00
2025-08-13 14:28:50 +02:00
mariadb-tzinfo-to-sql /usr/share/zoneinfo | mariadb mysql
2026-10-01 08:12:33 +02:00
MARIADB_DB_NAME = "glpi_db" MARIADB_DB_USER = "glpi" MARIADB_DB_EXTRA_GRANTS = "GRANT SELECT ON \`mysql\`.\`time_zone_name\`" MARIADB_DB_CREDS_FILE = " $HOME /glpi_db.creds" setup_mariadb_db
2025-01-06 11:09:12 -03:00
2026-10-02 08:01:49 +02:00
fetch_and_deploy_gh_release "glpi" "glpi-project/glpi" "prebuild" "latest" "/opt/glpi" "glpi-*.tgz"
2025-01-06 11:09:12 -03:00
msg_info "Setting Downstream file"
2025-03-24 14:20:56 +01:00
cat <<EOF >/opt/glpi/inc/downstream.php
2025-01-06 11:09:12 -03:00
<?php
define('GLPI_CONFIG_DIR', '/etc/glpi/');
if (file_exists(GLPI_CONFIG_DIR . '/local_define.php')) {
require_once GLPI_CONFIG_DIR . '/local_define.php';
}
EOF
mv /opt/glpi/config /etc/glpi
mv /opt/glpi/files /var/lib/glpi
mv /var/lib/glpi/_log /var/log/glpi
2025-03-24 14:20:56 +01:00
cat <<EOF >/etc/glpi/local_define.php
2025-01-06 11:09:12 -03:00
<?php
define('GLPI_VAR_DIR', '/var/lib/glpi');
define('GLPI_DOC_DIR', GLPI_VAR_DIR);
define('GLPI_CRON_DIR', GLPI_VAR_DIR . '/_cron');
define('GLPI_DUMP_DIR', GLPI_VAR_DIR . '/_dumps');
define('GLPI_GRAPH_DIR', GLPI_VAR_DIR . '/_graphs');
define('GLPI_LOCK_DIR', GLPI_VAR_DIR . '/_lock');
define('GLPI_PICTURE_DIR', GLPI_VAR_DIR . '/_pictures');
define('GLPI_PLUGIN_DOC_DIR', GLPI_VAR_DIR . '/_plugins');
define('GLPI_RSS_DIR', GLPI_VAR_DIR . '/_rss');
define('GLPI_SESSION_DIR', GLPI_VAR_DIR . '/_sessions');
define('GLPI_TMP_DIR', GLPI_VAR_DIR . '/_tmp');
define('GLPI_UPLOAD_DIR', GLPI_VAR_DIR . '/_uploads');
define('GLPI_CACHE_DIR', GLPI_VAR_DIR . '/_cache');
define('GLPI_LOG_DIR', '/var/log/glpi');
EOF
msg_ok "Configured Downstream file"
2025-10-13 14:26:55 -03:00
msg_info "Configuring GLPI Database"
$STD /usr/bin/php /opt/glpi/bin/console db:install \
--db-host= localhost \
2026-10-01 08:12:33 +02:00
--db-name= glpi_db \
--db-user= glpi \
--db-password= $MARIADB_DB_PASS \
2025-10-13 14:26:55 -03:00
--default-language= en_US \
--no-interaction \
--allow-superuser \
--force
msg_ok "Configured GLPI Database"
2025-01-06 11:09:12 -03:00
msg_info "Setting Folder and File Permissions"
chown root:root /opt/glpi/ -R
chown www-data:www-data /etc/glpi -R
chown www-data:www-data /var/lib/glpi -R
chown www-data:www-data /var/log/glpi -R
chown www-data:www-data /opt/glpi/marketplace -Rf
find /opt/glpi/ -type f -exec chmod 0644 {} \;
find /opt/glpi/ -type d -exec chmod 0755 {} \;
find /etc/glpi -type f -exec chmod 0644 {} \;
find /etc/glpi -type d -exec chmod 0755 {} \;
find /var/lib/glpi -type f -exec chmod 0644 {} \;
find /var/lib/glpi -type d -exec chmod 0755 {} \;
find /var/log/glpi -type f -exec chmod 0644 {} \;
find /var/log/glpi -type d -exec chmod 0755 {} \;
msg_ok "Configured Folder and File Permissions"
msg_info "Setup Service"
cat <<EOF >/etc/apache2/sites-available/glpi.conf
<VirtualHost *:80>
ServerName localhost
DocumentRoot /opt/glpi/public
<Directory /opt/glpi/public>
Require all granted
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</Directory>
ErrorLog \${APACHE_LOG_DIR}/glpi_error.log
CustomLog \${APACHE_LOG_DIR}/glpi_access.log combined
</VirtualHost>
EOF
$STD a2dissite 000-default.conf
$STD a2enmod rewrite
$STD a2ensite glpi.conf
2025-11-23 12:00:10 +01:00
rm -rf /opt/glpi/install/install.php
2025-01-06 11:09:12 -03:00
msg_ok "Setup Service"
msg_info "Setup Cronjob"
2026-03-09 04:05:50 -03:00
echo "* * * * * php /opt/glpi/front/cron.php" | crontab -u www-data -
2025-01-06 11:09:12 -03:00
msg_ok "Setup Cronjob"
msg_info "Update PHP Params"
PHP_VERSION = $( ls /etc/php/ | grep -E '^[0-9]+\.[0-9]+$' | head -n 1)
PHP_INI = "/etc/php/ $PHP_VERSION /apache2/php.ini"
sed -i 's/^upload_max_filesize = .*/upload_max_filesize = 20M/' $PHP_INI
sed -i 's/^post_max_size = .*/post_max_size = 20M/' $PHP_INI
sed -i 's/^max_execution_time = .*/max_execution_time = 60/' $PHP_INI
sed -i 's/^max_input_vars = .*/max_input_vars = 5000/' $PHP_INI
sed -i 's/^memory_limit = .*/memory_limit = 256M/' $PHP_INI
sed -i 's/^;\?\s*session.cookie_httponly\s*=.*/session.cookie_httponly = On/' $PHP_INI
systemctl restart apache2
msg_ok "Update PHP Params"
motd_ssh
customize
2025-11-22 17:27:13 +01:00
cleanup_lxc