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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
#!/bin/sh
set -e
################################################################################
# Copyright 2012-2013 Canonical Ltd.
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
################################################################################
export HOME=/home/phablet
logdir=$HOME/.ubuntu-touch-session/logs/
logfile=$logdir/ubuntu-touch-session.log
bashrc=$HOME/.bashrc
[ -d $logdir ] || mkdir -p $logdir
[ -e $logfile ] && cp $logfile $logfile.old
echo "Redirecting output to local session logs"
exec 3>&1 4>&2 >$logfile 2>&1
on_stop()
{
echo "Stopping services..."
for pid in $pids; do
echo -n "Stopping $pid"
if kill $pid >/dev/null 2>&1; then
echo " done"
else
echo " failed"
fi
done
echo "Killing session bus..."
kill ${DBUS_SESSION_BUS_PID}
echo "Session stopped."
}
trap on_stop EXIT INT QUIT ILL KILL SEGV TERM
# Initialize environment
for var in $(cat /etc/environment); do
export $var
done
device=$(grep ^ro.product.device= /system/build.prop |sed -e 's/.*=//')
echo "Device=$device"
# defaults
GRID_UNIT_PX=18
QTWEBKIT_DPR=2.0
# override defaults by sourcing /etc/ubuntu-touch-session.d/$device.conf
[ -e /etc/ubuntu-touch-session.d/$device.conf ] && . /etc/ubuntu-touch-session.d/$device.conf
grep -q GRID_UNIT_PX $bashrc || echo "export GRID_UNIT_PX=${GRID_UNIT_PX}" >> $bashrc
grep -q QTWEBKIT_DPR $bashrc || echo "export QTWEBKIT_DPR=${QTWEBKIT_DPR}" >> $bashrc
export GRID_UNIT_PX=${GRID_UNIT_PX}
export QTWEBKIT_DPR=${QTWEBKIT_DPR}
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
echo "Starting session bus"
export $(dbus-launch)
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
echo "Unable to start session bus"
exit 1
fi
fi
echo "DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}" > $HOME/.dbus-session
echo "DBUS_SESSION_BUS_PID=${DBUS_SESSION_BUS_PID}" >> $HOME/.dbus-session
while read delay command args; do
command=${command##*/}
sleep $delay
$command $args >"$HOME/.ubuntu-touch-session/logs/$command.log" 2>&1 &
pids="$! $pids"
echo "Started $command with pid $! ($delay secs start delay)"
if [ "$command" = "unity8" ]; then
shell_pid=$!
echo "Got Shell pid = $shell_pid"
fi
done < /etc/device-services
wait $shell_pid
on_stop
|