janimo / textsecure

TextSecure client package for Go
GNU General Public License v3.0
129 stars 26 forks source link

Program fails silently if run from a daemon #32

Closed mbethke closed 8 years ago

mbethke commented 8 years ago

I'm trying to run this as a message delivery agent from Icinga. Cut down a little, this is the script I'm running as a notification command:

#!/bin/bash
read -d '' sms <<EOF
$NOTIFICATIONTYPE
Service: $SERVICEDESC on Host $HOSTALIAS is $SERVICESTATE
$SHORTDATETIME
EOF
/usr/local/bin/textsecure -config /etc/textsecure/ -to "$USERPAGER" -message "$sms"

When I set the variables and run it from an interactive shell, it works fine. It also works when running Icinga in the forground for debugging. However, it fails to do anything when running from a daemonized Icinga. However, it's not the controlling terminal alone that causes it to fail; as a non-interactive command via ssh it doesn't present any problem either.

I've tried various workarounds like running textsecure using script and unbuffer to fake a terminal, trying to persuade bash it's interactive with set -m, but to no avail. Sorry I don't have enough of a clue about Go to go hunting for the problem myself yet.

janimo commented 8 years ago

Can you capture its output or does it fail silently?

mbethke commented 8 years ago

Sorry, my bad: it boiled down to a permission problem in the config directory that I didn't know it needed to write to every time. It actually failed with "permission denied" but I'd been too thick to capture the output ...