From 3e4541df00ea7cd871a2fa0267616695f484c600 Mon Sep 17 00:00:00 2001 From: Javier Pastor Date: Sun, 27 Jul 2025 20:11:55 +0200 Subject: [PATCH] Remove commercial modules & add verbose install - Added option to remove commercial modules - Added option to update system and modules --- ct/freepbx.sh | 67 ++++++++++++++++++ frontend/public/json/freepbx.json | 40 +++++++++++ install/freepbx-install.sh | 111 ++++++++++++++++++++++++++++++ misc/build.func | 20 +++--- 4 files changed, 228 insertions(+), 10 deletions(-) create mode 100644 ct/freepbx.sh create mode 100644 frontend/public/json/freepbx.json create mode 100644 install/freepbx-install.sh diff --git a/ct/freepbx.sh b/ct/freepbx.sh new file mode 100644 index 00000000..d7526bcd --- /dev/null +++ b/ct/freepbx.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/vsc55/community-scripts-ProxmoxVED/refs/heads/freepbx/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: Arian Nasr (arian-nasr) +# Updated by: Javier Pastor (vsc55) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://www.freepbx.org/ + +APP="FreePBX" +var_tags="pbx;voip;telephony" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-10}" +var_os="${var_os:-debian}" +var_version="${var_version:-12}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -f /lib/systemd/system/freepbx.service ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + msg_info "Updating $APP LXC" + $STD apt-get update + $STD apt-get -y upgrade + msg_ok "Updated $APP LXC" + + msg_info "Updating $APP Modules" + $STD fwconsole ma updateall + $STD fwconsole reload + msg_ok "Updated $APP Modules" + + exit +} + +start + +if whiptail --title "Commercial Modules" --yesno "Remove Commercial modules?" --defaultno 10 50; then + export ONLY_OPENSOURCE="yes" + + if whiptail --title "Firewall Module" --yesno "Do you want to KEEP the Firewall module (and sysadmin)?" 10 50; then + export REMOVE_FIREWALL="no" + else + export REMOVE_FIREWALL="yes" + fi +else + export ONLY_OPENSOURCE="no" + export REMOVE_FIREWALL="no" +fi + +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}" diff --git a/frontend/public/json/freepbx.json b/frontend/public/json/freepbx.json new file mode 100644 index 00000000..11040c04 --- /dev/null +++ b/frontend/public/json/freepbx.json @@ -0,0 +1,40 @@ +{ + "name": "FreePBX", + "slug": "freepbx", + "categories": [ + 0 + ], + "date_created": "2025-05-22", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 80, + "documentation": "https://sangomakb.atlassian.net/wiki/spaces/FP/overview?homepageId=8454359", + "website": "https://www.freepbx.org/", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/freepbx.webp", + "config_path": "", + "description": "FreePBX is a web-based open-source graphical user interface that manages Asterisk, a voice over IP and telephony server.", + "install_methods": [ + { + "type": "default", + "script": "ct/freepbx.sh", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 10, + "os": "debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [ + { + "text": "This script uses the official FreePBX install script. Check it here: https://github.com/FreePBX/sng_freepbx_debian_install", + "type": "info" + } + ] +} diff --git a/install/freepbx-install.sh b/install/freepbx-install.sh new file mode 100644 index 00000000..c5da1138 --- /dev/null +++ b/install/freepbx-install.sh @@ -0,0 +1,111 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: Arian Nasr (arian-nasr) +# Updated by: Javier Pastor (vsc55) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://www.freepbx.org/ + +INSTALL_URL="https://github.com/FreePBX/sng_freepbx_debian_install/raw/master/sng_freepbx_debian_install.sh" +INSTALL_PATH="/opt/sng_freepbx_debian_install.sh" + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +ONLY_OPENSOURCE="${ONLY_OPENSOURCE:-no}" +REMOVE_FIREWALL="${REMOVE_FIREWALL:-no}" +msg_ok "Remove Commercial modules is set to: $ONLY_OPENSOURCE" +msg_ok "Remove Firewall module is set to: $REMOVE_FIREWALL" + +msg_info "Downloading FreePBX installation script..." +if curl -fsSL "$INSTALL_URL" -o "$INSTALL_PATH"; then + msg_ok "Download completed successfully" +else + curl_exit_code=$? + msg_error "Error downloading FreePBX installation script (curl exit code: $curl_exit_code)" + msg_error "Aborting!" + exit 1 +fi + +if [[ "$VERBOSE" == "yes" ]]; then + msg_info "Installing FreePBX (Verbose)\n" +else + msg_info "Installing FreePBX, be patient, this takes time..." +fi +$STD bash "$INSTALL_PATH" + +if [[ $ONLY_OPENSOURCE == "yes" ]]; then + msg_info "Removing Commercial modules..." + + end_count=0 + max=5 + count=0 + while fwconsole ma list | awk '/Commercial/ {found=1} END {exit !found}'; do + count=$((count + 1)) + while read -r module; do + msg_info "Removing module: $module" + + if [[ "$REMOVE_FIREWALL" == "no" ]] && [[ "$module" == "sysadmin" ]]; then + msg_warn "Skipping sysadmin module removal, it is required for Firewall!" + continue + fi + + code=0 + $STD fwconsole ma -f remove $module || code=$? + if [[ $code -ne 0 ]]; then + msg_error "Module $module could not be removed - error code $code" + else + msg_ok "Module $module removed successfully" + fi + done < <(fwconsole ma list | awk '/Commercial/ {print $2}') + + [[ $count -ge $max ]] && break + + com_list=$(fwconsole ma list) + end_count=$(awk '/Commercial/ {count++} END {print count + 0}' <<< "$com_list") + awk '/Commercial/ {found=1} END {exit !found}' <<< "$com_list" || break + if [[ "$REMOVE_FIREWALL" == "no" ]] && \ + [[ $end_count -eq 1 ]] && \ + [[ $(awk '/Commercial/ {print $2}' <<< "$com_list") == "sysadmin" ]]; then + break + fi + + msg_warn "Not all commercial modules could be removed, retrying (attempt $count of $max)..." + done + + if [[ $REMOVE_FIREWALL == "yes" ]] && [[ $end_count -gt 0 ]]; then + msg_info "Removing Firewall module..." + if $STD fwconsole ma -f remove firewall; then + msg_ok "Firewall module removed successfully" + else + msg_error "Firewall module could not be removed, please check manually!" + fi + fi + + if [[ $end_count -eq 0 ]]; then + msg_ok "All commercial modules removed successfully" + elif [[ $end_count -eq 1 ]] && [[ $REMOVE_FIREWALL == "no" ]] && [[ $(fwconsole ma list | awk '/Commercial/ {print $2}') == "sysadmin" ]]; then + msg_ok "Only sysadmin module left, which is required for Firewall, skipping removal" + else + msg_warn "Some commercial modules could not be removed, please check the web interface for removal manually!" + fi + + msg_info "Reloading FreePBX..." + $STD fwconsole reload + msg_ok "FreePBX reloaded completely" +fi +msg_ok "Installed FreePBX finished" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -f "$INSTALL_PATH" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/misc/build.func b/misc/build.func index c8b1ff4b..0364736f 100644 --- a/misc/build.func +++ b/misc/build.func @@ -16,14 +16,14 @@ variables() { CT_TYPE=${var_unprivileged:-$CT_TYPE} } -source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/api.func) +source <(curl -fsSL https://raw.githubusercontent.com/vsc55/community-scripts-ProxmoxVED/refs/heads/freepbx/misc/api.func) if command -v curl >/dev/null 2>&1; then - source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/core.func) + source <(curl -fsSL https://raw.githubusercontent.com/vsc55/community-scripts-ProxmoxVED/refs/heads/freepbx/misc/core.func) load_functions #echo "(build.func) Loaded core.func via curl" elif command -v wget >/dev/null 2>&1; then - source <(wget -qO- https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/core.func) + source <(wget -qO- https://raw.githubusercontent.com/vsc55/community-scripts-ProxmoxVED/refs/heads/freepbx/misc/core.func) load_functions #echo "(build.func) Loaded core.func via wget" fi @@ -986,7 +986,7 @@ install_script() { header_info echo -e "${INFO}${HOLD} ${GN}Using Config File on node $PVEHOST_NAME${CL}" METHOD="advanced" - source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/config-file.func) + source <(curl -fsSL https://raw.githubusercontent.com/vsc55/community-scripts-ProxmoxVED/refs/heads/freepbx/misc/config-file.func) config_file ;; 5) @@ -1059,7 +1059,7 @@ check_container_storage() { } start() { - source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/tools.func) + source <(curl -fsSL https://raw.githubusercontent.com/vsc55/community-scripts-ProxmoxVED/refs/heads/freepbx/misc/tools.func) if command -v pveversion >/dev/null 2>&1; then install_script elif [ ! -z ${PHS_SILENT+x} ] && [[ "${PHS_SILENT}" == "1" ]]; then @@ -1125,9 +1125,9 @@ build_container() { TEMP_DIR=$(mktemp -d) pushd "$TEMP_DIR" >/dev/null if [ "$var_os" == "alpine" ]; then - export FUNCTIONS_FILE_PATH="$(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/alpine-install.func)" + export FUNCTIONS_FILE_PATH="$(curl -fsSL https://raw.githubusercontent.com/vsc55/community-scripts-ProxmoxVED/refs/heads/freepbx/misc/alpine-install.func)" else - export FUNCTIONS_FILE_PATH="$(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/install.func)" + export FUNCTIONS_FILE_PATH="$(curl -fsSL https://raw.githubusercontent.com/vsc55/community-scripts-ProxmoxVED/refs/heads/freepbx/misc/install.func)" fi export DIAGNOSTICS="$DIAGNOSTICS" export RANDOM_UUID="$RANDOM_UUID" @@ -1161,7 +1161,7 @@ build_container() { -unprivileged $CT_TYPE $PW " - bash -c "$(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/create_lxc.sh)" + bash -c "$(curl -fsSL https://raw.githubusercontent.com/vsc55/community-scripts-ProxmoxVED/refs/heads/freepbx/misc/create_lxc.sh)" if [ $? -ne 0 ]; then exit 200 fi @@ -1351,7 +1351,7 @@ EOF' fi msg_ok "Customized LXC Container" - if ! lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/install/"$var_install".sh)"; then + if ! lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/vsc55/community-scripts-ProxmoxVED/refs/heads/freepbx/install/"$var_install".sh)"; then exit $? fi } @@ -1365,7 +1365,7 @@ description() { cat < - Logo + Logo

${APP} LXC