summaryrefslogtreecommitdiffstats
path: root/web-gui/login/run.sh.in
blob: 91545915b98c1ffe41f74fa878a1b4eb3f1dbd80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
#
# json dbus bridge
#
# Copyright (c) 2010 by Michael Olbrich <m.olbrich@pengutronix.de>
#
# To the extent possible under law, Pengutronix e.K. has waived all copyright
# and related or neighboring rights to JSON-DBus-Bridge Demo Code.
#

if [ "`whoami`" != "root" ]; then
	echo This script must be run by root.
fi

if [ ! -f "@abs_builddir@/build/index.html" ]; then
	echo
	echo 'You must run "make" before running this script'
	echo
	exit 1
fi

finish() {
	kill $hello_pid
	kill $lighttpd_pid
	kill $jdb_user_pid
	kill $jdb_admin_pid
	kill $DBUS_SESSION_BUS_PID
	exit
}

trap finish SIGINT

eval `su -c "dbus-launch --config-file='@abs_builddir@/dbus-session.conf' --sh-syntax" @LIGHTTPD_USER@`

su -c "@abs_top_srcdir@/services/python/hello-world.py" @LIGHTTPD_USER@ &
hello_pid=$!

su -c "'@JSON_DBUS_BRIDGE@' '/tmp/json-dbus-bridge.user.socket'" @USER_ROLE@ &
jdb_user_pid=$!

su -c "'@JSON_DBUS_BRIDGE@' '/tmp/json-dbus-bridge.admin.socket'" @ADMIN_ROLE@ &
jdb_admin_pid=$!
sleep 0.5
chmod a+rw '/tmp/json-dbus-bridge.admin.socket'

su -c "@LIGHTTPD@ -f '@abs_builddir@/lighttpd.conf' -D" @LIGHTTPD_USER@ &
lighttpd_pid=$!

echo -n "waiting for lighttpd "
for i in `seq 10`; do
	sleep 1
	echo -n "."
	wget -e no_proxy=localhost -O - -q http://localhost:8080/ > /dev/null && break
done

if [ $? -ne 0 ]; then
	echo
	echo
	echo starting lighttpd failed!
	finish
	exit 1
else
	echo
	echo
	echo lighttpd sucessfully started.
	echo
	echo The demo page can be view at http://localhost:8080/
fi

while [ 1 ]; do
	sleep 100
done