FstabEdit 2.4 KB

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