home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 4 / MA_Cover_4.iso / netbsd / installation / miniroot / miniroot.fs / install.md < prev    next >
Encoding:
Text File  |  1997-11-30  |  8.4 KB  |  308 lines

  1. #    $NetBSD: install.md,v 1.3.2.5 1997/11/21 23:09:42 is Exp $
  2. #
  3. #
  4. # Copyright (c) 1996 The NetBSD Foundation, Inc.
  5. # All rights reserved.
  6. #
  7. # This code is derived from software contributed to The NetBSD Foundation
  8. # by Jason R. Thorpe.
  9. #
  10. # Redistribution and use in source and binary forms, with or without
  11. # modification, are permitted provided that the following conditions
  12. # are met:
  13. # 1. Redistributions of source code must retain the above copyright
  14. #    notice, this list of conditions and the following disclaimer.
  15. # 2. Redistributions in binary form must reproduce the above copyright
  16. #    notice, this list of conditions and the following disclaimer in the
  17. #    documentation and/or other materials provided with the distribution.
  18. # 3. All advertising materials mentioning features or use of this software
  19. #    must display the following acknowledgement:
  20. #        This product includes software developed by the NetBSD
  21. #        Foundation, Inc. and its contributors.
  22. # 4. Neither the name of The NetBSD Foundation nor the names of its
  23. #    contributors may be used to endorse or promote products derived
  24. #    from this software without specific prior written permission.
  25. #
  26. # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  27. # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  28. # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  29. # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  30. # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31. # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32. # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34. # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. # POSSIBILITY OF SUCH DAMAGE.
  37. #
  38.  
  39. #
  40. # machine dependent section of installation/upgrade script.
  41. #
  42.  
  43. # Machine-dependent install sets
  44. MDSETS="xbase xcomp xcontrib xfont xserver"
  45.  
  46. md_set_term() {
  47.     if [ ! -z "$TERM" ]; then
  48.         return
  49.     fi
  50.     echo -n "Specify terminal type [vt220]: "
  51.     getresp "vt220"
  52.     TERM="$resp"
  53.     export TERM
  54. }
  55.  
  56. __mount_kernfs() {
  57.     #
  58.     # Force kern_fs to be mounted
  59.     #
  60.     if [ ! -d /kern -o ! -e /kern/msgbuf ]; then
  61.         mkdir /kern > /dev/null 2>&1
  62.         /sbin/mount_kernfs /kern /kern >/dev/null 2>&1
  63.     fi
  64. }
  65.  
  66. md_makerootwritable() {
  67.     # Mount root rw for convenience of the tester ;-)
  68.     if [ ! -e /tmp/.root_writable ]; then
  69.         __mount_kernfs
  70.         # XXX: Use /kern/rootdev instead?
  71.         mount -u /kern/rootdev / > /dev/null 2>&1
  72.         cp /dev/null /tmp/.root_writable
  73.     fi
  74. }
  75.  
  76. md_get_diskdevs() {
  77.     # return available disk devices
  78.     __mount_kernfs
  79.     sed -n -e '/^[sw]d[0-9] /s/ .*//p' \
  80.         < /kern/msgbuf | sort -u
  81. }
  82.  
  83. md_get_cddevs() {
  84.     # return available CDROM devices
  85.     __mount_kernfs
  86.     sed -n -e '/^cd[0-9] /s/ .*//p' \
  87.         < /kern/msgbuf | sort -u
  88. }
  89.  
  90. md_get_partition_range() {
  91.     # return an expression describing the valid partition id's
  92.     echo '[a-p]'
  93. }
  94.  
  95. md_installboot() {
  96.     if [ -x /mnt/usr/mdec/installboot ]; then
  97.         echo -n "Should a boot block be installed? [y] "
  98.         getresp "y"
  99.         case "$resp" in
  100.             y*|Y*)
  101.                 echo "Installing boot block..."
  102.                 chroot /mnt /usr/mdec/installboot /usr/mdec/xxboot /dev/r${1}a
  103.                 ;;
  104.             *)
  105.                 echo "No bootblock installed..."
  106.                 ;;
  107.         esac
  108.     elif [ "$MODE" = "install" ]; then
  109.         cat << \__md_installboot_1
  110. There is no installboot program found on the installed filesystems. No boot
  111. programs are installed.
  112. __md_installboot_1
  113.     else
  114.         cat << \__md_installboot_2
  115. There is no installboot program found on the upgraded filesystems. No boot
  116. programs are installed.
  117. __md_installboot_2
  118.     fi
  119. }
  120.  
  121. md_native_fstype() {
  122.     echo "ados"
  123. }
  124.  
  125. md_native_fsopts() {
  126.     echo "ro"
  127. }
  128.  
  129. md_prep_disklabel() {
  130.     _DKDEVS=`md_get_diskdevs`
  131.     echo "If you like, you can now examine the labels of your disks."
  132.     echo ""
  133.     echo -n "Available are "${_DKDEVS}". Look at which? [skip this step] "
  134.     while [ "X$resp" != X"done" ]; do
  135.         getresp    "done"
  136.         echo ""
  137.         disklabel ${resp}
  138.         echo ""
  139.         echo -n "Available are "${_DKDEVS}". Look at which? [done] "
  140.     done
  141. }
  142.  
  143. md_labeldisk() {
  144. }
  145.  
  146. md_welcome_banner() {
  147.     if [ "$MODE" = "install" ]; then
  148.         echo ""
  149.         echo "Welcome to the NetBSD/amiga ${VERSION} installation program."
  150.         cat << \__welcome_banner_1
  151.  
  152. This program is designed to help you put NetBSD on your disk,
  153. in a simple and rational way.  You'll be asked several questions,
  154. and it would probably be useful to have your disk's hardware
  155. manual, the installation notes, and a calculator handy.
  156. __welcome_banner_1
  157.  
  158.     else
  159.         echo ""
  160.         echo "Welcome to the NetBSD/amiga ${VERSION} upgrade program."
  161.         cat << \__welcome_banner_2
  162.  
  163. This program is designed to help you upgrade your NetBSD system in a
  164. simple and rational way.
  165.  
  166. As a reminder, installing the `etc' binary set is NOT recommended.
  167. Once the rest of your system has been upgraded, you should manually
  168. merge any changes to files in the `etc' set into those files which
  169. already exist on your system.
  170. __welcome_banner_2
  171.     fi
  172.  
  173. cat << \__welcome_banner_3
  174.  
  175. As with anything which modifies your disk's contents, this
  176. program can cause SIGNIFICANT data loss, and you are advised
  177. to make sure your data is backed up before beginning the
  178. installation process.
  179.  
  180. Default answers are displayed in brackets after the questions.
  181. You can hit Control-C at any time to quit, but if you do so at a
  182. prompt, you may have to hit return.  Also, quitting in the middle of
  183. installation may leave your system in an inconsistent state.
  184.  
  185. __welcome_banner_3
  186. }
  187.  
  188. md_not_going_to_install() {
  189.     cat << \__not_going_to_install_1
  190.  
  191. OK, then.  Enter `halt' at the prompt to halt the machine.  Once the
  192. machine has halted, power-cycle the system to load new boot code.
  193.  
  194. Note: If you wish to have another try. Just type '^D' at the prompt. After
  195.       a moment, the installer will restart itself.
  196.  
  197. __not_going_to_install_1
  198. }
  199.  
  200. md_congrats() {
  201.     local what;
  202.     if [ "$MODE" = "install" ]; then
  203.         what="installed";
  204.     else
  205.         what="upgraded";
  206.     fi
  207.     cat << __congratulations_1
  208.  
  209. CONGRATULATIONS!  You have successfully $what NetBSD!
  210. To boot the installed system, enter halt at the command prompt. Once the
  211. system has halted, reset the machine and boot from the disk.
  212.  
  213. Note: If you wish to have another try. Just type '^D' at the prompt. After
  214.       a moment, the installer will restart itself.
  215.  
  216. __congratulations_1
  217. }
  218.  
  219. md_copy_kernel() {
  220.     # This is largely a copy of install_disk and install_from_mounted_fs()
  221.     # with some special frobbing.
  222.  
  223.     local _directory
  224.     local _sets
  225.     local _filename
  226.     local _f
  227.  
  228.     if [ "$MODE" = "install" ]; then
  229.         echo -n "Adding keymap initialization to rc.local..."
  230.         echo /usr/sbin/loadkmap ${__keymap__} >> /mnt/etc/rc.local
  231.         echo "done."
  232.     fi
  233.  
  234.     if [ -e /netbsd ]; then
  235.         echo -n "Copying kernel..."
  236.         cp -p /netbsd /mnt/netbsd
  237.         echo "done."
  238.         return
  239.     fi
  240.  
  241. cat << \__md_copy_kernel_1
  242. Your installation set did not include a netbsd kernel on the installation
  243. filesystem. You are now given the opportunity install it from either the
  244. kernel-floppy from the distribution or another location on one of your disks.
  245.  
  246. The following disk devices are installed on your system; please select
  247. the disk device containing the partition with the netbsd kernel:
  248. __md_copy_kernel_1
  249.  
  250.     _DKDEVS=`md_get_diskdevs`
  251.     echo    "$_DKDEVS"
  252.     echo    "fd0"
  253.     echo    ""
  254.     _DKDEVS="$_DKDEVS fd0"        # Might be on the kernel floppy!
  255.     echo -n    "Which is the disk with the kernel? [abort] "
  256.  
  257.     if mount_a_disk ; then
  258.         return    # couldn't mount the disk
  259.     fi
  260.  
  261.     # Get the directory where the file lives
  262.     resp=""        # force one iteration
  263.     while [ "X${resp}" = X"" ]; do
  264.         echo "Enter the directory relative to the mount point that"
  265.         echo -n "contains the file. [${_directory}] "
  266.         getresp "${_directory}"
  267.     done
  268.     _directory=$resp
  269.  
  270.     _sets=`(cd /mnt2/$_directory; ls netbsd* 2> /dev/null)`
  271.     if [ -z "$_sets" ]; then
  272.         echo "There are no NetBSD kernels available in \"$1\""
  273.         umount -f /mnt2 > /dev/null 2>&1
  274.         return
  275.     fi
  276.     while : ; do
  277.         echo "The following kernels are available:"
  278.         echo ""
  279.  
  280.         for _f in $_sets ; do
  281.             echo "    $_f"
  282.         done
  283.         echo ""
  284.         set -- $_sets
  285.         echo -n "File name [$1]? "
  286.         getresp "$1"
  287.         _f=$resp
  288.         _filename="/mnt2/$_directory/$_f"
  289.  
  290.         # Ensure file exists
  291.         if [ ! -f $_filename ]; then
  292.             echo "File $_filename does not exist.  Check to make"
  293.             echo "sure you entered the information properly."
  294.             echo -n "Do you want to retry [y]? "
  295.             getresp "y"
  296.             if [ "$resp" = "n" ]; then
  297.                 break
  298.             fi
  299.             continue
  300.         fi
  301.  
  302.         # Copy the kernel
  303.         cp $_filename /mnt
  304.         break
  305.     done
  306.     umount -f /mnt2 > /dev/null 2>&1
  307. }
  308.