#!/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): source ./configure.sh OR . ./configure.sh #move to the directory this script lives in so relative paths work cd "$(dirname "$0")" 2>/dev/null || true CONFIG_FILE="./resources/config.sh" # --------------------------------------------------------------------------- # Helper: prompt with a default value # ask # --------------------------------------------------------------------------- ask() { _var="$1" _prompt="$2" _default="$3" printf "%s [%s]: " "$_prompt" "$_default" read -r _input # --------------------------------------------------------------------------- ask_secret() { _var="$1" _prompt="$2" # stty may not be available in all minimal environments; fall back gracefully if stty -echo 2>/dev/null; then printf "%s: " "$_prompt" read -r _input # --------------------------------------------------------------------------- ask_bool() { _var="$1" _prompt="$2" _default="$3" while true; do printf "%s (true/false) [%s]: " "$_prompt" "$_default" read -r _input }" echo " Credentials will be stored in /root/.git-credentials (mode 600)." echo " Leave username blank to skip credential store configuration." echo "" ask git_username "Git username or email" "" if [ -n "$git_username" ]; then ask_secret git_password "Git password or personal access token" else git_password="" fi echo "" # --------------------------------------------------------------------------- # Write config.sh # --------------------------------------------------------------------------- cat > "$CONFIG_FILE" < 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 # Git Settings git_server=${git_server} # Hostname parsed from resources/fusionpbx.sh clone URL git_username=${git_username} # Git username or email for credential store git_password=${git_password} # Git password or personal access token EOF # Protect config.sh since it now contains credentials chmod 600 "$CONFIG_FILE" echo "============================================================" echo " Configuration saved to: $CONFIG_FILE" echo "============================================================" echo ""