Skip to content

Commit f7d37a8

Browse files
opastorellomichelroegl-brunnerMickLesk
authored
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 <[email protected]> * Update install/glpi-install.sh Co-authored-by: Michel Roegl-Brunner <[email protected]> * 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 <[email protected]> Co-authored-by: CanbiZ <[email protected]>
1 parent 4888c33 commit f7d37a8

File tree

3 files changed

+237
-0
lines changed

3 files changed

+237
-0
lines changed

ct/glpi.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
4+
# Copyright (c) 2021-2025 community-scripts ORG
5+
# Author: Nícolas Pastorello (opastorello)
6+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
7+
8+
# App Default Values
9+
APP="GLPI"
10+
var_tags="asset-management;foss"
11+
var_cpu="2"
12+
var_ram="2048"
13+
var_disk="10"
14+
var_os="debian"
15+
var_version="12"
16+
var_unprivileged="1"
17+
18+
# App Output & Base Settings
19+
header_info "$APP"
20+
base_settings
21+
22+
# Core
23+
variables
24+
color
25+
catch_errors
26+
27+
function update_script() {
28+
header_info
29+
check_container_storage
30+
check_container_resources
31+
32+
if [[ ! -d /opt/glpi ]]; then
33+
msg_error "No ${APP} Installation Found!"
34+
exit
35+
fi
36+
RELEASE=$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep '"tag_name"' | sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
37+
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
38+
msg_error "Ther is currently no automatic update function for ${APP}."
39+
else
40+
msg_ok "No update required. ${APP} is already at v${RELEASE}."
41+
fi
42+
exit
43+
}
44+
45+
start
46+
build_container
47+
description
48+
49+
msg_ok "Completed Successfully!\n"
50+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
51+
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
52+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:80${CL}"

install/glpi-install.sh

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: Nícolas Pastorello (opastorello)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
7+
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
8+
color
9+
verb_ip6
10+
catch_errors
11+
setting_up_container
12+
network_check
13+
update_os
14+
15+
msg_info "Installing Dependencies"
16+
$STD apt-get install -y \
17+
curl \
18+
git \
19+
sudo \
20+
mc \
21+
apache2 \
22+
php8.2-{apcu,cli,common,curl,gd,imap,ldap,mysql,xmlrpc,xml,mbstring,bcmath,intl,zip,redis,bz2,soap} \
23+
php-cas \
24+
libapache2-mod-php \
25+
mariadb-server
26+
msg_ok "Installed Dependencies"
27+
28+
msg_info "Setting up database"
29+
DB_NAME=glpi_db
30+
DB_USER=glpi
31+
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
32+
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql mysql
33+
mysql -u root -e "CREATE DATABASE $DB_NAME;"
34+
mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
35+
mysql -u root -e "GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'localhost';"
36+
mysql -u root -e "GRANT SELECT ON \`mysql\`.\`time_zone_name\` TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
37+
{
38+
echo "GLPI Database Credentials"
39+
echo "Database: $DB_NAME"
40+
echo "Username: $DB_USER"
41+
echo "Password: $DB_PASS"
42+
} >> ~/glpi_db.creds
43+
msg_ok "Set up database"
44+
45+
msg_info "Installing GLPi"
46+
cd /opt
47+
RELEASE=$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | grep '"tag_name"' | sed -E 's/.*"tag_name": "([^"]+)".*/\1/')
48+
wget -q "https://github.com/glpi-project/glpi/releases/download/${RELEASE}/glpi-${RELEASE}.tgz"
49+
tar -xzvf glpi-${RELEASE}.tgz
50+
cd /opt/glpi
51+
$STD php bin/console db:install --db-name=$DB_NAME --db-user=$DB_USER --db-password=$DB_PASS --no-interaction
52+
echo "${RELEASE}" >"/opt/${APP}_version.txt"
53+
msg_ok "Installed GLPi"
54+
55+
msg_info "Setting Downstream file"
56+
cat <<EOF > /opt/glpi/inc/downstream.php
57+
<?php
58+
define('GLPI_CONFIG_DIR', '/etc/glpi/');
59+
if (file_exists(GLPI_CONFIG_DIR . '/local_define.php')) {
60+
require_once GLPI_CONFIG_DIR . '/local_define.php';
61+
}
62+
EOF
63+
64+
mv /opt/glpi/config /etc/glpi
65+
mv /opt/glpi/files /var/lib/glpi
66+
mv /var/lib/glpi/_log /var/log/glpi
67+
68+
cat <<EOF > /etc/glpi/local_define.php
69+
<?php
70+
define('GLPI_VAR_DIR', '/var/lib/glpi');
71+
define('GLPI_DOC_DIR', GLPI_VAR_DIR);
72+
define('GLPI_CRON_DIR', GLPI_VAR_DIR . '/_cron');
73+
define('GLPI_DUMP_DIR', GLPI_VAR_DIR . '/_dumps');
74+
define('GLPI_GRAPH_DIR', GLPI_VAR_DIR . '/_graphs');
75+
define('GLPI_LOCK_DIR', GLPI_VAR_DIR . '/_lock');
76+
define('GLPI_PICTURE_DIR', GLPI_VAR_DIR . '/_pictures');
77+
define('GLPI_PLUGIN_DOC_DIR', GLPI_VAR_DIR . '/_plugins');
78+
define('GLPI_RSS_DIR', GLPI_VAR_DIR . '/_rss');
79+
define('GLPI_SESSION_DIR', GLPI_VAR_DIR . '/_sessions');
80+
define('GLPI_TMP_DIR', GLPI_VAR_DIR . '/_tmp');
81+
define('GLPI_UPLOAD_DIR', GLPI_VAR_DIR . '/_uploads');
82+
define('GLPI_CACHE_DIR', GLPI_VAR_DIR . '/_cache');
83+
define('GLPI_LOG_DIR', '/var/log/glpi');
84+
EOF
85+
msg_ok "Configured Downstream file"
86+
87+
msg_info "Setting Folder and File Permissions"
88+
chown root:root /opt/glpi/ -R
89+
chown www-data:www-data /etc/glpi -R
90+
chown www-data:www-data /var/lib/glpi -R
91+
chown www-data:www-data /var/log/glpi -R
92+
chown www-data:www-data /opt/glpi/marketplace -Rf
93+
find /opt/glpi/ -type f -exec chmod 0644 {} \;
94+
find /opt/glpi/ -type d -exec chmod 0755 {} \;
95+
find /etc/glpi -type f -exec chmod 0644 {} \;
96+
find /etc/glpi -type d -exec chmod 0755 {} \;
97+
find /var/lib/glpi -type f -exec chmod 0644 {} \;
98+
find /var/lib/glpi -type d -exec chmod 0755 {} \;
99+
find /var/log/glpi -type f -exec chmod 0644 {} \;
100+
find /var/log/glpi -type d -exec chmod 0755 {} \;
101+
msg_ok "Configured Folder and File Permissions"
102+
103+
msg_info "Setup Service"
104+
cat <<EOF >/etc/apache2/sites-available/glpi.conf
105+
<VirtualHost *:80>
106+
ServerName localhost
107+
DocumentRoot /opt/glpi/public
108+
109+
<Directory /opt/glpi/public>
110+
Require all granted
111+
RewriteEngine On
112+
RewriteCond %{HTTP:Authorization} ^(.+)$
113+
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
114+
RewriteCond %{REQUEST_FILENAME} !-f
115+
RewriteRule ^(.*)$ index.php [QSA,L]
116+
</Directory>
117+
118+
ErrorLog \${APACHE_LOG_DIR}/glpi_error.log
119+
CustomLog \${APACHE_LOG_DIR}/glpi_access.log combined
120+
</VirtualHost>
121+
EOF
122+
$STD a2dissite 000-default.conf
123+
$STD a2enmod rewrite
124+
$STD a2ensite glpi.conf
125+
msg_ok "Setup Service"
126+
127+
msg_info "Setup Cronjob"
128+
(crontab -l 2>/dev/null; echo "* * * * * php /opt/glpi/front/cron.php") | crontab -
129+
msg_ok "Setup Cronjob"
130+
131+
msg_info "Update PHP Params"
132+
PHP_VERSION=$(ls /etc/php/ | grep -E '^[0-9]+\.[0-9]+$' | head -n 1)
133+
PHP_INI="/etc/php/$PHP_VERSION/apache2/php.ini"
134+
sed -i 's/^upload_max_filesize = .*/upload_max_filesize = 20M/' $PHP_INI
135+
sed -i 's/^post_max_size = .*/post_max_size = 20M/' $PHP_INI
136+
sed -i 's/^max_execution_time = .*/max_execution_time = 60/' $PHP_INI
137+
sed -i 's/^max_input_vars = .*/max_input_vars = 5000/' $PHP_INI
138+
sed -i 's/^memory_limit = .*/memory_limit = 256M/' $PHP_INI
139+
sed -i 's/^;\?\s*session.cookie_httponly\s*=.*/session.cookie_httponly = On/' $PHP_INI
140+
systemctl restart apache2
141+
msg_ok "Update PHP Params"
142+
143+
motd_ssh
144+
customize
145+
146+
msg_info "Cleaning up"
147+
rm -rf /opt/glpi/install
148+
rm -rf /opt/glpi-${RELEASE}.tgz
149+
$STD apt-get -y autoremove
150+
$STD apt-get -y autoclean
151+
msg_ok "Cleaned"

json/glpi.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "GLPI",
3+
"slug": "glpi",
4+
"categories": [
5+
0
6+
],
7+
"date_created": "2025-01-06",
8+
"type": "ct",
9+
"updateable": false,
10+
"privileged": false,
11+
"interface_port": 80,
12+
"documentation": "https://glpi-project.org/documentation/",
13+
"website": "https://glpi-project.org/",
14+
"logo": "https://raw.githubusercontent.com/glpi-project/glpi/refs/heads/main/public/pics/login_logo_glpi.png",
15+
"description": "GLPI is a Free Asset and IT Management Software package, Data center management, ITIL Service Desk, licenses tracking and software auditing.",
16+
"install_methods": [
17+
{
18+
"type": "default",
19+
"script": "ct/glpi.sh",
20+
"resources": {
21+
"cpu": 2,
22+
"ram": 2048,
23+
"hdd": 10,
24+
"os": "Debian",
25+
"version": "12"
26+
}
27+
}
28+
],
29+
"default_credentials": {
30+
"username": "glpi",
31+
"password": "glpi"
32+
},
33+
"notes": []
34+
}

0 commit comments

Comments
 (0)