FstabEdit 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # This file is part of the 'dragora-installer'.
  2. #
  3. # Purpose: Edition of the file system table (fstab).
  4. # Re-order fstab adding information
  5. sort -k 1 "${SUBTMPDIR}/fstab" | uniq > "${SUBTMPDIR}/fstab.sorted"
  6. # To avoid populating the fstab twice (eg. when 'PRESERVE' is given)
  7. if test ! -e "${SUBTMPDIR}/FstabEdit.flag"
  8. then
  9. cat << EOF > "${SUBTMPDIR}/fstab"
  10. #
  11. # /etc/fstab - Static information about the filesystems.
  12. #
  13. # For more information, type "man 5 fstab".
  14. #
  15. # Filesystem Mountpoint Type Options Dump|Check
  16. EOF
  17. cat "${SUBTMPDIR}/fstab.sorted" >> "${SUBTMPDIR}/fstab"
  18. printf '%-43s %-14s %-12s %-16s %-3s %s\n' \
  19. "/dev/fd0" "/media/floppy" "auto" "noauto,owner,rw" "0" "0" \
  20. "#/dev/cdrom" "/media/cdrom" "iso9660,udf" "noauto,owner,ro" "0" "0" \
  21. "tmp" "/tmp" "tmpfs" "defaults" "0" "0" \
  22. >> "${SUBTMPDIR}/fstab"
  23. touch "${SUBTMPDIR}/FstabEdit.flag"
  24. fi
  25. # Show menu to edit the produced fstab (if desired)
  26. dialog --no-shadow --colors \
  27. --backtitle "\\ZbFile system table information" \
  28. --title "FILE SYSTEM TABLE EDITOR" \
  29. --ok-label "Save/Continue" --no-cancel \
  30. --defaultno --editbox "${SUBTMPDIR}/fstab" \
  31. $((LINES - 8)) $COLUMNS 2> "${SUBTMPDIR}/fstab.edit"
  32. # Check for differences and offer menu to view or apply changes
  33. diff -u "${SUBTMPDIR}/fstab" "${SUBTMPDIR}/fstab.edit" \
  34. > "${SUBTMPDIR}/fstab.diff" 2> /dev/null || true
  35. if test -s "${SUBTMPDIR}/fstab.diff"
  36. then
  37. while true
  38. do
  39. dialog --colors \
  40. --backtitle "\\ZbFile system table modification" \
  41. --title "FILE SYSTEM TABLE FROM THE INSTALLER" \
  42. --help-button --help-label "View Diff" \
  43. --cr-wrap --yesno \
  44. "The file system table has been modified.
  45. Would you like to apply the changes made?. If you choose 'No',
  46. the installer will continue with the default fstab file.
  47. " 8 66 || _status=$?
  48. case "${_status:-0}" in
  49. 0) ## Button "Yes"
  50. cp -f -- "${SUBTMPDIR}/fstab.edit" "${SUBTMPDIR}/fstab"
  51. break;
  52. ;;
  53. 1) ## Button "No"
  54. break;
  55. ;;
  56. 2) ## Button "View Diff"
  57. dialog --no-shadow --colors \
  58. --backtitle \
  59. "\\ZbFile system table modification (unified difference)" \
  60. --title "FILE SYSTEM TABLE CHANGES" \
  61. --exit-label "Return" \
  62. --cr-wrap --textbox "${SUBTMPDIR}/fstab.diff" \
  63. $((LINES - 8)) $COLUMNS || continue;
  64. ;;
  65. *) ## "Escape from L.A"
  66. unset -v _status
  67. return 99;
  68. esac
  69. done
  70. unset -v _status
  71. fi