~popey/+junk/phablet-flash-wrapper

1 by Alan Pope
initial version to add ppas and apps
1
#!/bin/bash
2 by Alan Pope
add backup and restore options
2
# Script to wrap phablet-flash
3
#
4
# Script does the following:-
5
# * Flash device (via phablet-flash)
6
# * Add applications from collections PPA
7
# * Reboot
8
#
9
# Assumptions:-
10
# * Device already running some build of Ubuntu Touch and is connected via USB
11
# * You're on Wifi and want the device to be on the same Wifi network
12
#
13
# (c) 2013 Canonical - Alan Pope alan.pope@canonical.com
14
15
UBUNTU_ROOT="/data/ubuntu"
16
17
function adb_root {
18
  echo ":: Run adb root"
19
  adb root
20
  if [ $? -ne "0" ]; then
21
    echo ":: adb root failed"
22
    exit 1
23
  fi
24
}
25
26
function pause {
3 by Alan Pope
Fix scripts so restore actually restores to the right place. Doh
27
    echo ":: Wait $1"
2 by Alan Pope
add backup and restore options
28
    sleep $1
29
}
30
3 by Alan Pope
Fix scripts so restore actually restores to the right place. Doh
31
function wait_for_device {
32
  echo -n ":: Waiting for device to come back ."
33
  STATE="unknown"
34
  while [ "$STATE" ==  "unknown" ];
35
  do
36
    echo -n "."
37
    STATE=`adb get-state`
38
    sleep 15
39
  done
40
  echo " "
41
}
42
2 by Alan Pope
add backup and restore options
43
adb_root
44
45
pause 5
46
47
echo ":: Delete old zip files to possibly regain space from /sdcard"
48
adb shell rm -r /sdcard/*.zip
49
50
echo ":: Flash device"
22 by Alan Pope
add script to reboot lots and look for cpu being eaten
51
phablet-flash cdimage-touch
2 by Alan Pope
add backup and restore options
52
FLASH_RESULT=$?
53
if [ $FLASH_RESULT == "0" ]; then
54
  echo ":: Flash success"
55
else
56
  echo ":: Flash failed"
57
  exit 1
58
fi
59
3 by Alan Pope
Fix scripts so restore actually restores to the right place. Doh
60
wait_for_device
8 by Alan Pope
clean up
61
pause 10
2 by Alan Pope
add backup and restore options
62
adb_root
63
pause 5
8 by Alan Pope
clean up
64
2 by Alan Pope
add backup and restore options
65
echo ":: Build script to do post-install tasks"
1 by Alan Pope
initial version to add ppas and apps
66
TMP_FILE=$(mktemp)
67
68
cat > $TMP_FILE << 'EOF'
69
#!/bin/bash
70
export PATH="/sbin:/usr/sbin:/bin:/usr/bin" 
71
add-apt-repository -y ppa:ubuntu-touch-coreapps-drivers/collection
72
add-apt-repository -y ppa:ubuntu-touch-coreapps-drivers/daily
73
apt-get update
2 by Alan Pope
add backup and restore options
74
apt-get install --yes touch-collection touch-coreapps
1 by Alan Pope
initial version to add ppas and apps
75
perl -p -i -e 's/false/true/' /usr/share/qml-phone-shell/Dash/Apps/ApplicationsFilterGrid.qml
76
EOF
77
78
echo ":: Installing apps"
2 by Alan Pope
add backup and restore options
79
adb push $TMP_FILE $UBUNTU_ROOT/$TMP_FILE
80
adb shell chmod 755 $UBUNTU_ROOT/$TMP_FILE
81
adb shell chroot $UBUNTU_ROOT $UBUNTU_ROOT/$TMP_FILE
82
83
pause 10
1 by Alan Pope
initial version to add ppas and apps
84
85
echo ":: Reboot"
86
adb reboot
87
3 by Alan Pope
Fix scripts so restore actually restores to the right place. Doh
88
wait_for_device
89
90
echo ":: Delete old zip files to possibly regain space from /sdcard"
91
adb shell rm -r /sdcard/*.zip
92
93
echo ":: Done"
94
95
96