Skip to content

Commit e90353f

Browse files
authored
Refactor: phpIPAM (#9027)
1 parent 37fc378 commit e90353f

File tree

2 files changed

+24
-36
lines changed

2 files changed

+24
-36
lines changed

ct/phpipam.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,22 @@ function update_script() {
3333
systemctl stop apache2
3434
msg_ok "Stopped Service"
3535

36+
PHP_VERSION="8.4" PHP_APACHE="YES" PHP_FPM="YES" PHP_MODULE="mysql,gmp,snmp,ldap,apcu" setup_php
37+
38+
msg_info "Installing PHP-PEAR"
39+
$STD apt install -y \
40+
php-pear \
41+
php-dev
42+
msg_ok "Installed PHP-PEAR"
43+
3644
mv /opt/phpipam/ /opt/phpipam-backup
37-
fetch_and_deploy_gh_release "phpipam" "phpipam/phpipam" "prebuild" "latest" "/opt/phpipam" "phpipam-v*.zip"
45+
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "phpipam" "phpipam/phpipam" "prebuild" "latest" "/opt/phpipam" "phpipam-v*.zip"
3846
cp /opt/phpipam-backup/config.php /opt/phpipam
47+
rm -r /opt/phpipam-backup
3948

4049
msg_info "Starting Service"
4150
systemctl start apache2
4251
msg_ok "Started Service"
43-
44-
msg_info "Cleaning up"
45-
rm -r /opt/phpipam-backup
46-
msg_ok "Cleaned"
4752
msg_ok "Updated successfully!"
4853
fi
4954
exit

install/phpipam-install.sh

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,27 @@ setting_up_container
1313
network_check
1414
update_os
1515

16-
msg_info "Installing Dependencies"
17-
$STD apt install -y php-pear
18-
msg_ok "Installed Dependencies"
16+
PHP_VERSION="8.4" PHP_APACHE="YES" PHP_FPM="YES" PHP_MODULE="mysql,gmp,snmp,ldap,apcu" setup_php
1917

20-
PHP_VERSION="8.2" PHP_APACHE="YES" PHP_FPM="YES" PHP_MODULE="mysql,imap,apcu,pspell,tidy,xmlrpc,gmp,ldap,common,snmp" setup_php
21-
setup_mariadb
22-
23-
msg_info "Setting up MariaDB"
24-
DB_NAME=phpipam
25-
DB_USER=phpipam
26-
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
27-
$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;"
28-
$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
29-
$STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
30-
{
31-
echo "phpIPAM-Credentials"
32-
echo "phpIPAM Database User: $DB_USER"
33-
echo "phpIPAM Database Password: $DB_PASS"
34-
echo "phpIPAM Database Name: $DB_NAME"
35-
} >>~/phpipam.creds
36-
msg_ok "Set up MariaDB"
18+
msg_info "Installing PHP-PEAR"
19+
$STD apt install -y \
20+
php-pear \
21+
php-dev
22+
msg_ok "Installed PHP-PEAR"
3723

24+
setup_mariadb
25+
MARIADB_DB_NAME="phpipam" MARIADB_DB_USER="phpipam" setup_mariadb_db
3826
fetch_and_deploy_gh_release "phpipam" "phpipam/phpipam" "prebuild" "latest" "/opt/phpipam" "phpipam-v*.zip"
3927

4028
msg_info "Installing phpIPAM"
41-
$STD mariadb -u root "${DB_NAME}" </opt/phpipam/db/SCHEMA.sql
29+
$STD mariadb -u root "${MARIADB_DB_NAME}" </opt/phpipam/db/SCHEMA.sql
4230
cp /opt/phpipam/config.dist.php /opt/phpipam/config.php
4331
sed -i -e "s/\(\$disable_installer = \).*/\1true;/" \
44-
-e "s/\(\$db\['user'\] = \).*/\1'$DB_USER';/" \
45-
-e "s/\(\$db\['pass'\] = \).*/\1'$DB_PASS';/" \
46-
-e "s/\(\$db\['name'\] = \).*/\1'$DB_NAME';/" \
32+
-e "s/\(\$db\['user'\] = \).*/\1'$MARIADB_DB_USER';/" \
33+
-e "s/\(\$db\['pass'\] = \).*/\1'$MARIADB_DB_PASS';/" \
34+
-e "s/\(\$db\['name'\] = \).*/\1'$MARIADB_DB_NAME';/" \
4735
/opt/phpipam/config.php
48-
sed -i '/max_execution_time/s/= .*/= 600/' /etc/php/8.2/apache2/php.ini
36+
sed -i '/max_execution_time/s/= .*/= 600/' /etc/php/8.4/apache2/php.ini
4937
msg_ok "Installed phpIPAM"
5038

5139
msg_info "Creating Service"
@@ -71,9 +59,4 @@ msg_ok "Created Service"
7159

7260
motd_ssh
7361
customize
74-
75-
msg_info "Cleaning up"
76-
$STD apt -y autoremove
77-
$STD apt -y autoclean
78-
$STD apt -y clean
79-
msg_ok "Cleaned"
62+
cleanup_lxc

0 commit comments

Comments
 (0)