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