Remove commercial modules & add verbose install

- Added option to remove commercial modules
- Added option to update system and modules
This commit is contained in:
Javier Pastor 2025-07-27 20:11:55 +02:00
parent 2e312c4d2b
commit 3e4541df00
4 changed files with 228 additions and 10 deletions

67
ct/freepbx.sh Normal file
View File

@ -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}"

View File

@ -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"
}
]
}

111
install/freepbx-install.sh Normal file
View File

@ -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"

View File

@ -16,14 +16,14 @@ variables() {
CT_TYPE=${var_unprivileged:-$CT_TYPE} 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 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 load_functions
#echo "(build.func) Loaded core.func via curl" #echo "(build.func) Loaded core.func via curl"
elif command -v wget >/dev/null 2>&1; then 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 load_functions
#echo "(build.func) Loaded core.func via wget" #echo "(build.func) Loaded core.func via wget"
fi fi
@ -986,7 +986,7 @@ install_script() {
header_info header_info
echo -e "${INFO}${HOLD} ${GN}Using Config File on node $PVEHOST_NAME${CL}" echo -e "${INFO}${HOLD} ${GN}Using Config File on node $PVEHOST_NAME${CL}"
METHOD="advanced" 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 config_file
;; ;;
5) 5)
@ -1059,7 +1059,7 @@ check_container_storage() {
} }
start() { 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 if command -v pveversion >/dev/null 2>&1; then
install_script install_script
elif [ ! -z ${PHS_SILENT+x} ] && [[ "${PHS_SILENT}" == "1" ]]; then elif [ ! -z ${PHS_SILENT+x} ] && [[ "${PHS_SILENT}" == "1" ]]; then
@ -1125,9 +1125,9 @@ build_container() {
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd "$TEMP_DIR" >/dev/null pushd "$TEMP_DIR" >/dev/null
if [ "$var_os" == "alpine" ]; then 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 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 fi
export DIAGNOSTICS="$DIAGNOSTICS" export DIAGNOSTICS="$DIAGNOSTICS"
export RANDOM_UUID="$RANDOM_UUID" export RANDOM_UUID="$RANDOM_UUID"
@ -1161,7 +1161,7 @@ build_container() {
-unprivileged $CT_TYPE -unprivileged $CT_TYPE
$PW $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 if [ $? -ne 0 ]; then
exit 200 exit 200
fi fi
@ -1351,7 +1351,7 @@ EOF'
fi fi
msg_ok "Customized LXC Container" 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 $? exit $?
fi fi
} }
@ -1365,7 +1365,7 @@ description() {
cat <<EOF cat <<EOF
<div align='center'> <div align='center'>
<a href='https://Helper-Scripts.com' target='_blank' rel='noopener noreferrer'> <a href='https://Helper-Scripts.com' target='_blank' rel='noopener noreferrer'>
<img src='https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/images/logo-81x112.png' alt='Logo' style='width:81px;height:112px;'/> <img src='https://raw.githubusercontent.com/vsc55/community-scripts-ProxmoxVED/refs/heads/freepbx/misc/images/logo-81x112.png' alt='Logo' style='width:81px;height:112px;'/>
</a> </a>
<h2 style='font-size: 24px; margin: 20px 0;'>${APP} LXC</h2> <h2 style='font-size: 24px; margin: 20px 0;'>${APP} LXC</h2>