setup 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/sh
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 2 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. set -e
  16. vardir="$1"
  17. method=$2
  18. option=$3
  19. cd "$vardir/methods/floppy"
  20. defaultfloppy=fd0
  21. defaultfstype=msdos
  22. if [ -f shvar.$option ]
  23. then
  24. . ./shvar.$option
  25. defaultfloppy="`echo \"$defaultfloppy\" | sed -e 's,^/dev/,,'`"
  26. fi
  27. while [ -z "$floppy" ]
  28. do
  29. echo -n '
  30. Which floppy disk drive do you wish to use ? Give the name in
  31. /dev (eg fd0) or the MSDOS drive letter (eg A). ['$defaultfloppy'] '
  32. read floppy
  33. if [ -z "$floppy" ]
  34. then
  35. floppy="$defaultfloppy"
  36. fi
  37. case "$floppy" in
  38. [ABab] | [ABab]: )
  39. floppy="`echo $floppy | \
  40. sed -e 's/:$//; s,^[Aa],/dev/fd0,; s,^[Bb],/dev/fd1,'`"
  41. ;;
  42. /* )
  43. ;;
  44. * )
  45. floppy="/dev/$floppy"
  46. ;;
  47. esac
  48. if ! [ -b "$floppy" ]
  49. then
  50. echo "$floppy is not a block device."
  51. floppy=""
  52. fi
  53. done
  54. while [ -z "$fstype" ]
  55. do
  56. echo -n '
  57. What kind of filesystem is on the floppies ? ['$defaultfstype'] '
  58. read fstype
  59. if [ -z "$fstype" ]
  60. then
  61. fstype="$defaultfstype"
  62. fi
  63. if ! grep " $fstype$" /proc/filesystems >/dev/null
  64. then
  65. echo \
  66. "Your kernel does not appear to support that filesystem type."
  67. fstype=""
  68. fi
  69. done
  70. echo
  71. outputparam () {
  72. echo "$2" | sed -e "s/'/'\\\\''/; s/^/$1='/; s/$/'/" >&3
  73. }
  74. exec 3>shvar.$option.new
  75. outputparam defaultfloppy "$floppy"
  76. outputparam defaultfstype "$fstype"
  77. mv shvar.$option.new shvar.$option
  78. exit 0