From e72f24891832be4acec81a697bb2a45456c50cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Fri, 22 Aug 2025 20:17:32 +0200 Subject: [PATCH] Refactor (#7095) --- ct/phpipam.sh | 12 ++++-------- install/phpipam-install.sh | 15 ++++----------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/ct/phpipam.sh b/ct/phpipam.sh index d5211799a..b6209b894 100644 --- a/ct/phpipam.sh +++ b/ct/phpipam.sh @@ -27,29 +27,25 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi + RELEASE=$(curl -fsSL https://api.github.com/repos/phpipam/phpipam/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') - if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + if [[ ! -f ~/.phpipam ]] || [[ "${RELEASE}" != "$(cat ~/.phpipam 2>/dev/null)" ]]; then msg_info "Stopping Service" systemctl stop apache2 msg_ok "Stopped Service" - msg_info "Updating ${APP} to v${RELEASE}" - cd /opt mv /opt/phpipam/ /opt/phpipam-backup - curl -fsSL "https://github.com/phpipam/phpipam/releases/download/v${RELEASE}/phpipam-v${RELEASE}.zip" -o $(basename "https://github.com/phpipam/phpipam/releases/download/v${RELEASE}/phpipam-v${RELEASE}.zip") - $STD unzip "phpipam-v${RELEASE}.zip" + fetch_and_deploy_gh_release "phpipam" "phpipam/phpipam" "prebuild" "latest" "/opt/phpipam" "phpipam-v*.zip" cp /opt/phpipam-backup/config.php /opt/phpipam - echo "${RELEASE}" >/opt/${APP}_version.txt - msg_ok "Updated $APP to v${RELEASE}" msg_info "Starting Service" systemctl start apache2 msg_ok "Started Service" msg_info "Cleaning up" - rm -r "/opt/phpipam-v${RELEASE}.zip" rm -r /opt/phpipam-backup msg_ok "Cleaned" + msg_ok "Updated Successfully" else msg_ok "No update required. ${APP} is already at v${RELEASE}" diff --git a/install/phpipam-install.sh b/install/phpipam-install.sh index 115a52649..cfed7a3d7 100644 --- a/install/phpipam-install.sh +++ b/install/phpipam-install.sh @@ -14,13 +14,10 @@ network_check update_os msg_info "Installing Dependencies" -$STD apt-get install -y \ - apache2 \ - libapache2-mod-php \ - php8.2 php8.2-{fpm,curl,cli,mysql,gd,intl,imap,apcu,pspell,tidy,xmlrpc,mbstring,gmp,xml,ldap,common,snmp} \ - php-pear +$STD apt-get install -y php-pear msg_ok "Installed Dependencies" +PHP_VERSION="8.2" PHP_APACHE="YES" PHP_FPM="YES" PHP_MODULE="mysql,imap,apcu,pspell,tidy,xmlrpc,gmp,ldap,common,snmp" setup_php setup_mariadb msg_info "Setting up MariaDB" @@ -38,11 +35,9 @@ $STD mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUS } >>~/phpipam.creds msg_ok "Set up MariaDB" +fetch_and_deploy_gh_release "phpipam" "phpipam/phpipam" "prebuild" "latest" "/opt/phpipam" "phpipam-v*.zip" + msg_info "Installing phpIPAM" -RELEASE=$(curl -fsSL https://api.github.com/repos/phpipam/phpipam/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') -cd /opt -curl -fsSL "https://github.com/phpipam/phpipam/releases/download/v${RELEASE}/phpipam-v${RELEASE}.zip" -o "phpipam-v${RELEASE}.zip" -$STD unzip "phpipam-v${RELEASE}.zip" $STD mariadb -u root "${DB_NAME}" /opt/${APPLICATION}_version.txt msg_ok "Installed phpIPAM" msg_info "Creating Service" @@ -79,7 +73,6 @@ motd_ssh customize msg_info "Cleaning up" -rm -rf "/opt/phpipam-v${RELEASE}.zip" $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned"