Annotation of src/distrib/utils/sysinst/upgrade.c, Revision 1.4.2.3
1.4.2.3 ! mellon 1: /* $NetBSD: upgrade.c,v 1.4.2.2 1997/11/02 20:56:38 mellon Exp $ */
1.1 phil 2:
3: /*
4: * Copyright 1997 Piermont Information Systems Inc.
5: * All rights reserved.
6: *
7: * Written by Philip A. Nelson for Piermont Information Systems Inc.
8: *
9: * Redistribution and use in source and binary forms, with or without
10: * modification, are permitted provided that the following conditions
11: * are met:
12: * 1. Redistributions of source code must retain the above copyright
13: * notice, this list of conditions and the following disclaimer.
14: * 2. Redistributions in binary form must reproduce the above copyright
15: * notice, this list of conditions and the following disclaimer in the
16: * documentation and/or other materials provided with the distribution.
17: * 3. All advertising materials mentioning features or use of this software
18: * must display the following acknowledgement:
19: * This product includes software develooped for the NetBSD Project by
20: * Piermont Information Systems Inc.
21: * 4. The name of Piermont Information Systems Inc. may not be used to endorse
22: * or promote products derived from this software without specific prior
23: * written permission.
24: *
25: * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
26: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28: * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
29: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
35: * THE POSSIBILITY OF SUCH DAMAGE.
36: *
37: */
38:
39: /* upgrade.c -- upgrade an installation. */
40:
41: #include <stdio.h>
42: #include <curses.h>
1.4.2.3 ! mellon 43: #include <errno.h>
1.1 phil 44: #include "defs.h"
45: #include "msg_defs.h"
46: #include "menu_defs.h"
47:
1.4.2.3 ! mellon 48: /*
! 49: * local prototypes
! 50: */
! 51: void check_prereqs(void);
! 52: int save_etc(void);
1.1 phil 53:
1.4.2.3 ! mellon 54: /* Do the system upgrade. */
1.1 phil 55: void do_upgrade(void)
56: {
57: doingwhat = msg_string (MSG_upgrade);
58:
59: msg_display (MSG_upgradeusure);
60: process_menu (MENU_noyes);
61: if (!yesno)
62: return;
63:
1.2 phil 64: get_ramsize ();
65:
66: if (find_disks () < 0)
67: return;
68:
69: if (!fsck_disks())
1.1 phil 70: return;
1.4.2.1 thorpej 71:
1.4.2.3 ! mellon 72: /* Move /mnt/etc /mnt/etc.old so old stuff isn't overwritten. */
! 73: if (save_etc())
! 74: return;
! 75:
1.1 phil 76:
1.3 phil 77: /* Do any md updating of the file systems ... e.g. bootblocks,
78: copy file systems ... */
1.2 phil 79: if (!md_update ())
80: return;
1.1 phil 81:
1.4.2.3 ! mellon 82: /* Done with disks. Ready to get and unpack tarballs. */
! 83: msg_display(MSG_disksetupdone);
! 84: process_menu (MENU_ok);
! 85:
1.4.2.2 mellon 86: get_and_unpack_sets(MSG_upgrcomplete, MSG_abortupgr);
1.4.2.3 ! mellon 87:
! 88: sanity_check();
! 89: }
! 90:
! 91: /*
! 92: * save target /etc files.
! 93: * if target /etc.old exists, print a warning message and give up.
! 94: * otherwise move /etc into target /etc.old, and then copy
! 95: * back files we might want during the installation -- in case
! 96: * we are upgrading the target root.
! 97: */
! 98: int save_etc(void)
! 99: {
! 100:
! 101: if (target_verify_file("/etc.old") == 0) {
! 102: msg_display(MSG_etc_oldexists);
! 103: process_menu (MENU_ok);
! 104: return EEXIST;
! 105: }
! 106:
! 107: #ifdef DEBUG
! 108: printf("saving /etc as /etc.old...");
! 109: #endif
! 110:
! 111: /* Move /mnt/etc /mnt/etc.old so old stuff isn't overwritten. */
! 112: mv_within_target_or_die ("/etc", "/etc.old");
! 113:
! 114: /* now make an /etc that should let the user reboot */
! 115: make_target_dir("/etc");
! 116:
! 117: #ifdef DEBUG
! 118: printf("Copying essential files back into new /etc...");
! 119: #endif
! 120: /* essential stuff */
! 121: cp_within_target("/etc.old/ld.so.cache", "/etc/");
! 122: cp_within_target("/etc.old/ld.so.conf", "/etc/");
! 123: cp_within_target("/etc.old/resolv.conf", "/etc/");
! 124:
! 125: /*
! 126: * do NOT create fstab so that restarting an incomplete
! 127: * upgrade (eg., after power failure) will fail, and
! 128: * force the user to check and restore their old /etc.
! 129: */
! 130:
! 131: /* general config */
! 132: cp_within_target("/etc.old/rc", "/etc/");
! 133: cp_within_target("/etc.old/rc.conf", "/etc/");
! 134: cp_within_target("/etc.old/rc.local", "/etc/");
! 135:
! 136: /* network config */
! 137: cp_within_target("/etc.old/ifconfig.*", "/etc/");
! 138: cp_within_target("/etc.old/myname", "/etc/");
! 139: cp_within_target("/etc.old/mygate", "/etc/");
! 140: cp_within_target("/etc.old/defaultdomain", "/etc/");
! 141:
! 142: /* old-style network config */
! 143: cp_within_target("/etc.old/hostname.*", "/etc/");
! 144:
! 145: return 0;
1.1 phil 146: }
CVSweb <webmaster@jp.NetBSD.org>