From 387cbec0994c0de777738f63a71683d16c85d8f3 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 23 Nov 2025 00:50:52 +0000 Subject: [PATCH 1/3] Move binary installation inside sudo block to fix permission check The build was succeeding but the post-build verification was failing because it tried to check /home/kiosk/talkkonnect-binary from outside the sudo -u kiosk block. Changes: - Move binary verification and installation inside the sudo -u block - Use ~ instead of /home/$KIOSK_USER (more reliable inside sudo) - Remove redundant chmod/chown after sudo block - Binary now installed while running as kiosk user This matches the approach from talkkonnect_complete_install.sh where all file operations happen inside the user context. --- setup_intercom.sh | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/setup_intercom.sh b/setup_intercom.sh index 1b44b4e..e7821d8 100755 --- a/setup_intercom.sh +++ b/setup_intercom.sh @@ -509,16 +509,22 @@ EOFOPUS cd cmd/talkkonnect || exit 1 echo 'Compiling with vendored dependencies...' - go build -mod=vendor -v -o /home/$KIOSK_USER/talkkonnect-binary . 2>&1 | tail -20 + go build -mod=vendor -v -o ~/talkkonnect-binary . 2>&1 | tail -20 - if [[ -f /home/$KIOSK_USER/talkkonnect-binary ]]; then - chmod +x /home/$KIOSK_USER/talkkonnect-binary - echo 'Build successful' - exit 0 - else + if [[ ! -f ~/talkkonnect-binary ]]; then echo 'Build failed - binary not created' exit 1 fi + + echo 'Build successful' + echo 'Installing binary...' + + # Install to go/bin + cp ~/talkkonnect-binary ~/go/bin/talkkonnect + chmod +x ~/go/bin/talkkonnect + rm ~/talkkonnect-binary + + echo 'Installation complete' " local build_result=$? @@ -534,19 +540,6 @@ EOFOPUS return 1 fi - # Verify and install binary - if [[ ! -x "/home/$KIOSK_USER/talkkonnect-binary" ]]; then - log_error "Binary not executable after build" - pause - return 1 - fi - - echo "Installing binary..." - sudo cp /home/$KIOSK_USER/talkkonnect-binary /home/$KIOSK_USER/go/bin/talkkonnect - sudo chmod +x /home/$KIOSK_USER/go/bin/talkkonnect - sudo chown "$KIOSK_USER:$KIOSK_USER" /home/$KIOSK_USER/go/bin/talkkonnect - rm -f /home/$KIOSK_USER/talkkonnect-binary - log_success "talkkonnect built successfully" echo "[4/4] Creating configuration..." From f6f2202e326ac4ffa18855665cfd5585d2d1b6cf Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 23 Nov 2025 00:56:03 +0000 Subject: [PATCH 2/3] Stop running talkkonnect before binary replacement Fixes "Text file busy" error and "Not installed" status: 1. **Stop service before install** (lines 535-547) - Check if talkkonnect service is running - Stop systemd service if active - Kill any stray processes - Sleep 1 second to ensure file is released - Then copy the new binary 2. **Fix status check** (line 72) - Changed from $HOME/go/bin/talkkonnect - To /home/$KIOSK_USER/go/bin/talkkonnect - Now correctly detects installed binary 3. **Separate build and install steps** - Build completes inside first sudo block - Installation happens in second sudo block after stopping service - Clean error handling for each step This matches the working talkkonnect_complete_install.sh approach. --- setup_intercom.sh | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/setup_intercom.sh b/setup_intercom.sh index e7821d8..171cd40 100755 --- a/setup_intercom.sh +++ b/setup_intercom.sh @@ -69,7 +69,7 @@ check_talkkonnect_status() { local installed=false local running=false - if command -v talkkonnect &>/dev/null || [[ -f "$HOME/go/bin/talkkonnect" ]]; then + if command -v talkkonnect &>/dev/null || [[ -f "/home/$KIOSK_USER/go/bin/talkkonnect" ]]; then installed=true if systemctl is-active --quiet talkkonnect; then running=true @@ -517,14 +517,6 @@ EOFOPUS fi echo 'Build successful' - echo 'Installing binary...' - - # Install to go/bin - cp ~/talkkonnect-binary ~/go/bin/talkkonnect - chmod +x ~/go/bin/talkkonnect - rm ~/talkkonnect-binary - - echo 'Installation complete' " local build_result=$? @@ -540,6 +532,33 @@ EOFOPUS return 1 fi + # Stop any running talkkonnect before installing + echo "Installing binary..." + if systemctl is-active --quiet talkkonnect 2>/dev/null; then + echo "Stopping existing talkkonnect service..." + sudo systemctl stop talkkonnect + fi + + # Kill any stray processes + if pgrep -x talkkonnect > /dev/null 2>&1; then + echo "Killing running talkkonnect processes..." + sudo pkill -9 talkkonnect + sleep 1 + fi + + # Now install as kiosk user + sudo -u "$KIOSK_USER" bash -c " + cp ~/talkkonnect-binary ~/go/bin/talkkonnect + chmod +x ~/go/bin/talkkonnect + rm ~/talkkonnect-binary + " + + if [[ $? -ne 0 ]]; then + log_error "Failed to install binary" + pause + return 1 + fi + log_success "talkkonnect built successfully" echo "[4/4] Creating configuration..." From 9a1425b1371c1eecfb0963f7b25364fcab8a91e6 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 23 Nov 2025 01:03:04 +0000 Subject: [PATCH 3/3] Fix talkkonnect status detection using systemd service file The status check was showing "Not installed" even after successful installation because it relied on PATH and file checks that weren't working reliably. Changes: - Check for /etc/systemd/system/talkkonnect.service first - This is the most reliable indicator of installation - Systemd service file is created during install and requires root - Falls back to command/file checks if service file doesn't exist This ensures status shows correctly immediately after installation. --- setup_intercom.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setup_intercom.sh b/setup_intercom.sh index 171cd40..91a6e57 100755 --- a/setup_intercom.sh +++ b/setup_intercom.sh @@ -69,7 +69,10 @@ check_talkkonnect_status() { local installed=false local running=false - if command -v talkkonnect &>/dev/null || [[ -f "/home/$KIOSK_USER/go/bin/talkkonnect" ]]; then + # Check if systemd service exists (most reliable indicator) + if [[ -f /etc/systemd/system/talkkonnect.service ]] || \ + command -v talkkonnect &>/dev/null || \ + [[ -f "/home/$KIOSK_USER/go/bin/talkkonnect" ]]; then installed=true if systemctl is-active --quiet talkkonnect; then running=true