diff --git a/install/glpi-install.sh b/install/glpi-install.sh new file mode 100644 index 00000000..0821c95d --- /dev/null +++ b/install/glpi-install.sh @@ -0,0 +1,150 @@ +#!/usr/bin/env bash + +#Copyright (c) 2021-2025 community-scripts ORG +# Author: NĂ­colas Pastorello (opastorello) +# License: MIT +# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y \ + curl \ + git \ + sudo \ + mc \ + apache2 \ + php \ + php-{apcu,cli,common,curl,gd,imap,ldap,mysql,xmlrpc,xml,mbstring,bcmath,intl,zip,redis,bz2,soap,cas} \ + libapache2-mod-php \ + mariadb-server +msg_ok "Installed Dependencies" + +msg_info "Setting up database" +DB_NAME=glpi_db +DB_USER=glpi +DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) +mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql mysql +mysql -u root -e "CREATE DATABASE $DB_NAME;" +mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';" +mysql -u root -e "GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'localhost';" +mysql -u root -e "GRANT SELECT ON \`mysql\`.\`time_zone_name\` TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" +msg_ok "Set up database" + +msg_info "Installing GLPi" +cd /opt +RELEASE=$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep '"tag_name"' | sed -E 's/.*"tag_name": "([^"]+)".*/\1/') +echo "${RELEASE}" >"/opt/${APP}_version.txt" +wget -q "https://github.com/glpi-project/glpi/releases/download/${RELEASE}/glpi-${RELEASE}.tgz" +tar -xzvf glpi-${RELEASE}.tgz +mv glpi /var/www/html/ + +cd /var/www/html/glpi +php bin/console db:install --db-name=$DB_NAME --db-user=$DB_USER --db-password=$DB_PASS --no-interaction +rm -rf /var/www/html/glpi/install +msg_ok "Installed GLPi" + +msg_info "Setting Downstream file" +cat < /var/www/html/glpi/inc/downstream.php + /etc/glpi/local_define.php +/etc/apache2/sites-available/glpi.conf + + ServerName localhost + DocumentRoot /var/www/html/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] + + + ErrorLog \${APACHE_LOG_DIR}/glpi_error.log + CustomLog \${APACHE_LOG_DIR}/glpi_access.log combined + +EOF + +a2dissite 000-default.conf +a2enmod rewrite +a2ensite glpi.conf +systemctl restart apache2 +msg_ok "Configured VirtualHost" + +msg_info "Setting Cron task" +echo "*/2 * * * * www-data /usr/bin/php /var/www/html/glpi/front/cron.php &>/dev/null" >> /etc/cron.d/glpi +msg_ok "Configured Cron task" + +msg_info "Changing parameters in php.ini" +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 "Changed parameters in php.ini" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -rf /opt/glpi-${RELEASE}.tgz +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned"