~michael-sheldon/ubuntu-touch-session/fix-1659388

1 by Ricardo Mendoza
Initial commit
1
#!/bin/bash
2
6.1.1 by Ricardo Mendoza
Change default session user
3
export HOME=/home/phablet
4.1.1 by Ricardo Mendoza
* Add per-service logging support
4
echo "Redirecting output to local session logs"
5
exec &> "$HOME/.ubuntu-session/logs/ubuntu-session.log"
6
3.1.1 by Ricardo Mendoza
* Pass a list of services to start depending on the device
7
on_stop()
8
{
4.1.1 by Ricardo Mendoza
* Add per-service logging support
9
    echo "Stopping services..."
10
    for pid in "${pids[@]}"
11
    do
12
        tuple=( $pid )
13
        echo "Stopping ${tuple[0]}"
14
        kill ${tuple[1]}
15
    done
16
    echo "Killing session bus..."
3.1.1 by Ricardo Mendoza
* Pass a list of services to start depending on the device
17
    kill ${DBUS_SESSION_BUS_PID}
4.1.1 by Ricardo Mendoza
* Add per-service logging support
18
    echo "Session stopped."
3.1.1 by Ricardo Mendoza
* Pass a list of services to start depending on the device
19
}
20
1.1.3 by Ricardo Mendoza
Fix dbus session bring up
21
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
1 by Ricardo Mendoza
Initial commit
22
    echo "Starting session bus"
3.1.1 by Ricardo Mendoza
* Pass a list of services to start depending on the device
23
    export `dbus-launch`
1.1.3 by Ricardo Mendoza
Fix dbus session bring up
24
    if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
25
        echo "Unable to start session bus"
1 by Ricardo Mendoza
Initial commit
26
        exit 1
27
    fi
28
fi
29
30
# Initialize shell, env, etc
31
32
export HOSTNAME=android
33
export SHELL=/system/bin/sh
8.1.1 by Bill Filler
* export LANG and LANGUAGE as they are needed by apps
34
export TERM=linux
1 by Ricardo Mendoza
Initial commit
35
export ANDROID_CACHE=/cache
36
export LOOP_MOUNTPOINT=/mnt/obb
37
export ASEC_MOUNTPOINT=/mnt/asec
38
export ANDROID_PROPERTY_WORKSPACE=8,49152
39
export ANDROID_ASSETS=/system/app
40
export ANDROID_BOOTLOGO=1
6.1.1 by Ricardo Mendoza
Change default session user
41
export USER=phablet
1 by Ricardo Mendoza
Initial commit
42
export LD_LIBRARY_PATH=/opt/qt5/lib:/vendor/lib:/system/lib
43
export QML_IMPORT_PATH=/opt/qt5/imports
44
export QT_FONT_PATH=/opt/qt5/lib/fonts
45
export PATH=/opt/qt5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
46
export ANDROID_DATA=/data
47
export QT_QPA_PLATFORM=hybris
48
export SHLVL=1
49
export MKSH=/system/bin/sh
50
export ANDROID_ROOT=/system
51
export EXTERNAL_STORAGE=/mnt/sdcard
52
export QT_PLUGIN_PATH=/opt/qt5/plugins
8.1.1 by Bill Filler
* export LANG and LANGUAGE as they are needed by apps
53
export LANG=en_US.UTF-8
54
export LANGUAGE=en_US:en
12.1.1 by Ricardo Mendoza
Add maliit as default input method
55
export QT_IM_MODULE=maliit
1 by Ricardo Mendoza
Initial commit
56
3.1.1 by Ricardo Mendoza
* Pass a list of services to start depending on the device
57
echo "DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}" > $HOME/.dbus-session
58
echo "DBUS_SESSION_BUS_PID=${DBUS_SESSION_BUS_PID}" >> $HOME/.dbus-session
1.1.3 by Ricardo Mendoza
Fix dbus session bring up
59
1 by Ricardo Mendoza
Initial commit
60
device=`grep Hardware /proc/cpuinfo | awk '{print $3}'`
61
62
if [ "$device" == "ventana" ]; then
3.1.1 by Ricardo Mendoza
* Pass a list of services to start depending on the device
63
    services="/etc/tablet-services"
7.1.1 by Ricardo Mendoza
Set resolution independence rules for the user session
64
    export GRID_UNIT_PX=10
1 by Ricardo Mendoza
Initial commit
65
else
3.1.1 by Ricardo Mendoza
* Pass a list of services to start depending on the device
66
    services="/etc/phone-services"
7.1.1 by Ricardo Mendoza
Set resolution independence rules for the user session
67
    export GRID_UNIT_PX=18
1 by Ricardo Mendoza
Initial commit
68
fi
3.1.1 by Ricardo Mendoza
* Pass a list of services to start depending on the device
69
4.1.1 by Ricardo Mendoza
* Add per-service logging support
70
if [ ! -d "$HOME/.ubuntu-session/logs/" ]; then
71
    mkdir -p "$HOME/.ubuntu-session/logs"
72
fi
73
3.1.1 by Ricardo Mendoza
* Pass a list of services to start depending on the device
74
while read service; do
5.1.1 by Ricardo Mendoza
Fix problem when having more than one argument
75
    service=( $service )
76
    arguments=${service[@]:1}
77
    service_path=( $(echo "${service[0]}" | tr "/" " ") )
4.1.1 by Ricardo Mendoza
* Add per-service logging support
78
    binary=${service_path[${#service_path[@]}-1]}
5.1.1 by Ricardo Mendoza
Fix problem when having more than one argument
79
    ${service[0]} $arguments &> "$HOME/.ubuntu-session/logs/$binary.log" &
80
    pids=("${pids[@]}" "${service[0]} $!")
81
    echo "Started ${service[0]} with pid $!"
14.1.1 by Ricardo Mendoza
Introduce delay on start-up of services to wait for completion.
82
    sleep 3
3.1.1 by Ricardo Mendoza
* Pass a list of services to start depending on the device
83
done < "$services"
84
85
trap 'on_stop' TERM
86
87
wait