Skip to content

Commit c45085a

Browse files
bvdberg01MickLesk
andauthored
New script: phpIPAM (#1503)
* Added phpipam * PR feedback * fix json * Fix php version --------- Co-authored-by: CanbiZ <[email protected]>
1 parent 959a7b4 commit c45085a

File tree

3 files changed

+190
-0
lines changed

3 files changed

+190
-0
lines changed

ct/phpipam.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env bash
2+
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: bvdberg01
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://phpipam.net/
7+
8+
# App Default Values
9+
APP="phpIPAM"
10+
var_tags="network"
11+
var_cpu="1"
12+
var_ram="512"
13+
var_disk="4"
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+
if [[ ! -d /opt/phpipam ]]; then
32+
msg_error "No ${APP} Installation Found!"
33+
exit
34+
fi
35+
RELEASE=$(curl -s https://api.github.com/repos/phpipam/phpipam/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
36+
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
37+
msg_info "Stopping Service"
38+
systemctl stop apache2
39+
msg_ok "Stopped Service"
40+
41+
msg_info "Updating ${APP} to v${RELEASE}"
42+
cd /opt
43+
mv /opt/phpipam/ /opt/phpipam-backup
44+
wget -q "https://github.com/phpipam/phpipam/releases/download/v${RELEASE}/phpipam-v${RELEASE}.zip"
45+
unzip -q "phpipam-v${RELEASE}.zip"
46+
cp /opt/phpipam-backup/config.php /opt/phpipam
47+
echo "${RELEASE}" >/opt/${APP}_version.txt
48+
msg_ok "Updated $APP to v${RELEASE}"
49+
50+
msg_info "Starting Service"
51+
systemctl start apache2
52+
msg_ok "Started Service"
53+
54+
msg_info "Cleaning up"
55+
rm -r "/opt/phpipam-v${RELEASE}.zip"
56+
rm -r /opt/phpipam-backup
57+
msg_ok "Cleaned"
58+
msg_ok "Updated Successfully"
59+
else
60+
msg_ok "No update required. ${APP} is already at v${RELEASE}"
61+
fi
62+
exit
63+
}
64+
65+
start
66+
build_container
67+
description
68+
69+
msg_ok "Completed Successfully!\n"
70+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
71+
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
72+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}"

install/phpipam-install.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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"

json/phpipam.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "phpIPAM",
3+
"slug": "phpipam",
4+
"categories": [
5+
11
6+
],
7+
"date_created": "2025-01-15",
8+
"type": "ct",
9+
"updateable": true,
10+
"privileged": false,
11+
"interface_port": 80,
12+
"documentation": "https://phpipam.net/documents/all-documents/",
13+
"website": "https://phpipam.net/",
14+
"logo": "https://phpipam.net/css/images/[email protected]",
15+
"description": "phpipam is an open-source web IP address management application (IPAM). Its goal is to provide light, modern and useful IP address management.",
16+
"install_methods": [
17+
{
18+
"type": "default",
19+
"script": "ct/phpipam.sh",
20+
"resources": {
21+
"cpu": 1,
22+
"ram": 1024,
23+
"hdd": 4,
24+
"os": "debian",
25+
"version": "12"
26+
}
27+
}
28+
],
29+
"default_credentials": {
30+
"username": "Admin",
31+
"password": "ipamadmin"
32+
},
33+
"notes": []
34+
}

0 commit comments

Comments
 (0)