A short example of using subtree for stuff.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.9 KiB

  1. #!/usr/bin/env bash
  2. set -e
  3. function print_help() {
  4. echo "Usage: $0 -t [pitfttype]"
  5. echo " -h Print this help"
  6. echo " -t [type] Specify the type of PiTFT: '28r' (PID 1601) or '28c' (PID 1983) or '35r' or '22'"
  7. echo
  8. echo "You must specify a type of display."
  9. exit 1
  10. }
  11. args=$(getopt -uo 'ht:i:' -- $*)
  12. [ $? != 0 ] && print_help
  13. set -- $args
  14. for i
  15. do
  16. case "$i"
  17. in
  18. -h)
  19. print_help
  20. ;;
  21. -t)
  22. pitfttype="$2"
  23. echo "Type = ${2}"
  24. shift
  25. shift
  26. ;;
  27. -i)
  28. target_image="$2"
  29. echo "Image = ${2}"
  30. shift
  31. shift
  32. ;;
  33. esac
  34. done
  35. if [[ $EUID -ne 0 ]]; then
  36. echo "$0 must be run as root. try: sudo $0"
  37. exit 1
  38. fi
  39. if [ "${pitfttype}" != "28r" ] && [ "${pitfttype}" != "28c" ] && [ "${pitfttype}" != "35r" ] && [ "${pitfttype}" != "22" ]
  40. then
  41. echo "Type must be '28r' (2.8\" resistive, PID 1601) or '28c' (2.8\" capacitive, PID 1983) or '35r' (3.5\" Resistive) or '22' (2.2\" no touch)"
  42. print_help
  43. fi
  44. target_mnt="/media/raspbian-target"
  45. echo "Mounting $target_image on $target_mnt"
  46. kpartx -av $target_image
  47. mkdir -p $target_mnt
  48. mount /dev/mapper/loop0p2 $target_mnt
  49. mount /dev/mapper/loop0p1 $target_mnt/boot
  50. echo "Adding apt.adafruit.com to sources.list"
  51. curl -SLs https://apt.adafruit.com/add | chroot $target_mnt /bin/bash
  52. echo "Installing adafruit-pitft-helper and dependencies"
  53. chroot $target_mnt sudo apt-get install adafruit-pitft-helper
  54. echo "Running adafruit-pitft-helper"
  55. chroot $target_mnt sudo adafruit-pitft-helper -t $pitfttype
  56. echo "Dropping you into Bash"
  57. chroot $target_mnt sudo /bin/bash
  58. echo "Unmounting $target_image"
  59. umount $target_mnt/boot
  60. umount $target_mnt
  61. kpartx -d $target_image