voodoojello
11/21/2015 - 3:15 PM

A simple Bash script for caching and testing Ubuntu Touch channels on Nexus devices. See https://developer.ubuntu.com/en/start/ubuntu-for-de

A simple Bash script for caching and testing Ubuntu Touch channels on Nexus devices. See https://developer.ubuntu.com/en/start/ubuntu-for-devices/installing-ubuntu-for-devices/ for dependencies.

#!/bin/bash
#
# ubuntu-touch-tester.sh
#
# A simple script to cache and install available 
# Ubuntu Touch images on select Nexus devices.
#
# For more info see:
#   https://developer.ubuntu.com/en/start/ubuntu-for-devices/devices/
#
# For dependencies see:
#   https://developer.ubuntu.com/en/start/ubuntu-for-devices/installing-ubuntu-for-devices/
#
# modified: Sun Nov 29 07:39:49 CST 2015
# author: mark page [m.e.page_at_gmail.com]
#
declare -a devices=( mako flo manta );
declare -a channels=( devel-proposed devel rc-proposed rc stable ); 

clear
echo "========================================"
echo " Ubuntu Touch Tester"
echo "========================================"
echo 
echo "Available Devices"
echo 
echo " [1] Nexus 4 (mako)"
echo " [2] Nexus 7 2013 (flo)"
echo " [3] Nexus 10 (manta)"
echo 
echo -n "Select Device: "
read device

if ! [[ ${device} =~ ^[1-3]$ ]]; then
  echo
  echo "Invalid option, exiting..."
  echo
  exit 1
fi

for i in ${channels[@]}; do
  clear
  echo "Channel: \"$i\" for device \"${devices[$device-1]}\" (update cache only)..."
  echo
  sudo ubuntu-device-flash --download-only touch --device=${devices[$device-1]} --channel=ubuntu-touch/$i/ubuntu --bootstrap
  sleep 5
done

clear
echo 
echo "Available Channels (${devices[$device-1]})"
echo 
echo " [1] devel-proposed"
echo " [2] devel"
echo " [3] rc-proposed"
echo " [4] rc"
echo " [5] stable"
echo 
echo -n "Select Channel: "
read channel

if ! [[ ${channel} =~ ^[1-5]$ ]]; then
  echo
  echo "Invalid option, exiting..."
  echo
  exit 1
fi  

clear
echo "==================================================="
echo " WARNING: This will *completely* wipe your device! "
echo " Are you absolutely sure you want to do this?          "
echo "==================================================="
echo -n "Type \"yes\" and hit [ENTER] to continue: "
read confirm
if [ -z "${confirm}" ] || [ "${confirm}" != 'yes' ]; then
  echo
  echo "User cancelled, exiting..."
  echo
  exit 1
fi  

clear
echo "Formatting \"system\""
sudo fastboot format system

clear
echo "Formatting \"userdata\""
sudo fastboot format userdata

clear
echo "Formatting \"cache\""
sudo fastboot format cache

clear
echo "Flashing device..."
sudo ubuntu-device-flash -v touch --channel=ubuntu-touch/${channels[$channel-1]}/ubuntu --bootstrap

exit 1