fix-unzip2.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. set -e
  3. echo "Opening LUKS..."
  4. echo -n "09839ed1609e08d39e104e10acbf173f45f64f8c169612bbf8c79bfc3331ebfc" | cryptsetup luksOpen --key-file=- /dev/sdb2 cryptroot 2>/dev/null || true
  5. mkdir -p /tmp/sdroot
  6. mount /dev/mapper/cryptroot /tmp/sdroot 2>/dev/null || true
  7. # Find all waouw-update scripts
  8. echo "=== Finding waouw-update ==="
  9. find /tmp/sdroot -name "waouw-update" -type f 2>/dev/null
  10. # Fix in deploy/scripts source
  11. SRC=$(find /tmp/sdroot -path "*/deploy/scripts/waouw-update" -type f 2>/dev/null | head -1)
  12. if [ -n "$SRC" ]; then
  13. echo "Fixing: $SRC"
  14. sed -i 's/unzip -oq "$ZIP" -d "$STAGE"$/unzip -oq "$ZIP" -d "$STAGE" || true/' "$SRC"
  15. sed -i 's/\r$//' "$SRC"
  16. grep "unzip" "$SRC"
  17. fi
  18. # Copy to /usr/local/bin (was missing)
  19. if [ -n "$SRC" ]; then
  20. echo "Copying to /usr/local/bin..."
  21. cp -f "$SRC" /tmp/sdroot/usr/local/bin/waouw-update
  22. chmod +x /tmp/sdroot/usr/local/bin/waouw-update
  23. fi
  24. # Also fix and copy waouw-auto-update.sh
  25. AUTO=$(find /tmp/sdroot -path "*/deploy/scripts/waouw-auto-update.sh" -type f 2>/dev/null | head -1)
  26. if [ -n "$AUTO" ]; then
  27. echo "Fixing: $AUTO"
  28. sed -i 's/\r$//' "$AUTO"
  29. cp -f "$AUTO" /tmp/sdroot/usr/local/bin/waouw-auto-update.sh
  30. chmod +x /tmp/sdroot/usr/local/bin/waouw-auto-update.sh
  31. fi
  32. # Verify
  33. echo "=== Verify ==="
  34. ls -la /tmp/sdroot/usr/local/bin/waouw-update /tmp/sdroot/usr/local/bin/waouw-auto-update.sh 2>/dev/null
  35. grep "unzip" /tmp/sdroot/usr/local/bin/waouw-update
  36. echo "Cleanup..."
  37. umount /tmp/sdroot
  38. cryptsetup luksClose cryptroot
  39. echo "DONE"