summaryrefslogtreecommitdiff
path: root/dot/local/bin/linlaunch
diff options
context:
space:
mode:
Diffstat (limited to 'dot/local/bin/linlaunch')
-rwxr-xr-xdot/local/bin/linlaunch58
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
3linphone_socket=/tmp/linphonec-$(id -u)
4
5warn() { printf '%s\n' "$0" "${*:-something is wrong.}" >&2; }
6die() { warn "$@"; exit 1; }
7
8init()
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
23wait_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
31getip()
32{
33 upnpc -s|sed -ne 's/^ExternalIPAddress = //p'
34}
35
36generic()
37{
38 linphonecsh generic "$*"
39}
40
41atexit()
42{
43 if [ "$kill_linphonec" ]; then
44 linphonecsh exit
45 fi
46}
47
48init
49trap atexit EXIT
50
51wait_for_linphone_socket
52
53if ip=$(getip); then
54 generic nat $ip
55 generic firewall nat
56fi
57
58generic friend list