24 lines
925 B
Bash
24 lines
925 B
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
script="$(dirname "$0")/configure-asterisk-user-hep.sh"
|
|
root=$(mktemp -d)
|
|
trap 'rm -rf -- "$root"' EXIT
|
|
mkdir -p "$root/.config/go-sip-asterisk"
|
|
printf '[directories]\n' >"$root/.config/go-sip-asterisk/asterisk.conf"
|
|
for addr in 0.0.0.0:19060 localhost:19060 127.0.0.1:0 127.0.0.1:abc; do
|
|
if HOME="$root" bash "$script" "$addr" >/dev/null 2>&1; then
|
|
echo "unexpected HEP address admitted: $addr" >&2; exit 1
|
|
fi
|
|
done
|
|
[[ ! -e "$root/.config/go-sip-asterisk/hep.conf" ]]
|
|
HOME="$root" bash "$script" 127.0.0.1:19060
|
|
conf="$root/.config/go-sip-asterisk/hep.conf"
|
|
grep -qx 'enabled = yes' "$conf"
|
|
grep -qx 'capture_address = 127.0.0.1:19060' "$conf"
|
|
grep -qx 'uuid_type = call-id' "$conf"
|
|
[[ $(stat -c '%a' "$conf") == 600 ]]
|
|
if HOME="$root" bash "$script" 127.0.0.1:19060 >/dev/null 2>&1; then
|
|
echo 'existing HEP config was overwritten' >&2; exit 1
|
|
fi
|
|
printf 'HEP config: passed\n'
|