]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/pc-sysinstall/backend/parseconfig.sh
Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_60 r321788,
[FreeBSD/FreeBSD.git] / usr.sbin / pc-sysinstall / backend / parseconfig.sh
1 #!/bin/sh
2 #-
3 # SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 #
5 # Copyright (c) 2010 iXsystems, Inc.  All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 # 1. Redistributions of source code must retain the above copyright
11 #    notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 #    notice, this list of conditions and the following disclaimer in the
14 #    documentation and/or other materials provided with the distribution.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 # SUCH DAMAGE.
27 #
28 # $FreeBSD$
29
30 # Main install configuration parsing script
31 #
32
33 # Source our functions scripts
34 . ${BACKEND}/functions.sh
35 . ${BACKEND}/functions-bsdlabel.sh
36 . ${BACKEND}/functions-cleanup.sh
37 . ${BACKEND}/functions-disk.sh
38 . ${BACKEND}/functions-extractimage.sh
39 . ${BACKEND}/functions-installcomponents.sh
40 . ${BACKEND}/functions-installpackages.sh
41 . ${BACKEND}/functions-localize.sh
42 . ${BACKEND}/functions-mountdisk.sh
43 . ${BACKEND}/functions-networking.sh
44 . ${BACKEND}/functions-newfs.sh
45 . ${BACKEND}/functions-packages.sh
46 . ${BACKEND}/functions-parse.sh
47 . ${BACKEND}/functions-runcommands.sh
48 . ${BACKEND}/functions-ftp.sh
49 . ${BACKEND}/functions-unmount.sh
50 . ${BACKEND}/functions-upgrade.sh
51 . ${BACKEND}/functions-users.sh
52
53 # Check that the config file exists
54 if [ ! -e "${1}" ]
55 then
56   echo "ERROR: Install configuration $1 does not exist!"
57   exit 1
58 fi
59
60 # Set our config file variable
61 CFGF="$1"
62
63 # Resolve any relative pathing
64 CFGF="`realpath ${CFGF}`"
65 export CFGF
66
67 # Start by doing a sanity check, which will catch any obvious mistakes in the config
68 file_sanity_check "installMode installType installMedium packageType"
69
70 # We passed the Sanity check, lets grab some of the universal config settings and store them
71 check_value installMode "fresh upgrade extract"
72 check_value installType "PCBSD FreeBSD"
73 check_value installMedium "dvd usb ftp rsync image local"
74 check_value packageType "uzip tar rsync split dist"
75 if_check_value_exists mirrorbal "load prefer round-robin split"
76
77 # We passed all sanity checks! Yay, lets start the install
78 echo "File Sanity Check -> OK"
79
80 # Lets load the various universal settings now
81 get_value_from_cfg installMode
82 export INSTALLMODE="${VAL}"
83
84 get_value_from_cfg installType
85 export INSTALLTYPE="${VAL}"
86
87 get_value_from_cfg installMedium
88 export INSTALLMEDIUM="${VAL}"
89
90 get_value_from_cfg packageType
91 export PACKAGETYPE="${VAL}"
92
93 # Check if we are doing any networking setup
94 start_networking
95
96 # If we are not doing an upgrade, lets go ahead and setup the disk
97 case "${INSTALLMODE}" in
98   fresh)
99     if [ "${INSTALLMEDIUM}" = "image" ]
100     then
101       install_image
102     else
103       install_fresh
104     fi
105     ;;
106
107   extract)
108     # Extracting only, make sure we have a valid target directory
109     get_value_from_cfg installLocation
110     export FSMNT="${VAL}"
111     if [ -z "$FSMNT" ] ; then exit_err "Missing installLocation=" ; fi
112     if [ ! -d "$FSMNT" ] ; then exit_err "No such directory: $FSMNT" ; fi
113
114     install_extractonly
115     ;;
116
117   upgrade)
118     install_upgrade
119     ;;
120
121   *)
122     exit 1
123     ;;
124 esac
125
126 exit 0