Add Easy Asterisk Intercom addon with automatic update management

Features:
- Download and install latest Easy Asterisk from GitHub repository
- Automatic version detection using GitHub API
- Smart update checking with user confirmation
- Configuration preservation during updates and reruns
- Backup and restore functionality for configs
- Safe re-run capability without breaking existing setup

Menu changes:
- Added "Install/Update Intercom (Easy Asterisk)" option
- Updated configure_intercom to work with Easy Asterisk installation
- Enhanced configuration interface with file editing support

README updates:
- Added Communication section with Easy Asterisk Intercom
- Documented installation, update, and configuration workflows
- Updated version to 0.9.9
- Added installation locations and management commands

The intercom addon integrates with outis1one/easy-asterisk repository
and follows the pattern of easy-asterisk-v*.sh version files.
This commit is contained in:
Claude
2025-12-10 12:21:18 +00:00
parent 77eaf19636
commit 62e4a906b9
2 changed files with 387 additions and 97 deletions
+67 -9
View File
@@ -48,9 +48,9 @@ Home/office kiosk for reusing old hardware, displaying:
# Enable SSH during installation # Enable SSH during installation
# Download and run installer # Download and run installer
wget https://github.com/outis1one/ubk/raw/main/install_kiosk_0.9.8.sh wget https://github.com/outis1one/ubk/raw/main/install_kiosk_v0.9.9.sh
chmod +x install_kiosk_0.9.8.sh chmod +x install_kiosk_v0.9.9.sh
./install_kiosk_0.9.8.sh ./install_kiosk_v0.9.9.sh
``` ```
The installer will guide you through configuration during setup. The installer will guide you through configuration during setup.
@@ -112,6 +112,14 @@ The installer will guide you through configuration during setup.
## Optional Add-ons ## Optional Add-ons
### Communication
- **Easy Asterisk Intercom** - Voice communication and intercom system
- Downloads latest version from Easy Asterisk repository
- Automatic update detection and installation
- Configuration preservation during updates
- Full Asterisk PBX integration
- SIP/PJSIP support for IP phones and softphones
### Audio ### Audio
- **Lyrion Music Server (LMS)** - Formerly Logitech Media Server - **Lyrion Music Server (LMS)** - Formerly Logitech Media Server
- **Squeezelite Player** - Network audio player for LMS - **Squeezelite Player** - Network audio player for LMS
@@ -385,15 +393,61 @@ smb://WORKGROUP/COMPUTER/PrinterName
```bash ```bash
# Run installer script again to access menu # Run installer script again to access menu
./install_kiosk_0.9.8.sh ./install_kiosk_0.9.9.sh
# Menu structure: # Menu structure:
# 1. Core Settings - Sites, WiFi, schedules, passwords, full reinstall, complete uninstall # 1. Core Settings - Sites, WiFi, schedules, passwords, full reinstall, complete uninstall
# 2. Addons - LMS, CUPS, VNC, VPNs # 2. Addons - Easy Asterisk Intercom, LMS, CUPS, VNC, VPNs
# 3. Advanced - Diagnostics, logs, Electron updates, virtual consoles, emergency hotspot # 3. Advanced - Diagnostics, logs, Electron updates, virtual consoles, emergency hotspot
# 4. Restart Kiosk Display # 4. Restart Kiosk Display
``` ```
### Installing Easy Asterisk Intercom
The Easy Asterisk Intercom addon provides voice communication capabilities to your kiosk system.
**Access the addon menu:**
```bash
./install_kiosk_v0.9.9.sh
# Select: 2) Manage Addons
# Then: 2) Install/Update Intercom (Easy Asterisk)
```
**Features:**
- **Automatic installation** - Downloads and installs the latest version from the Easy Asterisk repository
- **Update detection** - Checks for newer versions and prompts to update
- **Safe re-runs** - Can be run multiple times without breaking existing configurations
- **Config preservation** - Automatically backs up and restores configurations during updates
- **Full Asterisk PBX** - Complete telephony features including SIP, extensions, voicemail
**Installation behavior:**
- **First install:** Downloads latest version from https://github.com/outis1one/easy-asterisk
- **Already installed (latest):** Prompts to re-run installation (preserves configs)
- **Update available:** Prompts to update and shows version difference
- **All scenarios:** Configuration files in `/etc/asterisk/` and installation settings are preserved
**Managing Easy Asterisk:**
```bash
# Check installation status
systemctl status asterisk
# View Asterisk console
asterisk -rvvv
# Restart Asterisk
systemctl restart asterisk
# Configure intercom
./install_kiosk_v0.9.9.sh
# Select: 2) Manage Addons → 6) Configure Intercom
```
**Installation location:**
- Installation files: `/opt/easy-asterisk/`
- Configuration: `/etc/asterisk/`
- Version tracking: `/opt/easy-asterisk/.version`
- Config backups: `/opt/easy-asterisk/config_backup/`
### Updating Electron ### Updating Electron
```bash ```bash
@@ -918,12 +972,16 @@ See the LICENSE file in the repository for full terms.
## Project Status & Future Plans ## Project Status & Future Plans
**Current Version:** 0.9.8 - Named Sites & Navigation Menu **Current Version:** 0.9.9 - Easy Asterisk Intercom Integration
**Recent Updates (v0.9.9):**
- Easy Asterisk Intercom addon with automatic updates
- Smart version detection and configuration preservation
- Enhanced addon management system
**Planned Features:** **Planned Features:**
- Web-based GUI configuration interface - Web-based GUI configuration interface
- All-in-one ISO installer - All-in-one ISO installer
- Voice communication integration (Asterisk/Baresip)
- Enhanced Raspberry Pi support and testing - Enhanced Raspberry Pi support and testing
**Known Limitations:** **Known Limitations:**
@@ -960,5 +1018,5 @@ Special thanks to the maintainers of all upstream projects that make UBK possibl
--- ---
*Last Updated: December 2, 2025* *Last Updated: December 10, 2025*
*Version: 0.9.8* *Version: 0.9.9*
+313 -81
View File
@@ -212,86 +212,280 @@ EOF
} }
################################################################################ ################################################################################
# Intercom Integration # Intercom Integration (Easy Asterisk)
################################################################################ ################################################################################
install_intercom() { # GitHub repository details
log_info "Installing Intercom addon..." EASY_ASTERISK_REPO="outis1one/easy-asterisk"
EASY_ASTERISK_RAW_URL="https://raw.githubusercontent.com/${EASY_ASTERISK_REPO}/main"
EASY_ASTERISK_API_URL="https://api.github.com/repos/${EASY_ASTERISK_REPO}/contents"
local intercom_addon_path="${ADDON_DIR}/intercom" # Local installation paths
mkdir -p "$intercom_addon_path" EASY_ASTERISK_INSTALL_DIR="/opt/easy-asterisk"
EASY_ASTERISK_VERSION_FILE="${EASY_ASTERISK_INSTALL_DIR}/.version"
EASY_ASTERISK_CONFIG_BACKUP="${EASY_ASTERISK_INSTALL_DIR}/config_backup"
# Create Intercom configuration ################################################################################
cat > "${intercom_addon_path}/config.conf" <<'EOF' # Function: get_latest_easy_asterisk_version
[intercom] # Description: Get the latest version of easy-asterisk from GitHub
enabled = true # Returns: Version string (e.g., "1.2.3") or empty string on failure
version = 1.0 ################################################################################
description = Intercom System Integration for UBK Kiosk get_latest_easy_asterisk_version() {
log_info "Checking for latest Easy Asterisk version..."
[intercom_server] # Try to get file list from GitHub API
host = localhost local files_json=$(curl -s "${EASY_ASTERISK_API_URL}" 2>/dev/null)
port = 8888
protocol = HTTP
[features] if [ $? -ne 0 ] || [ -z "$files_json" ]; then
two_way_audio = true log_warning "Could not fetch file list from GitHub API"
video_support = false return 1
call_recording = true
presence_detection = true
emergency_alert = true
[devices]
auto_discovery = true
max_devices = 20
timeout = 30
[security]
require_authentication = true
enable_encryption = true
allowed_ips = 0.0.0.0/0
[audio]
codec = opus
sample_rate = 16000
bit_depth = 16
EOF
# Create initialization script
cat > "${intercom_addon_path}/init.sh" <<'EOF'
#!/bin/bash
ADDON_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_FILE="${ADDON_DIR}/config.conf"
echo "[Intercom] Initializing addon..."
# Check required packages
for pkg in pulseaudio alsa-utils; do
if ! dpkg -l | grep -q "^ii $pkg"; then
echo "[Intercom] Installing $pkg..."
sudo apt-get update
sudo apt-get install -y "$pkg"
fi fi
done
# Load configuration # Extract easy-asterisk-v*.sh files and find the latest version
if [ -f "$CONFIG_FILE" ]; then local latest_version=$(echo "$files_json" | grep -oP 'easy-asterisk-v\K[0-9]+\.[0-9]+\.[0-9]+(?=\.sh)' | sort -V | tail -1)
echo "[Intercom] Configuration loaded"
fi
# Start audio services if [ -z "$latest_version" ]; then
sudo systemctl restart pulseaudio || true log_warning "No version files found in repository"
sudo systemctl restart alsasound || true return 1
fi
echo "[Intercom] Addon initialized successfully" echo "$latest_version"
EOF return 0
}
chmod +x "${intercom_addon_path}/init.sh" ################################################################################
# Function: get_installed_easy_asterisk_version
# Description: Get the currently installed version of easy-asterisk
# Returns: Version string or empty if not installed
################################################################################
get_installed_easy_asterisk_version() {
if [ -f "$EASY_ASTERISK_VERSION_FILE" ]; then
cat "$EASY_ASTERISK_VERSION_FILE"
return 0
fi
# Run initialization echo ""
bash "${intercom_addon_path}/init.sh" return 1
}
log_success "Intercom addon installed" ################################################################################
# Function: backup_easy_asterisk_configs
# Description: Backup existing configuration files before update
# Returns: 0 on success, 1 on failure
################################################################################
backup_easy_asterisk_configs() {
log_info "Backing up Easy Asterisk configurations..."
if [ ! -d "$EASY_ASTERISK_INSTALL_DIR" ]; then
log_info "No existing installation to backup"
return 0
fi
# Create backup directory with timestamp
local backup_dir="${EASY_ASTERISK_CONFIG_BACKUP}/$(date +%Y%m%d_%H%M%S)"
mkdir -p "$backup_dir"
# Backup common config directories and files
for item in config etc *.conf *.cfg; do
if [ -e "${EASY_ASTERISK_INSTALL_DIR}/${item}" ]; then
cp -r "${EASY_ASTERISK_INSTALL_DIR}/${item}" "$backup_dir/" 2>/dev/null || true
fi
done
# Also backup Asterisk configs if they exist
if [ -d "/etc/asterisk" ]; then
mkdir -p "${backup_dir}/asterisk_etc"
cp -r /etc/asterisk/*.conf "${backup_dir}/asterisk_etc/" 2>/dev/null || true
fi
log_success "Configuration backup created at: $backup_dir"
return 0
}
################################################################################
# Function: restore_easy_asterisk_configs
# Description: Restore configuration files after update
# Parameters: $1 - Backup directory path
# Returns: 0 on success, 1 on failure
################################################################################
restore_easy_asterisk_configs() {
local backup_dir="$1"
if [ -z "$backup_dir" ] || [ ! -d "$backup_dir" ]; then
log_info "No backup to restore"
return 0
fi
log_info "Restoring Easy Asterisk configurations..."
# Restore backed up items
for item in $(ls -A "$backup_dir"); do
if [ "$item" != "asterisk_etc" ]; then
cp -r "${backup_dir}/${item}" "${EASY_ASTERISK_INSTALL_DIR}/" 2>/dev/null || true
fi
done
# Restore Asterisk configs if they were backed up
if [ -d "${backup_dir}/asterisk_etc" ]; then
cp -r "${backup_dir}/asterisk_etc"/*.conf /etc/asterisk/ 2>/dev/null || true
fi
log_success "Configuration restored"
return 0
}
################################################################################
# Function: download_and_install_easy_asterisk
# Description: Download and run the Easy Asterisk installation script
# Parameters: $1 - Version to install
# Returns: 0 on success, 1 on failure
################################################################################
download_and_install_easy_asterisk() {
local version="$1"
local script_name="easy-asterisk-v${version}.sh"
local script_url="${EASY_ASTERISK_RAW_URL}/${script_name}"
local temp_script="/tmp/${script_name}"
log_info "Downloading Easy Asterisk v${version}..."
# Download the installation script
if ! curl -fsSL "$script_url" -o "$temp_script"; then
log_error "Failed to download Easy Asterisk installation script"
log_error "URL: $script_url"
return 1
fi
# Verify the script was downloaded
if [ ! -f "$temp_script" ] || [ ! -s "$temp_script" ]; then
log_error "Downloaded script is empty or missing"
return 1
fi
# Make script executable
chmod +x "$temp_script"
log_info "Running Easy Asterisk installation script..."
log_info "This may take several minutes..."
# Run the installation script
if bash "$temp_script"; then
log_success "Easy Asterisk installation completed"
# Save version information
mkdir -p "$EASY_ASTERISK_INSTALL_DIR"
echo "$version" > "$EASY_ASTERISK_VERSION_FILE"
# Clean up temp file
rm -f "$temp_script"
return 0
else
log_error "Easy Asterisk installation failed"
rm -f "$temp_script"
return 1
fi
}
################################################################################
# Function: install_intercom
# Description: Install or update Easy Asterisk Intercom addon
# Returns: 0 on success, 1 on failure
################################################################################
install_intercom() {
echo ""
echo -e "${BLUE}================================${NC}"
echo -e "${BLUE}Easy Asterisk Intercom Setup${NC}"
echo -e "${BLUE}================================${NC}"
echo ""
# Get latest version from GitHub
local latest_version=$(get_latest_easy_asterisk_version)
if [ -z "$latest_version" ]; then
log_error "Could not determine latest version"
log_error "Please check your internet connection and that the repository is accessible"
log_error "Repository: https://github.com/${EASY_ASTERISK_REPO}"
return 1
fi
log_info "Latest version available: v${latest_version}"
# Check if already installed
local installed_version=$(get_installed_easy_asterisk_version)
if [ -n "$installed_version" ]; then
log_info "Currently installed version: v${installed_version}"
# Compare versions
if [ "$installed_version" = "$latest_version" ]; then
echo ""
log_info "Easy Asterisk v${installed_version} is already installed (latest version)"
echo ""
read -p "Do you want to re-run the installation? (y/N): " rerun_choice
if [[ ! "$rerun_choice" =~ ^[Yy]$ ]]; then
log_info "Installation cancelled"
return 0
fi
log_info "Re-running installation (configs will be preserved)..."
else
echo ""
log_info "Update available: v${installed_version} → v${latest_version}"
echo ""
read -p "Do you want to update? (Y/n): " update_choice
if [[ "$update_choice" =~ ^[Nn]$ ]]; then
log_info "Update cancelled"
return 0
fi
log_info "Updating Easy Asterisk..."
fi
# Backup existing configurations
backup_easy_asterisk_configs
local backup_dir=$(ls -td "${EASY_ASTERISK_CONFIG_BACKUP}"/* 2>/dev/null | head -1)
else
log_info "Easy Asterisk is not currently installed"
echo ""
read -p "Do you want to install Easy Asterisk v${latest_version}? (Y/n): " install_choice
if [[ "$install_choice" =~ ^[Nn]$ ]]; then
log_info "Installation cancelled"
return 0
fi
fi
# Download and install
if download_and_install_easy_asterisk "$latest_version"; then
# Restore configurations if this was an update/rerun
if [ -n "$backup_dir" ]; then
restore_easy_asterisk_configs "$backup_dir"
fi
echo ""
log_success "Easy Asterisk Intercom is ready!"
log_info "Installation directory: $EASY_ASTERISK_INSTALL_DIR"
log_info "Version: v${latest_version}"
if [ -n "$installed_version" ] && [ "$installed_version" != "$latest_version" ]; then
log_success "Successfully updated from v${installed_version} to v${latest_version}"
log_info "Your configurations have been preserved"
fi
echo ""
return 0
else
log_error "Installation failed"
# Attempt to restore from backup if update failed
if [ -n "$backup_dir" ]; then
log_warning "Attempting to restore previous configuration..."
restore_easy_asterisk_configs "$backup_dir"
fi
return 1
fi
} }
################################################################################ ################################################################################
@@ -305,7 +499,7 @@ display_addon_menu() {
echo -e "${BLUE} UBK Kiosk v${SCRIPT_VERSION} Addon Menu${NC}" echo -e "${BLUE} UBK Kiosk v${SCRIPT_VERSION} Addon Menu${NC}"
echo -e "${BLUE}================================${NC}" echo -e "${BLUE}================================${NC}"
echo "1) Install Easy Asterisk" echo "1) Install Easy Asterisk"
echo "2) Install Intercom" echo "2) Install/Update Intercom (Easy Asterisk)"
echo "3) Install Custom Addon" echo "3) Install Custom Addon"
echo "4) List Installed Addons" echo "4) List Installed Addons"
echo "5) Configure Easy Asterisk" echo "5) Configure Easy Asterisk"
@@ -400,25 +594,63 @@ configure_easy_asterisk() {
} }
configure_intercom() { configure_intercom() {
local config_file="${ADDON_DIR}/intercom/config.conf" # Check if Easy Asterisk is installed
if [ ! -d "$EASY_ASTERISK_INSTALL_DIR" ]; then
if [ ! -f "$config_file" ]; then log_error "Easy Asterisk Intercom is not installed"
log_error "Intercom not installed" log_info "Please install it first using option 2 from the Addons menu"
return return 1
fi fi
log_info "Configuring Intercom..." local installed_version=$(get_installed_easy_asterisk_version)
read -p "Enter Intercom server host [localhost]: " intercom_host echo ""
intercom_host="${intercom_host:-localhost}" echo -e "${BLUE}================================${NC}"
echo -e "${BLUE}Easy Asterisk Configuration${NC}"
echo -e "${BLUE}================================${NC}"
echo ""
log_info "Installed version: v${installed_version}"
log_info "Installation directory: $EASY_ASTERISK_INSTALL_DIR"
echo ""
read -p "Enter Intercom server port [8888]: " intercom_port # Check if the easy-asterisk installation has a configuration script
intercom_port="${intercom_port:-8888}" if [ -x "${EASY_ASTERISK_INSTALL_DIR}/configure.sh" ]; then
log_info "Running Easy Asterisk configuration script..."
bash "${EASY_ASTERISK_INSTALL_DIR}/configure.sh"
elif [ -d "/etc/asterisk" ]; then
log_info "Asterisk configuration files are located in /etc/asterisk/"
echo ""
echo "Common configuration files:"
echo " - /etc/asterisk/sip.conf (SIP configuration)"
echo " - /etc/asterisk/extensions.conf (Dialplan)"
echo " - /etc/asterisk/pjsip.conf (PJSIP configuration)"
echo ""
read -p "Do you want to edit a configuration file? (y/N): " edit_choice
sed -i "s/^host = .*/host = $intercom_host/" "$config_file" if [[ "$edit_choice" =~ ^[Yy]$ ]]; then
sed -i "s/^port = .*/port = $intercom_port/" "$config_file" echo ""
echo "Available configuration files:"
ls -1 /etc/asterisk/*.conf 2>/dev/null | nl
echo ""
read -p "Enter file number to edit (or q to cancel): " file_num
log_success "Intercom configuration updated" if [[ "$file_num" =~ ^[0-9]+$ ]]; then
local config_file=$(ls -1 /etc/asterisk/*.conf 2>/dev/null | sed -n "${file_num}p")
if [ -f "$config_file" ]; then
${EDITOR:-nano} "$config_file"
log_success "Configuration file edited: $config_file"
log_info "Restarting Asterisk to apply changes..."
systemctl restart asterisk
else
log_error "Invalid file selection"
fi
fi
fi
else
log_warning "No configuration interface found"
log_info "You may need to manually configure Easy Asterisk"
fi
echo ""
} }
view_addon_logs() { view_addon_logs() {