~popey/+junk/phablet-flash-wrapper

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
#!/bin/bash
# Script to add ppa & apps and set timezone
#
# Script does the following:-
# * adds ppas
# * adds apps
# * sets timezone
#
# Assumptions:-
# * Device already running flipped build of Ubuntu Touch and is connected via USB
# * You're already connected to the network on the device
# * You live in London :)
#
# (c) 2013 Canonical - Alan Pope alan.pope@canonical.com

UBUNTU_ROOT="/"

function adb_root {
  echo ":: Run adb root"
  adb root
  if [ $? -ne "0" ]; then
    echo ":: adb root failed"
    exit 1
  fi
}

function pause {
    echo ":: Wait $1"
    sleep $1
}

function wait_for_device {
  echo -n ":: Waiting for device to come back ."
  STATE="unknown"
  while [ "$STATE" ==  "unknown" ];
  do
    echo -n "."
    STATE=`adb get-state`
    sleep 15
  done
  echo " "
}

echo ":: Enable developer mode"
adb shell touch /userdata/.writable_image
adb reboot
wait_for_device
pause 5

phablet-network
pause 10

echo ":: Build script to do post-install tasks"
TMP_FILE=$(mktemp)

cat > $TMP_FILE << 'EOF'
#!/bin/bash
export PATH="/sbin:/usr/sbin:/bin:/usr/bin" 
add-apt-repository -y ppa:ubuntu-touch-coreapps-drivers/collection
add-apt-repository -y ppa:ubuntu-touch-coreapps-drivers/daily
add-apt-repository -y ppa:popey/ppa
apt-get update
apt-get remove -y --purge demo-assets-music demo-assets-videos demo-assets-pictures webapps-demo-extras
apt-get install --yes touch-collection touch-coreapps mosh ssh vnstat pastebinit ssh uptimed predict bootchart
#perl -p -i -e 's/expandable\:\ false/expandable\:\ true/' /usr/share/unity8/Dash/Apps/ApplicationsFilterGrid.qml
echo "Europe/London" | sudo tee /etc/timezone
dpkg-reconfigure --frontend noninteractive tzdata
(crontab -l ; echo "* * * * * /home/phablet/powerstat.sh >> /home/phablet/battery.csv")| uniq - | crontab -
EOF

echo ":: Installing apps"
adb push $TMP_FILE $UBUNTU_ROOT/$TMP_FILE
adb push powerstat.sh /home/phablet/
adb shell chmod 755 $UBUNTU_ROOT/$TMP_FILE
adb shell chroot $UBUNTU_ROOT $UBUNTU_ROOT/$TMP_FILE

echo ":: Reboot device"
adb reboot

echo ":: Done"