From f7d37a8f3ceaa145ee14d89cedaf1ec27306f7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADcolas=20Pastorello?= Date: Mon, 6 Jan 2025 11:09:12 -0300 Subject: [PATCH] New script: GLPI (#1201) * Create glpi.json * Create glpi.sh * Create glpi-install.sh * Update glpi.sh * Update glpi.sh * Update glpi.sh * Update glpi-install.sh * Update glpi-install.sh * Update glpi.json * Update glpi.json * Update glpi.sh * Update install/glpi-install.sh Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com> * Update install/glpi-install.sh Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com> * Update glpi-install.sh * Update glpi-install.sh * Update glpi-install.sh * Update glpi.json * Update glpi.sh * Update glpi-install.sh Adjusted apt install * Update glpi-install.sh Changed cron * Update glpi-install.sh Added STD * Update glpi.sh * Update glpi-install.sh * Update glpi.json --------- Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com> Co-authored-by: CanbiZ <47820557+MickLesk@users.noreply.github.com> --- ct/glpi.sh | 52 ++++++++++++++ install/glpi-install.sh | 151 ++++++++++++++++++++++++++++++++++++++++ json/glpi.json | 34 +++++++++ 3 files changed, 237 insertions(+) create mode 100644 ct/glpi.sh create mode 100644 install/glpi-install.sh create mode 100644 json/glpi.json diff --git a/ct/glpi.sh b/ct/glpi.sh new file mode 100644 index 00000000..a485061b --- /dev/null +++ b/ct/glpi.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: NĂ­colas Pastorello (opastorello) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE + +# App Default Values +APP="GLPI" +var_tags="asset-management;foss" +var_cpu="2" +var_ram="2048" +var_disk="10" +var_os="debian" +var_version="12" +var_unprivileged="1" + +# App Output & Base Settings +header_info "$APP" +base_settings + +# Core +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -d /opt/glpi ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + RELEASE=$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep '"tag_name"' | sed -E 's/.*"tag_name": "([^"]+)".*/\1/') + if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + msg_error "Ther is currently no automatic update function for ${APP}." + else + msg_ok "No update required. ${APP} is already at v${RELEASE}." + fi + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:80${CL}" diff --git a/install/glpi-install.sh b/install/glpi-install.sh new file mode 100644 index 00000000..04cbf1f2 --- /dev/null +++ b/install/glpi-install.sh @@ -0,0 +1,151 @@ +#!/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 \ + php8.2-{apcu,cli,common,curl,gd,imap,ldap,mysql,xmlrpc,xml,mbstring,bcmath,intl,zip,redis,bz2,soap} \ + php-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;" +{ + echo "GLPI Database Credentials" + echo "Database: $DB_NAME" + echo "Username: $DB_USER" + echo "Password: $DB_PASS" +} >> ~/glpi_db.creds +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/') +wget -q "https://github.com/glpi-project/glpi/releases/download/${RELEASE}/glpi-${RELEASE}.tgz" +tar -xzvf glpi-${RELEASE}.tgz +cd /opt/glpi +$STD php bin/console db:install --db-name=$DB_NAME --db-user=$DB_USER --db-password=$DB_PASS --no-interaction +echo "${RELEASE}" >"/opt/${APP}_version.txt" +msg_ok "Installed GLPi" + +msg_info "Setting Downstream file" +cat < /opt/glpi/inc/downstream.php + /etc/glpi/local_define.php +/etc/apache2/sites-available/glpi.conf + + ServerName localhost + DocumentRoot /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] + + + ErrorLog \${APACHE_LOG_DIR}/glpi_error.log + CustomLog \${APACHE_LOG_DIR}/glpi_access.log combined + +EOF +$STD a2dissite 000-default.conf +$STD a2enmod rewrite +$STD a2ensite glpi.conf +msg_ok "Setup Service" + +msg_info "Setup Cronjob" +(crontab -l 2>/dev/null; echo "* * * * * php /opt/glpi/front/cron.php") | crontab - +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 + +msg_info "Cleaning up" +rm -rf /opt/glpi/install +rm -rf /opt/glpi-${RELEASE}.tgz +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/json/glpi.json b/json/glpi.json new file mode 100644 index 00000000..6d652bdd --- /dev/null +++ b/json/glpi.json @@ -0,0 +1,34 @@ +{ + "name": "GLPI", + "slug": "glpi", + "categories": [ + 0 + ], + "date_created": "2025-01-06", + "type": "ct", + "updateable": false, + "privileged": false, + "interface_port": 80, + "documentation": "https://glpi-project.org/documentation/", + "website": "https://glpi-project.org/", + "logo": "https://raw.githubusercontent.com/glpi-project/glpi/refs/heads/main/public/pics/login_logo_glpi.png", + "description": "GLPI is a Free Asset and IT Management Software package, Data center management, ITIL Service Desk, licenses tracking and software auditing.", + "install_methods": [ + { + "type": "default", + "script": "ct/glpi.sh", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 10, + "os": "Debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": "glpi", + "password": "glpi" + }, + "notes": [] +}