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.
 
 
 
 
 

47 lines
1.0 KiB

  1. #!/bin/sh
  2. #supports_backup in PINN
  3. set -ex
  4. # shellcheck disable=SC2154
  5. if [ -z "$part1" ] || [ -z "$part2" ]; then
  6. printf "Error: missing environment variable part1 or part2\n" 1>&2
  7. exit 1
  8. fi
  9. mkdir -p /tmp/1 /tmp/2
  10. mount "$part1" /tmp/1
  11. mount "$part2" /tmp/2
  12. sed /tmp/1/cmdline.txt -i -e "s|root=[^ ]*|root=${part2}|"
  13. sed /tmp/2/etc/fstab -i -e "s|^[^#].* / |${part2} / |"
  14. sed /tmp/2/etc/fstab -i -e "s|^[^#].* /boot |${part1} /boot |"
  15. # shellcheck disable=SC2154
  16. if [ -z "$restore" ]; then
  17. if [ -f /mnt/ssh ]; then
  18. cp /mnt/ssh /tmp/1/
  19. fi
  20. if [ -f /mnt/ssh.txt ]; then
  21. cp /mnt/ssh.txt /tmp/1/
  22. fi
  23. if [ -f /settings/wpa_supplicant.conf ]; then
  24. cp /settings/wpa_supplicant.conf /tmp/1/
  25. fi
  26. if ! grep -q resize /proc/cmdline; then
  27. if ! grep -q splash /tmp/1/cmdline.txt; then
  28. sed -i "s| quiet||g" /tmp/1/cmdline.txt
  29. fi
  30. sed -i 's| init=/usr/lib/raspi-config/init_resize.sh||' /tmp/1/cmdline.txt
  31. else
  32. sed -i '1 s|.*|& sdhci.debug_quirks2=4|' /tmp/1/cmdline.txt
  33. fi
  34. fi
  35. umount /tmp/1
  36. umount /tmp/2