4 Commits

Author SHA1 Message Date
0321a27fdc change file permissions 2026-04-06 19:03:07 -04:00
61a873dda1 optimize configure.sh 2026-04-06 18:53:07 -04:00
360b9ca28d update prompt architecture to add install sections. 2026-04-06 18:34:13 -04:00
69d548b0d4 add test collection for debian 2026-04-06 13:51:31 -04:00
8 changed files with 421 additions and 107 deletions

312
debian/configure.sh vendored Normal file
View File

@@ -0,0 +1,312 @@
#!/bin/sh
# configure.sh - Interactively collect variables and write resources/config.sh
# Drop this file alongside install.sh in the debian/ (or ubuntu/, devuan/, etc.) directory.
# It is sourced/called by install.sh BEFORE resources/config.sh is sourced.
#
# Usage (standalone): ./configure.sh
# Usage (from install): . ./configure.sh
cd "$(dirname "$0")" 2>/dev/null || true
CONFIG_FILE="./resources/config.sh"
_CREDS_FILE="/root/.git-credentials"
# ===========================================================================
# Defaults — every variable is pre-populated so sections with no
# customization need no else branch at all.
# ===========================================================================
domain_name=ip_address ; system_username=admin
system_password=random ; system_branch=5.5
php_version=8.2 ; letsencrypt_folder=true
switch_branch=stable ; switch_source=true
switch_package=false ; switch_version=1.10.12
switch_tls=true ; switch_token=
sofia_version=1.13.17
database_name=fusionpbx ; database_username=fusionpbx
database_password=random ; database_repo=official
database_version=18 ; database_host=127.0.0.1
database_port=5432 ; database_backup=false
application_transcribe=true ; application_speech=true
application_language_model=true ; application_device_logs=true
application_dialplan_tools=false; application_edit=false
application_sip_trunks=false
_git_credentials_written=false
# ===========================================================================
# Helpers
# ===========================================================================
# ask <var> <prompt> <default>
ask() {
printf "%s [%s]: " "$2" "$3"
read -r _input </dev/tty
eval "${1}=\"${_input:-$3}\""
}
# ask_secret <var> <prompt> — no echo
ask_secret() {
if stty -echo 2>/dev/null; then
printf "%s: " "$2"
read -r _input </dev/tty
stty echo; echo ""
else
printf "%s (input visible): " "$2"
read -r _input </dev/tty
fi
eval "${1}=\"${_input}\""
}
# ask_yn <prompt> <default y|n> — returns 0=yes 1=no
ask_yn() {
while true; do
printf "%s (y/n) [%s]: " "$1" "$2"
read -r _input </dev/tty
case "${_input:-$2}" in
y|Y|yes|YES) return 0 ;;
n|N|no|NO) return 1 ;;
*) echo " Please enter y or n." ;;
esac
done
}
# ask_bool <var> <prompt> <default true|false> — wraps ask_yn
ask_bool() {
_yn=$([ "$3" = "true" ] && echo "y" || echo "n")
if ask_yn "$2" "$_yn"; then eval "${1}=true"
else eval "${1}=false"
fi
}
# write_git_credentials <server>
write_git_credentials() {
_srv="$1"
ask _git_username "Git username or email" ""
[ -z "$_git_username" ] && { echo " No username entered — skipping."; return; }
ask_secret _git_password "Git password or personal access token"
# URL-encode characters that break the credentials file URL format
_enc_u=$(printf '%s' "$_git_username" | sed 's/%/%25/g;s/ /%20/g;s/:/%3A/g;s/@/%40/g')
_enc_p=$(printf '%s' "$_git_password" | sed 's/%/%25/g;s/ /%20/g;s/:/%3A/g;s/@/%40/g')
# Remove any pre-existing entry for this server, then append
[ -f "$_CREDS_FILE" ] && sed -i "/@${_srv}/d" "$_CREDS_FILE"
printf 'https://%s:%s@%s\n' "$_enc_u" "$_enc_p" "$_srv" >> "$_CREDS_FILE"
chmod 600 "$_CREDS_FILE"
_git_credentials_written=true
echo " Credentials written to $_CREDS_FILE"
unset _git_password _enc_p _git_username _enc_u
}
# ===========================================================================
echo ""
echo "============================================================"
echo " FusionPBX Installer - Configuration Setup"
echo " Values will be written to: $CONFIG_FILE"
echo " Press ENTER to accept the default shown in [brackets]."
echo "============================================================"
echo ""
# ===========================================================================
# SECTION 1 — Basic Settings
# ===========================================================================
echo "------------------------------------------------------------"
echo " Basic Settings"
echo "------------------------------------------------------------"
if ask_yn "Customize basic settings" "y"; then
echo ""
ask domain_name "Domain name (hostname, ip_address, or custom)" "ip_address"
ask system_username "FusionPBX admin username" "admin"
ask system_password "FusionPBX admin password (random = auto)" "random"
ask system_branch "FusionPBX branch (master, 5.5)" "5.5"
ask php_version "PHP version (8.3, 8.2, 8.1)" "8.2"
ask_bool letsencrypt_folder "Create Let's Encrypt folder structure" "true"
echo ""
else
echo " Using defaults."; echo ""
fi
# ===========================================================================
# SECTION 2 — Advanced Install Settings
# ===========================================================================
echo "------------------------------------------------------------"
echo " Advanced Install Settings (FreeSWITCH / Sofia-Sip / Database)"
echo "------------------------------------------------------------"
if ask_yn "Customize advanced settings" "n"; then
echo ""
echo " -- FreeSWITCH --"
ask switch_branch " Branch (master, stable)" "stable"
ask_bool switch_source " Compile from source" "true"
ask_bool switch_package " Install from binary package" "false"
ask switch_version " Source version (source builds only)" "1.10.12"
ask_bool switch_tls " Enable TLS" "true"
ask switch_token " SignalWire auth token (blank if none)" ""
echo ""
echo " -- Sofia-Sip --"
ask sofia_version " Release version" "1.13.17"
echo ""
echo " -- Database --"
ask database_name " Database name" "fusionpbx"
ask database_username " Database username" "fusionpbx"
ask database_password " Database password (random = auto)" "random"
ask database_repo " PostgreSQL repo (official, system)" "official"
ask database_version " PostgreSQL version" "18"
ask database_host " Database host" "127.0.0.1"
ask database_port " Database port" "5432"
ask_bool database_backup " Enable database backup" "false"
echo ""
else
echo " Using defaults."; echo ""
fi
# ===========================================================================
# SECTION 3 — Additional Applications
# ===========================================================================
echo "------------------------------------------------------------"
echo " Additional Applications"
echo "------------------------------------------------------------"
if ask_yn "Customize additional applications" "y"; then
echo ""
ask_bool application_transcribe "Install Speech-to-Text (transcribe)" "true"
ask_bool application_speech "Install Text-to-Speech" "true"
ask_bool application_language_model "Install Language Model" "true"
ask_bool application_device_logs "Log device provision requests" "true"
ask_bool application_dialplan_tools "Install additional dialplan applications" "false"
ask_bool application_edit "Install XML/Script/PHP editor" "false"
ask_bool application_sip_trunks "Install registration-based SIP trunks" "false"
echo ""
else
echo " Using defaults."; echo ""
fi
# ===========================================================================
# SECTION 4 — Git Credentials
# ===========================================================================
_git_server=$(grep 'git clone' ./resources/fusionpbx.sh \
| grep -o 'https://[^/]*' | sed 's|https://||' | head -1)
echo "------------------------------------------------------------"
echo " Git Credentials"
echo "------------------------------------------------------------"
echo " Server detected: ${_git_server:-<not found>}"
if ask_yn "Configure git credentials" "y"; then
echo ""
write_git_credentials "$_git_server"
echo ""
else
echo " Skipping."; echo ""
fi
# ===========================================================================
# SUMMARY
# ===========================================================================
cat <<EOF
============================================================
Configuration Summary
============================================================
Basic Settings
domain_name = $domain_name
system_username = $system_username
system_password = $system_password
system_branch = $system_branch
php_version = $php_version
letsencrypt_folder = $letsencrypt_folder
Advanced Settings (FreeSWITCH / Sofia-Sip / Database)
switch_branch = $switch_branch
switch_source = $switch_source
switch_package = $switch_package
switch_version = $switch_version
switch_tls = $switch_tls
switch_token = ${switch_token:-<not set>}
sofia_version = $sofia_version
database_name = $database_name
database_username = $database_username
database_password = $database_password
database_repo = $database_repo
database_version = $database_version
database_host = $database_host
database_port = $database_port
database_backup = $database_backup
Additional Applications
transcribe = $application_transcribe
speech = $application_speech
language_model = $application_language_model
device_logs = $application_device_logs
dialplan_tools = $application_dialplan_tools
edit = $application_edit
sip_trunks = $application_sip_trunks
Git Credentials
git_server = ${_git_server:-<not detected>}
credentials written = $_git_credentials_written
============================================================
EOF
if ! ask_yn "Continue with installation using these settings" "y"; then
echo ""
echo "Installation cancelled. No changes have been made."
echo ""
exit 1
fi
echo ""
# ===========================================================================
# Write config.sh
# ===========================================================================
cat > "$CONFIG_FILE" <<EOF
#!/bin/sh
# FusionPBX Settings
domain_name=${domain_name} # hostname, ip_address or a custom value
system_username=${system_username} # default username admin
system_password=${system_password} # random or a custom value
system_branch=${system_branch} # master, 5.5
# FreeSWITCH Settings
switch_branch=${switch_branch} # master, stable
switch_source=${switch_source} # true (source compile) or false (binary package)
switch_package=${switch_package} # true (binary package) or false (source compile)
switch_version=${switch_version} # which source code to download, only for source
switch_tls=${switch_tls} # true or false
switch_token=${switch_token} # Get the auth token from https://signalwire.com
# Signup or Login -> Profile -> Personal Auth Token
# Sofia-Sip Settings
sofia_version=${sofia_version} # release-version for sofia-sip to use
# Database Settings
database_name=${database_name} # Database name (safe characters A-Z, a-z, 0-9)
database_username=${database_username} # Database username (safe characters A-Z, a-z, 0-9)
database_password=${database_password} # random or a custom value (safe characters A-Z, a-z, 0-9)
database_repo=${database_repo} # PostgreSQL official, system
database_version=${database_version} # requires repo official
database_host=${database_host} # hostname or IP address
database_port=${database_port} # port number
database_backup=${database_backup} # true or false
# General Settings
php_version=${php_version} # PHP version 8.3, 8.2, 8.1
letsencrypt_folder=${letsencrypt_folder} # true or false
# Optional Applications
application_transcribe=${application_transcribe} # Speech to Text
application_speech=${application_speech} # Text to Speech
application_language_model=${application_language_model} # Language model
application_device_logs=${application_device_logs} # Log device provision requests
application_dialplan_tools=${application_dialplan_tools} # Add additional dialplan applications
application_edit=${application_edit} # Editor for XML, Provision, Scripts, and PHP
application_sip_trunks=${application_sip_trunks} # Registration-based SIP trunks
EOF
chmod 600 "$CONFIG_FILE"
echo "============================================================"
echo " Configuration saved to: $CONFIG_FILE"
echo "============================================================"
echo ""

14
debian/install.sh vendored
View File

@@ -3,6 +3,9 @@
#move to script directory so all relative paths work
cd "$(dirname "$0")"
#collect configuration variables (writes resources/config.sh)
. ./configure.sh
#includes
. ./resources/config.sh
. ./resources/colors.sh
@@ -11,8 +14,8 @@ cd "$(dirname "$0")"
# removes the cd img from the /etc/apt/sources.list file (not needed after base install)
sed -i '/cdrom:/d' /etc/apt/sources.list
#Update to the latest packages
verbose "Update installed packages."
#Update to latest packages
verbose "Update installed packages"
apt-get update && apt-get upgrade -y
#Add dependencies
@@ -25,7 +28,10 @@ apt-get install -y dialog
apt-get install -y nano
apt-get install -y net-tools
apt-get install -y gpg
apt-get install -y unzip
apt-get install -y git
#Git global config, credential store, and safe directory
resources/git.sh
#SNMP
apt-get install -y snmpd
@@ -66,4 +72,4 @@ resources/switch.sh
server_address=$(hostname -I)
#add the database schema, user and groups
resources/finish.sh
resources/finish.sh

View File

@@ -1,40 +1,42 @@
#!/bin/sh
# FusionPBX Settings
domain_name=ip_address # hostname, ip_address or a custom value
system_username=admin # default username admin
system_password=random # random or a custom value
system_branch=5.5 # master, 5.5
domain_name=ip_address # hostname, ip_address or a custom value
system_username=admin # default username admin
system_password=random # random or a custom value
system_branch=5.5 # master, 5.5
# FreeSWITCH Settings
switch_branch=stable # master, stable
switch_source=true # true (source compile) or false (binary package)
switch_package=false # true (binary package) or false (source compile)
switch_version=1.10.12 # which source code to download, only for source
switch_tls=true # true or false
switch_token= # Get the auth token from https://signalwire.com
# Signup or Login -> Profile -> Personal Auth Token
switch_branch=stable # master, stable
switch_source=true # true (source compile) or false (binary package)
switch_package=false # true (binary package) or false (source compile)
switch_version=1.10.12 # which source code to download, only for source
switch_tls=true # true or false
switch_token= # Get the auth token from https://signalwire.com
# Signup or Login -> Profile -> Personal Auth Token
# Sofia-Sip Settings
sofia_version=1.13.17 # release-version for sofia-sip to use
sofia_version=1.13.17 # release-version for sofia-sip to use
# Database Settings
database_name=fusionpbx # Database name (safe characters A-Z, a-z, 0-9)
database_username=fusionpbx # Database username (safe characters A-Z, a-z, 0-9)
database_password=random # random or a custom value (safe characters A-Z, a-z, 0-9)
database_repo=official # PostgreSQL official, system
database_version=18 # requires repo official
database_host=127.0.0.1 # hostname or IP address
database_port=5432 # port number
database_backup=false # true or false
database_name=fusionpbx # Database name (safe characters A-Z, a-z, 0-9)
database_username=fusionpbx # Database username (safe characters A-Z, a-z, 0-9)
database_password=random # random or a custom value (safe characters A-Z, a-z, 0-9)
database_repo=official # PostgreSQL official, system
database_version=18 # requires repo official
database_host=127.0.0.1 # hostname or IP address
database_port=5432 # port number
database_backup=false # true or false
# General Settings
php_version=8.2 # PHP version 8.3, 8.2, 8.1
letsencrypt_folder=true # true or false
php_version=8.2 # PHP version 8.3, 8.2, 8.1
letsencrypt_folder=true # true or false
# Optional Applications
application_transcribe=true # Speech to Text
application_speech=true # Text to Speech
application_language_model=true # Language model
application_device_logs=true # Log device provision requests
application_dialplan_tools=false # Add additional dialplan applications
application_edit=false # Editor for XML, Provision, Scripts, and PHP
application_sip_trunks=false # Registration-based SIP trunks
application_transcribe=true # Speech to Text
application_speech=true # Text to Speech
application_language_model=true # Language model
application_device_logs=true # Log device provision requests
application_dialplan_tools=false # Add additional dialplan applications
application_edit=false # Editor for XML, Provision, Scripts, and PHP
application_sip_trunks=false # Registration-based SIP trunks

38
debian/resources/git.sh vendored Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/sh
# git.sh - Apply global git configuration required by the installer
# - credential.helper pointing to /root/.git-credentials
# (the file itself is written by configure.sh before install begins)
# - safe.directory for /var/www/fusionpbx (needed when git runs as root
# but the directory is owned by www-data, git >= 2.35.2 requirement)
#
# This script must be called after git is installed (handled by install.sh).
#move to script directory so all relative paths work
cd "$(dirname "$0")"
#includes
. ./config.sh
. ./colors.sh
verbose "Configuring global git settings"
CREDENTIALS_FILE="/root/.git-credentials"
# ---------------------------------------------------------------------------
# 1. Credential helper
# Wire git to the file-based store that configure.sh already populated.
# ---------------------------------------------------------------------------
git config --global credential.helper "store --file $CREDENTIALS_FILE"
verbose " credential.helper = store --file $CREDENTIALS_FILE"
# ---------------------------------------------------------------------------
# 2. Safe directory for /var/www/fusionpbx
# Git >= 2.35.2 refuses to operate on directories owned by a different
# user. The installer runs as root but chowns the checkout to www-data,
# so subsequent git operations (updates, pulls) fail without this.
# ---------------------------------------------------------------------------
git config --global --add safe.directory /var/www/fusionpbx
verbose " safe.directory += /var/www/fusionpbx"
verbose "Git configuration complete"

View File

@@ -156,26 +156,17 @@ crontab -e
if (!file_exists($new_path)) { system('mkdir -p '.$new_path); }
$command = "mv ".$old_path."/".$record_name." ".$new_path."/".$record_name;
if ($debug) { echo $command."\n"; }
system($command, $move_result_code);
//skip the database update if the move failed
if ($move_result_code !== 0) {
if ($debug) { echo "mv failed with exit code ".$move_result_code.", skipping database update.\n"; }
continue;
}
}
//set the sql update params
$sql_params = [];
if ($action_name == 'move' || $action_name == 'both') {
$sql_params[] = "record_path = '".$new_path."'";
}
if ($action_name == 'convert' || $action_name == 'both') {
$sql_params[] = "record_name = '".$path_parts['filename'].".mp3'";
system($command);
}
//update the database to the new directory
$sql = "update v_xml_cdr set " . implode(", ", $sql_params) . " \n";
$sql = "update v_xml_cdr set \n";
if ($action_name == 'move' || $action_name == 'both') {
$sql .= "record_path = '".$new_path."' \n";
}
if ($action_name == 'convert' || $action_name == 'both') {
$sql .= "record_name = '".$path_parts['filename'].".mp3'\n";
}
$sql .= "where xml_cdr_uuid = '".$row['xml_cdr_uuid']."';\n";
if ($debug) { echo $sql."\n"; }
$database->execute($sql);

View File

@@ -35,12 +35,6 @@ if [ ."$os_codename" = ."trixie" ]; then
apt install -y python3-distutils-extra plocate
fi
#use master branch for Debian 13 for now
if [ ."$os_codename" = ."trixie" ]; then
switch_branch=master
switch_version=1.10.13
fi
# additional dependencies
apt install -y sqlite3 unzip
@@ -48,7 +42,7 @@ apt install -y sqlite3 unzip
CWD=$(pwd)
#install the following dependencies if the switch version is greater than 1.10.0
if [ ."$switch_branch" = ."master" ] || [ $(echo "$switch_version" | tr -d '.') -gt 1100 ]; then
if [ ."$switch_version" = ."master" ] || [ $(echo "$switch_version" | tr -d '.') -gt 1100 ] || [ ."$os_codename" = ."trixie" ]; then
# libks build-requirements
apt install -y cmake uuid-dev
@@ -66,7 +60,7 @@ if [ ."$switch_branch" = ."master" ] || [ $(echo "$switch_version" | tr -d '.')
# sofia-sip
cd /usr/src
if [ ."$sofia_version" = ."master" ]; then
if [ ."$sofia_version" = ."master" ] || [ ."$os_codename" = ."trixie" ]; then
git clone https://github.com/freeswitch/sofia-sip.git sofia-sip
cd sofia-sip
else
@@ -83,7 +77,7 @@ if [ ."$switch_branch" = ."master" ] || [ $(echo "$switch_version" | tr -d '.')
cd /usr/src
git clone https://github.com/freeswitch/spandsp.git spandsp
cd spandsp
if [ ."$sofia_version" != ."master" ] && [ ."$switch_branch" != ."master" ]; then
if [ ."$sofia_version" != ."master" ] && [ ."$os_codename" != ."trixie" ] && [ ."$switch_branch" != ."master" ]; then
git reset --hard 0d2e6ac65e0e8f53d652665a743015a88bf048d4
fi
#/usr/bin/sed -i 's/AC_PREREQ(\[2\.71\])/AC_PREREQ([2.69])/g' /usr/src/spandsp/configure.ac
@@ -97,7 +91,7 @@ fi
cd /usr/src
#check for master
if [ ."$switch_branch" = ."master" ]; then
if [ ."$os_codename" = ."trixie" ] || [ ."$switch_branch" = ."master" ]; then
#master branch
echo "Using version master"
rm -r /usr/src/freeswitch
@@ -106,14 +100,14 @@ if [ ."$switch_branch" = ."master" ]; then
git remote add fusionpbx https://github.com/fusionpbx/freeswitch.git
git fetch fusionpbx
git checkout 1.10.12
git checkout -b $switch_version
git rebase fusionpbx/master
./bootstrap.sh -j
fi
#check for stable release
if [ ."$switch_branch" != ."master" ] && [ ."$switch_branch" = ."stable" ]; then
if [ ."$switch_branch" != ."master" ] && [ ."$os_codename" != ."trixie" ] && [ ."$switch_branch" = ."stable" ]; then
echo "Using version $switch_version"
#1.8 and older
if [ $(echo "$switch_version" | tr -d '.') -lt 1100 ]; then
@@ -122,22 +116,18 @@ if [ ."$switch_branch" != ."master" ] && [ ."$switch_branch" = ."stable" ]; then
cd /usr/src/freeswitch-$switch_version
# Reset repo just-in-case we are rebuilding
#git reset --hard HEAD && git clean -fdx
git reset --hard HEAD && git clean -fdx
fi
#1.10.0 and newer
if [ $(echo "$switch_version" | tr -d '.') -gt 1100 ]; then
# Get the source code using git
git clone https://github.com/fusionpbx/freeswitch freeswitch-$switch_version
# Change the working directory
cd /usr/src/freeswitch-$switch_version
# Get the stable branch
git checkout $switch_version
# Reset repo just-in-case we are rebuilding
#git reset --hard origin/master && git clean -fdx
git reset --hard origin/master && git clean -fdx
#wget http://files.freeswitch.org/freeswitch-releases/freeswitch-$switch_version.-release.zip
#unzip freeswitch-$switch_version.-release.zip

View File

@@ -1,44 +1,20 @@
#!/bin/sh
# Move to script directory so all relative paths work
#move to script directory so all relative paths work
cd "$(dirname "$0")"
# Includes
#includes
. ../config.sh
. ../environment.sh
# Change the working directory
cd /usr/share/freeswitch/sounds
# change the working directory
cd /usr/src/freeswitch-$switch_version
# Make sure wget is installed
apt-get install -y wget
# compile and install the sounds
make sounds-install moh-install
make hd-sounds-install hd-moh-install
make cd-sounds-install cd-moh-install
# Array of sample rates
sample_rates="48000 32000 16000 8000"
# Loop through each sample rate
for sample_rate in $sample_rates; do
# Download the file
/usr/bin/wget "https://files.freeswitch.org/releases/sounds/freeswitch-sounds-en-us-callie-${sample_rate}-1.0.53.tar.gz"
# Extract the file
/usr/bin/tar xvzf "freeswitch-sounds-en-us-callie-${sample_rate}-1.0.53.tar.gz"
done
# Change to directory to the music directory
cd /usr/share/freeswitch/sounds/music
# Loop through each sample rate
for sample_rate in $sample_rates; do
# Download the file
/usr/bin/wget "https://files.freeswitch.org/releases/sounds/freeswitch-sounds-music-${sample_rate}-1.0.52.tar.gz"
# Extract the file
/usr/bin/tar xvzf "freeswitch-sounds-music-${sample_rate}-1.0.52.tar.gz"
done
# Move the music to the default directory
/usr/bin/mv music default
# Remove the tar.gz files
/usr/bin/rm /usr/share/freeswitch/sounds/music/*.tar.gz
#move the music into music/default directory
mkdir -p /usr/share/freeswitch/sounds/music/default
mv /usr/share/freeswitch/sounds/music/*000 /usr/share/freeswitch/sounds/music/default

View File

@@ -11,8 +11,8 @@ cd "$(dirname "$0")"
# removes the cd img from the /etc/apt/sources.list file (not needed after base install)
sed -i '/cdrom:/d' /etc/apt/sources.list
#Update to the latest packages
verbose "Update installed packages."
#Update to latest packages
verbose "Update installed packages"
apt-get update && apt-get upgrade -y
#Add dependencies
@@ -25,7 +25,6 @@ apt-get install -y dialog
apt-get install -y nano
apt-get install -y nginx
apt-get install -y build-essential
apt-get install -y unzip
#SNMP
apt-get install -y snmpd