1+ #! /usr/bin/env bash
2+
3+ # Copyright (c) 2021-2025 community-scripts ORG
4+ # Author: bvdberg01
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+ sudo \
19+ mc \
20+ mariadb-server \
21+ apache2 \
22+ php8.2-{pdo,mysql,sockets,gmp,ldap,simplexml,json,cli,mbstring,pear,gd,curl}
23+ msg_ok " Installed Dependencies"
24+
25+ msg_info " Setting up MariaDB"
26+ DB_NAME=phpipam
27+ DB_USER=phpipam
28+ DB_PASS=$( openssl rand -base64 18 | tr -dc ' a-zA-Z0-9' | head -c13)
29+ $STD mysql -u root -e " CREATE DATABASE $DB_NAME ;"
30+ $STD mysql -u root -e " CREATE USER '$DB_USER '@'localhost' IDENTIFIED WITH mysql_native_password AS PASSWORD('$DB_PASS ');"
31+ $STD mysql -u root -e " GRANT ALL ON $DB_NAME .* TO '$DB_USER '@'localhost'; FLUSH PRIVILEGES;"
32+ {
33+ echo " phpIPAM-Credentials"
34+ echo " phpIPAM Database User: $DB_USER "
35+ echo " phpIPAM Database Password: $DB_PASS "
36+ echo " phpIPAM Database Name: $DB_NAME "
37+ } >> ~ /phpipam.creds
38+ msg_ok " Set up MariaDB"
39+
40+ msg_info " Installing phpIPAM"
41+ RELEASE=$( curl -s https://api.github.com/repos/phpipam/phpipam/releases/latest | grep " tag_name" | awk ' {print substr($2, 3, length($2)-4) }' )
42+ cd /opt
43+ wget -q " https://github.com/phpipam/phpipam/releases/download/v${RELEASE} /phpipam-v${RELEASE} .zip"
44+ unzip -q " phpipam-v${RELEASE} .zip"
45+ mysql -u root " ${DB_NAME} " < /opt/phpipam/db/SCHEMA.sql
46+ cp /opt/phpipam/config.dist.php /opt/phpipam/config.php
47+ sed -i -e " s/\(\$ disable_installer = \).*/\1true;/" \
48+ -e " s/\(\$ db\['user'\] = \).*/\1'$DB_USER ';/" \
49+ -e " s/\(\$ db\['pass'\] = \).*/\1'$DB_PASS ';/" \
50+ -e " s/\(\$ db\['name'\] = \).*/\1'$DB_NAME ';/" \
51+ /opt/phpipam/config.php
52+ sed -i ' /max_execution_time/s/= .*/= 600/' /etc/php/8.2/apache2/php.ini
53+ echo " ${RELEASE} " > /opt/${APPLICATION} _version.txt
54+ msg_ok " Installed phpIPAM"
55+
56+ msg_info " Creating Service"
57+ cat << EOF >/etc/apache2/sites-available/phpipam.conf
58+ <VirtualHost *:80>
59+ ServerName phpipam
60+ DocumentRoot /opt/phpipam
61+ <Directory /opt/phpipam>
62+ Options FollowSymLinks
63+ AllowOverride All
64+ Require all granted
65+ </Directory>
66+
67+ ErrorLog /var/log/apache2/phpipam_error.log
68+ CustomLog /var/log/apache2/phpipam_access.log combined
69+ </VirtualHost>
70+ EOF
71+ $STD a2ensite phpipam
72+ $STD a2enmod rewrite
73+ $STD a2dissite 000-default.conf
74+ $STD systemctl reload apache2
75+ msg_ok " Created Service"
76+
77+ motd_ssh
78+ customize
79+
80+ msg_info " Cleaning up"
81+ rm -rf " /opt/phpipam-v${RELEASE} .zip"
82+ $STD apt-get -y autoremove
83+ $STD apt-get -y autoclean
84+ msg_ok " Cleaned"
0 commit comments