source: src-sh/pc-sysinstall/backend/parseconfig.sh @ 8378d50

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2releng/10.0.3releng/10.1releng/10.1.1
Last change on this file since 8378d50 was 8378d50, checked in by Kris Moore <kris@…>, 17 months ago

Update pc-sysinstall to now allow doing restores from a replicated
ZFS dataset via life-preserver

  • Property mode set to 100755
File size: 4.4 KB
Line 
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: head/usr.sbin/pc-sysinstall/backend/parseconfig.sh 247705 2013-03-03 09:47:47Z jpaetzel $
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-ftp.sh
37. ${BACKEND}/functions-extractimage.sh
38. ${BACKEND}/functions-installcomponents.sh
39. ${BACKEND}/functions-installpackages.sh
40. ${BACKEND}/functions-localize.sh
41. ${BACKEND}/functions-mountdisk.sh
42. ${BACKEND}/functions-networking.sh
43. ${BACKEND}/functions-newfs.sh
44. ${BACKEND}/functions-packages.sh
45. ${BACKEND}/functions-parse.sh
46. ${BACKEND}/functions-runcommands.sh
47. ${BACKEND}/functions-unmount.sh
48. ${BACKEND}/functions-upgrade.sh
49. ${BACKEND}/functions-users.sh
50. ${BACKEND}/functions-zfsrestore.sh
51
52# Check that the config file exists
53if [ ! -e "${1}" ]
54then
55  echo "ERROR: Install configuration $1 does not exist!"
56  exit 1
57fi
58
59# Set our config file variable
60CFGF="$1"
61
62# Resolve any relative pathing
63CFGF="`realpath ${CFGF}`"
64export CFGF
65
66# Start by doing a sanity check, which will catch any obvious mistakes in the config
67
68# We passed the Sanity check, lets grab some of the universal config settings and store them
69check_value installMode "fresh upgrade extract zfsrestore"
70
71# Lets load the various universal settings now
72get_value_from_cfg installMode
73export INSTALLMODE="${VAL}"
74
75if [ "$INSTALLMODE" = "zfsrestore" ] ; then
76  file_sanity_check "sshHost sshPort sshUser sshKey zfsRemoteDataset"
77else
78  file_sanity_check "installMode installType installMedium packageType"
79  check_value installType "PCBSD FreeBSD"
80  check_value installMedium "dvd usb ftp rsync image local"
81  check_value packageType "uzip tar rsync split dist zfs"
82  if_check_value_exists mirrorbal "load prefer round-robin split"
83fi
84
85# We passed all sanity checks! Yay, lets start the install
86echo "File Sanity Check -> OK"
87
88get_value_from_cfg installType
89export INSTALLTYPE="${VAL}"
90
91get_value_from_cfg installMedium
92export INSTALLMEDIUM="${VAL}"
93
94get_value_from_cfg packageType
95export PACKAGETYPE="${VAL}"
96
97# See if the user wants a custom zpool starting name
98get_value_from_cfg zpoolName
99if [ -n "$VAL" ] ; then
100  export ZPOOLCUSTOMNAME="${VAL}"
101fi
102
103# Check if we are going to force ZFS 4k sectors with gnop
104get_value_from_cfg zfsForce4k
105if [ -n "$VAL" ] ; then
106  export ZFSFORCE4K="${VAL}"
107fi
108
109# Check if we are doing any networking setup
110start_networking
111
112# If we are not doing an upgrade, lets go ahead and setup the disk
113case "${INSTALLMODE}" in
114  zfsrestore) restore_zfs ;;
115  fresh)
116    if [ "${INSTALLMEDIUM}" = "image" ]
117    then
118      install_image
119    else
120      install_fresh
121    fi
122    ;;
123
124  extract)
125    # Extracting only, make sure we have a valid target directory
126    get_value_from_cfg installLocation
127    export FSMNT="${VAL}"
128    if [ -z "$FSMNT" ] ; then exit_err "Missing installLocation=" ; fi
129    if [ ! -d "$FSMNT" ] ; then exit_err "No such directory: $FSMNT" ; fi
130
131    install_extractonly
132    ;;
133
134  upgrade)
135    install_upgrade
136    ;;
137
138  *)
139    exit 1
140    ;;
141esac
142
143exit 0
Note: See TracBrowser for help on using the repository browser.