├── README.md
└── glpi-install.sh
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # GLPI_install_script
3 |
4 |
5 |
6 | ## About this script
7 |
8 | This script was written in order to quickly install the latest version of GLPI (currently 10.0.05) on Ubuntu & Debian servers.
9 |
10 | The script will install, Apache, MariaDB, PHP and dependencies, and download and install the latest version from the [Official GLPI repo](https://github.com/glpi-project/glpi) and configure the database for you.
11 | Once the script is executed, the only thing you have to do will be to connect to GLPI.
12 |
13 | The installation of GLPI is done without SSL. If you need to open access to GLPI from the outside and/or an SSL certificate, I recommend that you use a reverse proxy.
14 |
15 | ⚠️ It is strongly recommended to run this script on a fresh install.
16 |
17 | ### Default accounts
18 | | Login | Password | Role |
19 | |--|--|--|
20 | glpi|glpi|admin account
21 | tech|tech|technical account
22 | normal|normal|"normal" account
23 | post-only|postonly|post-only account
24 |
25 | ### Read the documentation
26 | Know that I have no connection with the team that develops GLPI and/or TecLib.
27 | If you encounter a problem with this script on one of the compatible distributions, you can create an issue, i will help you with pleasure.
28 | If you encounter a problem with GLPI and/or need more information on how it works, I recommend that you read the documentations:
29 |
30 | [GLPI Administrators Docs](https://glpi-install.readthedocs.io/)
31 |
32 | [GLPI Users Docs](https://glpi-user-documentation.readthedocs.io/)
33 |
34 | ## Compatibility
35 | Since this script uses apt, it currently only works on debian-based distributions.
36 | This script was tested on this distributions:
37 | | OS | VERSION| COMPATIBILITY|
38 | |--|--|--|
39 | |Debian|10|⚠️ Never tried, if you choose to force the script, it is at your own risk. |
40 | |Debian|11|✅|
41 | |Debian|12|✅|
42 | |Ubuntu|22.04|✅|
43 | |Ubuntu|22.10|⚠️ Never tried, if you choose to force the script, it is at your own risk.|
44 |
45 |
46 | ## How to use
47 | GLPI_install_script is installed by running one of the following commands in your terminal. You can install this via the command-line with either curl or wget.
48 |
49 | wget https://raw.githubusercontent.com/jr0w3/GLPI_install_script/main/glpi-install.sh && bash glpi-install.sh
50 | or with curl
51 |
52 | curl -O https://raw.githubusercontent.com/jr0w3/GLPI_install_script/main/glpi-install.sh && bash glpi-install.sh
53 |
--------------------------------------------------------------------------------
/glpi-install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # GLPI install script
4 | #
5 | # Author: jr0w3
6 | # Version: 1.1.1
7 | #
8 |
9 | function warn(){
10 | echo -e '\e[31m'$1'\e[0m';
11 | }
12 | function info(){
13 | echo -e '\e[36m'$1'\e[0m';
14 | }
15 |
16 | function check_root()
17 | {
18 | # Vérification des privilèges root
19 | if [[ "$(id -u)" -ne 0 ]]
20 | then
21 | warn "This script must be run as root" >&2
22 | exit 1
23 | else
24 | info "Root privilege: OK"
25 | fi
26 | }
27 |
28 | function check_distro()
29 | {
30 | # Constante pour les versions de Debian acceptables
31 | DEBIAN_VERSIONS=("11" "12")
32 |
33 | # Constante pour les versions d'Ubuntu acceptables
34 | UBUNTU_VERSIONS=("22.04")
35 |
36 | # Récupération du nom de la distribution
37 | DISTRO=$(lsb_release -is)
38 |
39 | # Récupération de la version de la distribution
40 | VERSION=$(lsb_release -rs)
41 |
42 | # Vérifie si c'est une distribution Debian
43 | if [ "$DISTRO" == "Debian" ]; then
44 | # Vérifie si la version de Debian est acceptable
45 | if [[ " ${DEBIAN_VERSIONS[*]} " == *" $VERSION "* ]]; then
46 | info "Your operating system version ($DISTRO $VERSION) is compatible."
47 | else
48 | warn "Your operating system version ($DISTRO $VERSION) is not noted as compatible."
49 | warn "Do you still want to force the installation? Be careful, if you choose to force the script, it is at your own risk."
50 | info "Are you sure you want to continue? [yes/no]"
51 | read response
52 | if [ $response == "yes" ]; then
53 | info "Continuing..."
54 | elif [ $response == "no" ]; then
55 | info "Exiting..."
56 | exit 1
57 | else
58 | warn "Invalid response. Exiting..."
59 | exit 1
60 | fi
61 | fi
62 |
63 | # Vérifie si c'est une distribution Ubuntu
64 | elif [ "$DISTRO" == "Ubuntu" ]; then
65 | # Vérifie si la version d'Ubuntu est acceptable
66 | if [[ " ${UBUNTU_VERSIONS[*]} " == *" $VERSION "* ]]; then
67 | info "Your operating system version ($DISTRO $VERSION) is compatible."
68 | else
69 | warn "Your operating system version ($DISTRO $VERSION) is not noted as compatible."
70 | warn "Do you still want to force the installation? Be careful, if you choose to force the script, it is at your own risk."
71 | info "Are you sure you want to continue? [yes/no]"
72 | read response
73 | if [ $response == "yes" ]; then
74 | info "Continuing..."
75 | elif [ $response == "no" ]; then
76 | info "Exiting..."
77 | exit 1
78 | else
79 | warn "Invalid response. Exiting..."
80 | exit 1
81 | fi
82 | fi
83 | # Si c'est une autre distribution
84 | else
85 | warn "Il s'agit d'une autre distribution que Debian ou Ubuntu qui n'est pas compatible."
86 | exit 1
87 | fi
88 | }
89 |
90 | function network_info()
91 | {
92 | INTERFACE=$(ip route | awk 'NR==1 {print $5}')
93 | IPADRESS=$(ip addr show $INTERFACE | grep inet | awk '{ print $2; }' | sed 's/\/.*$//' | head -n 1)
94 | HOST=$(hostname)
95 | }
96 |
97 | function confirm_installation()
98 | {
99 | warn "This script will now install the necessary packages for installing and configuring GLPI."
100 | info "Are you sure you want to continue? [yes/no]"
101 | read confirm
102 | if [ $confirm == "yes" ]; then
103 | info "Continuing..."
104 | elif [ $confirm == "no" ]; then
105 | info "Exiting..."
106 | exit 1
107 | else
108 | warn "Invalid response. Exiting..."
109 | exit 1
110 | fi
111 | }
112 |
113 | function install_packages()
114 | {
115 | info "Installing packages..."
116 | sleep 1
117 | apt update
118 | apt install --yes --no-install-recommends \
119 | apache2 \
120 | mariadb-server \
121 | perl \
122 | curl \
123 | jq \
124 | php
125 | info "Installing php extensions..."
126 | apt install --yes --no-install-recommends \
127 | php-ldap \
128 | php-imap \
129 | php-apcu \
130 | php-xmlrpc \
131 | php-cas \
132 | php-mysqli \
133 | php-mbstring \
134 | php-curl \
135 | php-gd \
136 | php-simplexml \
137 | php-xml \
138 | php-intl \
139 | php-zip \
140 | php-bz2
141 | systemctl enable mariadb
142 | systemctl enable apache2
143 | }
144 |
145 | function mariadb_configure()
146 | {
147 | info "Configuring MariaDB..."
148 | sleep 1
149 | SLQROOTPWD=$(openssl rand -base64 48 | cut -c1-12 )
150 | SQLGLPIPWD=$(openssl rand -base64 48 | cut -c1-12 )
151 | systemctl start mariadb
152 | sleep 1
153 |
154 | # Set the root password
155 | mysql -e "UPDATE mysql.user SET Password = PASSWORD('$SLQROOTPWD') WHERE User = 'root'"
156 | # Remove anonymous user accounts
157 | mysql -e "DELETE FROM mysql.user WHERE User = ''"
158 | # Disable remote root login
159 | mysql -e "DELETE FROM mysql.user WHERE User = 'root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')"
160 | # Remove the test database
161 | mysql -e "DROP DATABASE test"
162 | # Reload privileges
163 | mysql -e "FLUSH PRIVILEGES"
164 | # Create a new database
165 | mysql -e "CREATE DATABASE glpi"
166 | # Create a new user
167 | mysql -e "CREATE USER 'glpi_user'@'localhost' IDENTIFIED BY '$SQLGLPIPWD'"
168 | # Grant privileges to the new user for the new database
169 | mysql -e "GRANT ALL PRIVILEGES ON glpi.* TO 'glpi_user'@'localhost'"
170 | # Reload privileges
171 | mysql -e "FLUSH PRIVILEGES"
172 |
173 | # Initialize time zones datas
174 | mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p'$SLQROOTPWD' mysql
175 | #Ask tz
176 | dpkg-reconfigure tzdata
177 | systemctl restart mariadb
178 | sleep 1
179 | mysql -e "GRANT SELECT ON mysql.time_zone_name TO 'glpi_user'@'localhost'"
180 | }
181 |
182 | function install_glpi()
183 | {
184 | info "Downloading and installing the latest version of GLPI..."
185 | # Get download link for the latest release
186 | DOWNLOADLINK=$(curl -s https://api.github.com/repos/glpi-project/glpi/releases/latest | jq -r '.assets[0].browser_download_url')
187 | wget -O /tmp/glpi-latest.tgz $DOWNLOADLINK
188 | tar xzf /tmp/glpi-latest.tgz -C /var/www/html/
189 |
190 | # Add permissions
191 | chown -R www-data:www-data /var/www/html/glpi
192 | chmod -R 775 /var/www/html/glpi
193 |
194 | # Setup vhost
195 | cat > /etc/apache2/sites-available/000-default.conf << EOF
196 |
197 | DocumentRoot /var/www/html/glpi/public
198 |
199 | Require all granted
200 | RewriteEngine On
201 | RewriteCond %{REQUEST_FILENAME} !-f
202 | RewriteRule ^(.*)$ index.php [QSA,L]
203 |
204 |
205 | LogLevel warn
206 | ErrorLog \${APACHE_LOG_DIR}/error-glpi.log
207 | CustomLog \${APACHE_LOG_DIR}/access-glpi.log combined
208 |
209 |
210 | EOF
211 |
212 | #Disable Apache Web Server Signature
213 | echo "ServerSignature Off" >> /etc/apache2/apache2.conf
214 | echo "ServerTokens Prod" >> /etc/apache2/apache2.conf
215 |
216 | # Setup Cron task
217 | echo "*/2 * * * * www-data /usr/bin/php /var/www/html/glpi/front/cron.php &>/dev/null" >> /etc/cron.d/glpi
218 |
219 | #Activation du module rewrite d'apache
220 | a2enmod rewrite && systemctl restart apache2
221 | }
222 |
223 | function setup_db()
224 | {
225 | info "Setting up GLPI..."
226 | cd /var/www/html/glpi
227 | php bin/console db:install --db-name=glpi --db-user=glpi_user --db-password=$SQLGLPIPWD --no-interaction
228 | rm -rf /var/www/html/glpi/install
229 | }
230 |
231 | function display_credentials()
232 | {
233 | info "=======> GLPI installation details <======="
234 | warn "It is important to record this informations. If you lose them, they will be unrecoverable."
235 | info "==> GLPI:"
236 | info "Default user accounts are:"
237 | info "USER - PASSWORD - ACCESS"
238 | info "glpi - glpi - admin account,"
239 | info "tech - tech - technical account,"
240 | info "normal - normal - normal account,"
241 | info "post-only - postonly - post-only account."
242 | echo ""
243 | info "You can connect access GLPI web page from IP or hostname:"
244 | info "http://$IPADRESS or http://$HOST"
245 | echo ""
246 | info "==> Database:"
247 | info "root password: $SLQROOTPWD"
248 | info "glpi_user password: $SQLGLPIPWD"
249 | info "GLPI database name: glpi"
250 | info "<==========================================>"
251 | echo ""
252 | info "If you encounter any issue with this script, please report it on GitHub: https://github.com/jr0w3/GLPI_install_script/issues"
253 | }
254 |
255 |
256 | check_root
257 | check_distro
258 | confirm_installation
259 | network_info
260 | install_packages
261 | mariadb_configure
262 | install_glpi
263 | setup_db
264 | display_credentials
265 |
--------------------------------------------------------------------------------