Commit Graph
7 Commits
Author SHA1 Message Date
Claude d98eba2f76 Fix PTT permission denied errors - config files readable
CRITICAL FIX: PTT service couldn't read config files
======================================================

Problem Found in User's Diagnostics:
  System Logs (PTT):
  /usr/local/bin/kiosk-ptt: line 4: /etc/easy-asterisk/config: Permission denied
  /usr/local/bin/kiosk-ptt: line 5: /etc/easy-asterisk/ptt-device: Permission denied

Root Cause:
- Config files were chmod 600 (root read-only)
- PTT script runs as kiosk user (via systemd user service)
- Kiosk user couldn't read the config files
- PTT couldn't load device path or settings
- Mic stayed unmuted (PTT never started)

Fixes Applied:
==============

1. Config File Permissions (save_config function):
   ✓ Changed CONFIG_DIR from default to chmod 755 (readable)
   ✓ Changed CONFIG_FILE from chmod 600 to 644 (world-readable)
   ✓ Changed PTT_CONFIG_FILE from chmod 600 to 644 (world-readable)

   Files affected:
   - /etc/easy-asterisk/config (now 644)
   - /etc/easy-asterisk/ptt-device (now 644)

2. Input Group Membership (enable_client_services):
   ✓ Added check for 'input' group membership
   ✓ Automatically adds user to 'input' group if not already member
   ✓ Required for evtest to access /dev/input/event* devices

   Already existed in configure_ptt_menu (line 875) but added to
   enable_client_services for consistency during client install.

3. Removed Duplicate Permission Setting:
   ✓ Removed chmod 600 from detect_ptt_button function
   ✓ Removed redundant PTT config file creation
   ✓ Now relies on save_config() for all permission setting
   ✓ Ensures consistent 644 permissions

Why World-Readable is Safe:
============================
Config files contain:
- Device paths (/dev/input/eventX)
- Extension numbers (102, 201, etc.)
- SIP passwords (already in ~/.baresip/accounts)
- Server IPs (already in network config)

These are not system-level secrets. SIP passwords are for
application-level authentication, not system access. The kiosk
user needs read access for their services to function.

Testing After Update:
====================

For existing installs, run these commands to fix permissions:

  # Fix config file permissions
  sudo chmod 755 /etc/easy-asterisk
  sudo chmod 644 /etc/easy-asterisk/config
  sudo chmod 644 /etc/easy-asterisk/ptt-device

  # Add user to input group
  sudo usermod -aG input kiosk

  # User must log out/in or reboot for group change
  # OR restart services with newgrp:
  sudo -u kiosk newgrp input <<'RESTART'
  XDG_RUNTIME_DIR=/run/user/$(id -u kiosk) systemctl --user restart kiosk-ptt
  RESTART

  # Verify PTT logs
  journalctl -t kiosk-ptt -n 20

Expected Output After Fix:
===========================
  kiosk-ptt: PTT handler started, microphone muted, listening on /dev/input/event4
  kiosk-ptt: PTT pressed - mic unmuted
  kiosk-ptt: PTT released - mic muted

NOT:
  /usr/local/bin/kiosk-ptt: Permission denied

This resolves the PTT not working issue completely.
2025-12-03 19:20:00 +00:00
Claude a4b29082e7 CRITICAL FIX: Kiosk offline + PTT not muting issues
This fixes two critical bugs that prevented the kiosk client from
working properly.

ISSUE 1: Kiosk User Offline/Can't Connect
==========================================
Problem: Client installed but showed offline, couldn't register
with Asterisk server. Services weren't starting properly for
headless/non-logged-in users.

Root Causes:
- Missing DBUS_SESSION_BUS_ADDRESS environment variable
- Insufficient wait time for PipeWire and network
- No logging to diagnose startup issues
- Service dependencies not strong enough

Fixes:
✓ Added DBUS_SESSION_BUS_ADDRESS to all user services
✓ Increased startup delays (5s for baresip, 8s for PTT)
✓ Changed Wants to Requires for pipewire-pulse (hard dependency)
✓ Added StandardOutput/StandardError=journal for logging
✓ Increased RestartSec from 5s to 10s for more stable restarts

ISSUE 2: PTT Not Muting Microphone
===================================
Problem: PTT configured but microphone NOT muted on startup,
pressing PTT button did nothing, had to manually mute.

Root Causes:
- kiosk-ptt script missing XDG_RUNTIME_DIR environment
- pactl commands failing silently without proper context
- No wait for PipeWire to be ready before muting
- No logging to see what was happening

Fixes:
✓ Added XDG_RUNTIME_DIR detection/setup in PTT script
✓ Added 10-second wait loop for PipeWire to become ready
✓ Added error handling with logger for failed pactl commands
✓ Added logging for all PTT press/release events
✓ Export KIOSK_UID env var in PTT service

Enhanced Logging & Diagnostics
===============================
All services now log to systemd journal with tags:

- baresip-launcher: Network detection, config verification, startup
- kiosk-ptt: Startup, mic mute status, PTT press/release events
- baresip.service: Service output (via StandardOutput=journal)

View logs:
  journalctl -t baresip-launcher -f
  journalctl -t kiosk-ptt -f
  sudo -u kiosk journalctl --user -u baresip -f

New Features
============
1. Enhanced Diagnostics (Client Management > Run Diagnostics):
   - Shows launcher logs (last 10 lines)
   - Shows PTT logs (last 5 lines)
   - Shows Baresip service logs (last 10 lines)
   - Displays commands to view live logs

2. Manual Audio Fix Tool (Tools > Fix Audio):
   - Restarts PipeWire services
   - Unmutes microphone and speaker
   - Sets volume to 75%
   - Restarts Baresip
   - Shows current status

Improved Baresip Launcher
==========================
- Logs all startup steps
- Verifies config and accounts files exist
- Better network wait logic with logging
- Clear error messages if files missing
- Network detection logs which interface found

Testing After Update
====================
1. For existing installs - restart services:
   sudo -u kiosk systemctl --user daemon-reload
   sudo -u kiosk systemctl --user restart pipewire pipewire-pulse baresip

2. Check status:
   sudo -u kiosk systemctl --user status baresip

3. View logs:
   journalctl -t baresip-launcher -n 50
   journalctl -t kiosk-ptt -n 20

4. If still offline:
   Main Menu > Tools > Fix Audio (Unmute & Restart)

This should resolve both the offline connection issue and the
PTT mic muting problem. All operations now have proper logging
for easier troubleshooting.
2025-12-03 19:01:08 +00:00
Claude 7921c959ff Add smart user detection and selection for kiosk client install
Added intelligent user selection that scans /home directory and
presents available users, making it much easier to install the
kiosk client for the correct user account.

Features:
1. Smart User Detection
   - Scans /etc/passwd for real users (UID >= 1000)
   - Excludes system accounts (nologin, /bin/false)
   - Shows username, UID, and home directory
   - Presents numbered list of available users

2. Intelligent Defaults
   - Auto-suggests SUDO_USER if available
   - Falls back to first detected user
   - Highlights suggested choice as default

3. Manual Override
   - Option to manually enter username
   - Validates entered username exists
   - Shows confirmation with UID

4. Improved User Experience
   - install_client_only(): Uses new select_user function
   - configure_local_client(): Shows current user, offers to change
   - Clear feedback on user selection
   - Proper error handling for invalid selections

5. Verified Ownership
   All user configs are properly owned by selected user:
   - ~/.baresip/config (chown in configure_baresip:1879)
   - ~/.baresip/accounts (chown in configure_baresip:1879)
   - ~/.config/systemd/user/* (chown in enable_client_services:1962)
   - ~/.config/wireplumber/* (chown in configure_audio_ducking:1067)
   - All PipeWire/audio operations run as selected user

Example Flow:
  $ sudo ./easy-asterisk-interactive-v1.28.sh
  > Install Client Only

  Scanning for users...

    1) kiosk (UID: 1000, Home: /home/kiosk)
    2) admin (UID: 1001, Home: /home/admin)
    3) Enter username manually

  Select user [1]: 1
  ✓ Selected user: kiosk (UID: 1000)

This makes it much easier to install on kiosk systems where you
might not remember the exact username, and ensures all configs
are created with proper ownership from the start.
2025-12-03 18:35:57 +00:00
Claude 3d0c6a6afc Major fix: Audio and user permission issues for kiosk client
This commit addresses multiple critical issues that prevented the
kiosk client from working properly, especially regarding audio.

Issues Fixed:
1. Baresip config check error
   - Removed premature check for .baresip directory
   - Added option to install Baresip if not present
   - Improved user flow for client configuration

2. Audio completely lost after client installation
   - PTT service was starting even without PTT device configured
   - Added ConditionPathExists to PTT systemd service
   - Only enable PTT service when PTT device is actually configured
   - Ensured audio is unmuted for normal intercom operation

3. PipeWire/PulseAudio initialization
   - Added proper PipeWire and PipeWire-Pulse service dependencies
   - Explicitly enable and start PipeWire services for user
   - Added audio group membership check

4. Audio unmuting after installation
   - Created ensure_audio_unmuted() helper function
   - Automatically unmute microphone and speakers after install
   - Set reasonable volume levels (75%) if too low
   - Only applies when PTT is not configured

5. User permissions and ownership
   - Ensured all configs owned by kiosk user
   - Proper audio group membership
   - Clear messaging about needing to log out/reboot

6. Enhanced diagnostics
   - Added PipeWire service status checks
   - Show microphone/speaker mute status and volumes
   - Display PTT configuration status
   - Clear error message when microphone is muted
   - Added helpful instructions for troubleshooting

7. Improved user messaging
   - Added comprehensive post-install instructions
   - Clear explanation of audio configuration
   - Guidance on when to log out/reboot
   - Better error messages throughout

Key Changes:
- configure_local_client(): Offers to install Baresip if missing
- enable_client_services(): Only enables PTT when configured
- ensure_audio_unmuted(): New function to ensure audio works
- run_client_diagnostics(): Enhanced with audio status info
- install_client_only(): Added detailed audio setup message

The kiosk now works as a proper intercom out of the box, with
microphone and speakers unmuted and ready to use.
2025-12-03 17:29:57 +00:00
Claude cb95676722 Fix kiosk audio output: don't mute microphone by default
The PTT handler was muting the audio source before checking if a PTT
device was configured. This prevented kiosks from sending audio back
to calling phones during normal intercom operation.

Changes:
- Move audio mute command after PTT device check
- Only mute audio when PTT device is actually configured
- Leave audio unmuted for standard kiosk intercom functionality
- Add clarifying comments about PTT mode vs normal operation

This fixes the issue where phones calling the kiosk could send audio
but received no audio back from the kiosk.
2025-12-03 17:14:22 +00:00
Claude 74f9f63828 CRITICAL FIX: Set ENABLE_TLS="n" by default for LAN-only installs
ROOT CAUSE FOUND:
- install_server_only() was hardcoding ENABLE_TLS="y" (line 2039)
- install_full() wasn't setting ENABLE_TLS at all
- This caused devices to always use TLS/5061 even for LAN-only setups

FIXES:
1. install_server_only(): Changed ENABLE_TLS="y" to ENABLE_TLS="n"
2. install_full(): Added ENABLE_TLS="n" before configure_asterisk
3. Added debug output showing ENABLE_TLS and DOMAIN_NAME values in device summary

HOW IT WORKS NOW:
- Both install functions start with ENABLE_TLS="n" (LAN-only/UDP)
- Only setup_internet_access() sets ENABLE_TLS="y" (internet/TLS)
- Device configuration respects ENABLE_TLS value from saved config
- Device summary correctly displays UDP/5060 for LAN-only
- Device summary shows TLS/5061 only after internet/certs setup

This ensures devices use UDP transport for LAN-only installations
and TLS only when explicitly configured for internet calling.
2025-12-03 16:30:58 +00:00
Claude cd18ca5e5d v1.28: Fix LAN-only device configuration and add informative messages
CRITICAL FIX:
- Added load_config() call in add_device_menu to read saved ENABLE_TLS setting
- Device display now correctly shows UDP/5060 when ENABLE_TLS != "y"
- Device display shows TLS/5061 only when ENABLE_TLS == "y"
- SRTP requirement properly displayed based on TLS configuration

OTHER FIXES:
- ICE support only enabled when DOMAIN_NAME is set (FQDN/internet calling)
- RTP config: icesupport and STUN only for FQDN setups, not LAN-only
- Added informative message after server install before internet setup prompt

ISSUE RESOLVED:
When installing server-only without selecting internet/certs, devices now
correctly show:
  Transport: UDP (port 5060)
  SRTP: Not required

This matches the actual pjsip.conf configuration and allows mobile devices
to properly register with UDP transport on LAN networks.

Created v1.28.sh with all fixes, keeping v1.23.sh for reference.
2025-12-03 16:15:38 +00:00