diff --git a/Readme.md b/Readme.md index 1a89905..638d0e5 100644 --- a/Readme.md +++ b/Readme.md @@ -48,9 +48,9 @@ Home/office kiosk for reusing old hardware, displaying: # Enable SSH during installation # Download and run installer -wget https://github.com/outis1one/ubk/raw/main/install_kiosk_v0.9.9.sh -chmod +x install_kiosk_v0.9.9.sh -./install_kiosk_v0.9.9.sh +wget https://github.com/outis1one/ubk/raw/main/install_kiosk_v0.9.8.sh +chmod +x install_kiosk_v0.9.8.sh +./install_kiosk_v0.9.8.sh ``` The installer will guide you through configuration during setup. @@ -393,7 +393,7 @@ smb://WORKGROUP/COMPUTER/PrinterName ```bash # Run installer script again to access menu -./install_kiosk_0.9.9.sh +./install_kiosk_v0.9.8.sh # Menu structure: # 1. Core Settings - Sites, WiFi, schedules, passwords, full reinstall, complete uninstall @@ -408,9 +408,9 @@ The Easy Asterisk Intercom addon provides voice communication capabilities to yo **Access the addon menu:** ```bash -./install_kiosk_v0.9.9.sh -# Select: 2) Manage Addons -# Then: 2) Install/Update Intercom (Easy Asterisk) +./install_kiosk_v0.9.8.sh +# Select: 2) Addons +# Then: 4) Easy Asterisk Intercom ``` **Features:** @@ -437,9 +437,9 @@ asterisk -rvvv # Restart Asterisk systemctl restart asterisk -# Configure intercom -./install_kiosk_v0.9.9.sh -# Select: 2) Manage Addons → 6) Configure Intercom +# Configure intercom (rerun installation to update) +./install_kiosk_v0.9.8.sh +# Select: 2) Addons → 4) Easy Asterisk Intercom ``` **Installation location:** @@ -972,12 +972,13 @@ See the LICENSE file in the repository for full terms. ## Project Status & Future Plans -**Current Version:** 0.9.9 - Easy Asterisk Intercom Integration +**Current Version:** 0.9.8 - Named Sites & Easy Asterisk Intercom -**Recent Updates (v0.9.9):** +**Recent Updates (v0.9.8):** - Easy Asterisk Intercom addon with automatic updates - Smart version detection and configuration preservation -- Enhanced addon management system +- Named websites feature for user-friendly site identification +- Navigation menu with key icon **Planned Features:** - Web-based GUI configuration interface @@ -1019,4 +1020,4 @@ Special thanks to the maintainers of all upstream projects that make UBK possibl --- *Last Updated: December 10, 2025* -*Version: 0.9.9* +*Version: 0.9.8* diff --git a/install_kiosk_v0.9.8.sh b/install_kiosk_v0.9.8.sh index 938a663..8b7cc54 100644 --- a/install_kiosk_v0.9.8.sh +++ b/install_kiosk_v0.9.8.sh @@ -513,7 +513,18 @@ show_addon_status() { [[ -x /usr/bin/wg ]] && { any_addon=true; echo "WireGuard: ✓ Installed"; } [[ -x /usr/bin/tailscale ]] && { any_addon=true; echo "Tailscale: ✓ Installed"; } [[ -x /usr/bin/netbird ]] && { any_addon=true; echo "Netbird: ✓ Installed"; } - + + # Easy Asterisk Intercom - FAST CHECK + if [[ -f "${EASY_ASTERISK_VERSION_FILE:-/opt/easy-asterisk/.version}" ]]; then + any_addon=true + local ea_version=$(cat "${EASY_ASTERISK_VERSION_FILE:-/opt/easy-asterisk/.version}" 2>/dev/null || echo "Unknown") + if systemctl is-active asterisk &>/dev/null; then + echo "Easy Asterisk: ✓ Running (v${ea_version})" + else + echo "Easy Asterisk: ✓ Installed (v${ea_version}) - Not running" + fi + fi + if ! $any_addon; then echo "No addons installed" fi @@ -8933,6 +8944,252 @@ uninstall_html_keyboard() { log_success "HTML Keyboard removed" pause } +################################################################################ +### SECTION 14.5: ADDON - EASY ASTERISK INTERCOM +################################################################################ + +# GitHub repository details for Easy Asterisk +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 installation paths +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" + +get_latest_easy_asterisk_version() { + # Try to get file list from GitHub API + local files_json=$(curl -s "${EASY_ASTERISK_API_URL}" 2>/dev/null) + + if [ $? -ne 0 ] || [ -z "$files_json" ]; then + return 1 + fi + + # Extract easy-asterisk-v*.sh files and find the latest version + # Support both 3-part (1.2.3) and 4-part (0.9.8.7) version numbers + local latest_version=$(echo "$files_json" | grep -oP 'easy-asterisk-v\K[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?(?=\.sh)' | sort -V | tail -1) + + if [ -z "$latest_version" ]; then + return 1 + fi + + echo "$latest_version" + return 0 +} + +get_installed_easy_asterisk_version() { + if [ -f "$EASY_ASTERISK_VERSION_FILE" ]; then + cat "$EASY_ASTERISK_VERSION_FILE" + return 0 + fi + echo "" + return 1 +} + +backup_easy_asterisk_configs() { + if [ ! -d "$EASY_ASTERISK_INSTALL_DIR" ]; then + 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" + return 0 +} + +restore_easy_asterisk_configs() { + local backup_dir="$1" + + if [ -z "$backup_dir" ] || [ ! -d "$backup_dir" ]; then + return 0 + fi + + # Restore backed up items + for item in $(ls -A "$backup_dir" 2>/dev/null); 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 +} + +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}" + + echo "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" + + echo "Running Easy Asterisk installation script..." + echo "This may take several minutes..." + echo + + # 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 +} + +addon_easy_asterisk_intercom() { + clear + echo "════════════════════════════════════════════════════════════" + echo " EASY ASTERISK INTERCOM SETUP " + echo "════════════════════════════════════════════════════════════" + echo + + # Get latest version from GitHub + echo "Checking for latest version..." + 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}" + pause + return 1 + fi + + log_success "Latest version available: v${latest_version}" + echo + + # Check if already installed + local installed_version=$(get_installed_easy_asterisk_version) + + if [ -n "$installed_version" ]; then + echo "Currently installed version: v${installed_version}" + echo + + # Compare versions + if [ "$installed_version" = "$latest_version" ]; then + log_success "Easy Asterisk v${installed_version} is already installed (latest version)" + echo + read -r -p "Do you want to re-run the installation? (y/N): " rerun_choice + + if [[ ! "$rerun_choice" =~ ^[Yy]$ ]]; then + echo "Installation cancelled" + pause + return 0 + fi + + echo "Re-running installation (configs will be preserved)..." + else + echo "Update available: v${installed_version} → v${latest_version}" + echo + read -r -p "Do you want to update? (Y/n): " update_choice + + if [[ "$update_choice" =~ ^[Nn]$ ]]; then + echo "Update cancelled" + pause + return 0 + fi + + echo "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 + echo "Easy Asterisk is not currently installed" + echo + read -r -p "Do you want to install Easy Asterisk v${latest_version}? (Y/n): " install_choice + + if [[ "$install_choice" =~ ^[Nn]$ ]]; then + echo "Installation cancelled" + pause + return 0 + fi + fi + + echo + # 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!" + echo "Installation directory: $EASY_ASTERISK_INSTALL_DIR" + echo "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}" + echo "Your configurations have been preserved" + fi + + echo + echo "Management commands:" + echo " Check status: systemctl status asterisk" + echo " Asterisk CLI: asterisk -rvvv" + echo " Restart: systemctl restart asterisk" + echo + else + log_error "Installation failed" + + # Attempt to restore from backup if update failed + if [ -n "$backup_dir" ]; then + echo "Attempting to restore previous configuration..." + restore_easy_asterisk_configs "$backup_dir" + fi + fi + + pause +} + ################################################################################ ### SECTION 15: ADVANCED MENU FUNCTIONS ################################################################################ @@ -9494,14 +9751,16 @@ addons_menu() { echo " 1. LMS Server / Squeezelite Player" echo " 2. CUPS Printing" echo " 3. Remote Access (VNC/VPN)" + echo " 4. Easy Asterisk Intercom" echo " 0. Return" echo - read -r -p "Choose [0-3]: " choice - + read -r -p "Choose [0-4]: " choice + case "$choice" in 1) addon_lms_squeezelite ;; 2) addon_cups ;; 3) remote_access_menu ;; + 4) addon_easy_asterisk_intercom ;; 0) return ;; esac done diff --git a/install_kiosk_v0.9.9.sh b/install_kiosk_v0.9.9.sh index 235c268..9684b90 100644 --- a/install_kiosk_v0.9.9.sh +++ b/install_kiosk_v0.9.9.sh @@ -137,82 +137,7 @@ install_addon() { } ################################################################################ -# Easy Asterisk Integration -################################################################################ - -install_easy_asterisk() { - log_info "Installing Easy Asterisk addon..." - - local asterisk_addon_path="${ADDON_DIR}/easy_asterisk" - mkdir -p "$asterisk_addon_path" - - # Create Easy Asterisk configuration - cat > "${asterisk_addon_path}/config.conf" <<'EOF' -[easy_asterisk] -enabled = true -version = 1.0 -description = Easy Asterisk Integration for UBK Kiosk - -[asterisk_server] -host = localhost -port = 5060 -protocol = SIP - -[features] -call_forwarding = true -voicemail_integration = true -conference_support = true -caller_id_customization = true - -[security] -enable_auth = true -enable_encryption = false -allowed_ips = localhost,127.0.0.1 - -[logging] -level = INFO -output_file = /var/log/ubk_asterisk.log -EOF - - # Create initialization script - cat > "${asterisk_addon_path}/init.sh" <<'EOF' -#!/bin/bash - -ADDON_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -CONFIG_FILE="${ADDON_DIR}/config.conf" - -echo "[Easy Asterisk] Initializing addon..." - -# Check if Asterisk is installed -if ! command -v asterisk &> /dev/null; then - echo "[Easy Asterisk] Warning: Asterisk not found. Installing..." - sudo apt-get update - sudo apt-get install -y asterisk asterisk-dev -fi - -# Load configuration -if [ -f "$CONFIG_FILE" ]; then - source <(grep -E '^\[|^[a-zA-Z_]' "$CONFIG_FILE") - echo "[Easy Asterisk] Configuration loaded" -fi - -# Initialize Asterisk integration -echo "[Easy Asterisk] Starting Asterisk daemon..." -sudo systemctl restart asterisk || true - -echo "[Easy Asterisk] Addon initialized successfully" -EOF - - chmod +x "${asterisk_addon_path}/init.sh" - - # Run initialization - bash "${asterisk_addon_path}/init.sh" - - log_success "Easy Asterisk addon installed" -} - -################################################################################ -# Intercom Integration (Easy Asterisk) +# Intercom Integration (Easy Asterisk from GitHub) ################################################################################ # GitHub repository details @@ -498,47 +423,39 @@ display_addon_menu() { echo -e "${BLUE}================================${NC}" echo -e "${BLUE} UBK Kiosk v${SCRIPT_VERSION} Addon Menu${NC}" echo -e "${BLUE}================================${NC}" - echo "1) Install Easy Asterisk" - echo "2) Install/Update Intercom (Easy Asterisk)" - echo "3) Install Custom Addon" - echo "4) List Installed Addons" - echo "5) Configure Easy Asterisk" - echo "6) Configure Intercom" - echo "7) View Addon Logs" - echo "8) Return to Main Menu" - echo "9) Exit" + echo "1) Install/Update Intercom (Easy Asterisk)" + echo "2) Install Custom Addon" + echo "3) List Installed Addons" + echo "4) Configure Intercom" + echo "5) View Addon Logs" + echo "6) Return to Main Menu" + echo "7) Exit" echo -e "${BLUE}================================${NC}" - + read -p "Select option: " addon_choice - + case $addon_choice in 1) - install_easy_asterisk - ;; - 2) install_intercom ;; - 3) + 2) read -p "Enter addon name: " addon_name read -p "Enter addon URL (leave blank for local): " addon_url install_addon "$addon_name" "$addon_url" ;; - 4) + 3) list_addons ;; - 5) - configure_easy_asterisk - ;; - 6) + 4) configure_intercom ;; - 7) + 5) view_addon_logs ;; - 8) + 6) return ;; - 9) + 7) log_info "Exiting..." exit 0 ;; @@ -571,33 +488,11 @@ list_addons() { echo "" } -configure_easy_asterisk() { - local config_file="${ADDON_DIR}/easy_asterisk/config.conf" - - if [ ! -f "$config_file" ]; then - log_error "Easy Asterisk not installed" - return - fi - - log_info "Configuring Easy Asterisk..." - - read -p "Enter Asterisk server host [localhost]: " asterisk_host - asterisk_host="${asterisk_host:-localhost}" - - read -p "Enter Asterisk server port [5060]: " asterisk_port - asterisk_port="${asterisk_port:-5060}" - - sed -i "s/^host = .*/host = $asterisk_host/" "$config_file" - sed -i "s/^port = .*/port = $asterisk_port/" "$config_file" - - log_success "Easy Asterisk configuration updated" -} - configure_intercom() { # Check if Easy Asterisk is installed if [ ! -d "$EASY_ASTERISK_INSTALL_DIR" ]; then log_error "Easy Asterisk Intercom is not installed" - log_info "Please install it first using option 2 from the Addons menu" + log_info "Please install it first using option 1 from the Addons menu" return 1 fi