diff options
author | Andrew Cady <d@jerkface.net> | 2018-12-09 03:58:58 -0500 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2018-12-09 03:58:58 -0500 |
commit | f4bd641e36418bc2a43bc31d8ac0bf57b1c51953 (patch) | |
tree | f565e29f956152fdb53c2a5042714de5bbb202ab /dot/local/bin/linlaunch | |
parent | 7aa3cd0a0e2961388df2cc11665dabef2250d6d7 (diff) |
new commands
Diffstat (limited to 'dot/local/bin/linlaunch')
-rwxr-xr-x | dot/local/bin/linlaunch | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/dot/local/bin/linlaunch b/dot/local/bin/linlaunch new file mode 100755 index 0000000..20ebc7a --- /dev/null +++ b/dot/local/bin/linlaunch | |||
@@ -0,0 +1,58 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | linphone_socket=/tmp/linphonec-$(id -u) | ||
4 | |||
5 | warn() { printf '%s\n' "$0" "${*:-something is wrong.}" >&2; } | ||
6 | die() { warn "$@"; exit 1; } | ||
7 | |||
8 | init() | ||
9 | { | ||
10 | out=$(linphonecsh init -CD 2>&1) | ||
11 | [ -z "$out" ] && return | ||
12 | case "$out" in | ||
13 | *'running linphonec has been found'*) | ||
14 | printf '%s\n' "$out" >&2 | ||
15 | return 1 ;; | ||
16 | '') | ||
17 | return 0 ;; | ||
18 | *) | ||
19 | die "Error: unexpected output from linphonecsh: $out" ;; | ||
20 | esac | ||
21 | } | ||
22 | |||
23 | wait_for_linphone_socket() | ||
24 | { | ||
25 | for n in $(seq 1 50); do | ||
26 | test -e ${linphone_socket} && break | ||
27 | sleep 0.1 | ||
28 | done | ||
29 | } | ||
30 | |||
31 | getip() | ||
32 | { | ||
33 | upnpc -s|sed -ne 's/^ExternalIPAddress = //p' | ||
34 | } | ||
35 | |||
36 | generic() | ||
37 | { | ||
38 | linphonecsh generic "$*" | ||
39 | } | ||
40 | |||
41 | atexit() | ||
42 | { | ||
43 | if [ "$kill_linphonec" ]; then | ||
44 | linphonecsh exit | ||
45 | fi | ||
46 | } | ||
47 | |||
48 | init | ||
49 | trap atexit EXIT | ||
50 | |||
51 | wait_for_linphone_socket | ||
52 | |||
53 | if ip=$(getip); then | ||
54 | generic nat $ip | ||
55 | generic firewall nat | ||
56 | fi | ||
57 | |||
58 | generic friend list | ||