]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
[FreeBSD/FreeBSD.git] / usr.sbin / pc-sysinstall / pc-sysinstall / pc-sysinstall.sh
1 #!/bin/sh
2 #####################################################################
3 #       Author: Kris Moore
4 #      License: BSD 
5 #  Description: pc-sysinstall provides a backend for performing 
6 #  system installations, as well as calls which a front-end can use
7 #  to retrive information about the system
8 #####################################################################
9 # SPDX-License-Identifier: BSD-2-Clause-FreeBSD
10 #
11 # Copyright 2010 iXsystems
12 # All rights reserved
13 #
14 # Redistribution and use in source and binary forms, with or without
15 # modification, are permitted providing that the following conditions
16 # are met:
17 # 1. Redistributions of source code must retain the above copyright
18 #    notice, this list of conditions and the following disclaimer.
19 # 2. Redistributions in binary form must reproduce the above copyright
20 #    notice, this list of conditions and the following disclaimer in the
21 #    documentation and/or other materials provided with the distribution.
22 #
23 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
27 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32 # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 # POSSIBILITY OF SUCH DAMAGE.
34 #
35 # $FreeBSD$
36 #####################################################################
37
38 # User-editable configuration variables
39
40 # Set this to the program location
41 if [ -z "${PROGDIR}" ]
42 then
43   PROGDIR="/usr/share/pc-sysinstall"
44   export PROGDIR
45 fi
46
47 # Set this to the components location
48 COMPDIR="${PROGDIR}/components"
49 export COMPDIR
50
51 CONFDIR="${PROGDIR}/conf"
52 export CONFDIR
53
54 # Set this to the packages location
55 PKGDIR="${CONFDIR}"
56 export PKGDIR
57
58 # End of user-editable configuration
59 #####################################################################
60
61 # Set our QUERYDIR
62 QUERYDIR="${PROGDIR}/backend-query" 
63 export QUERYDIR
64
65 # Set our BACKEND
66 BACKEND="${PROGDIR}/backend" 
67 export BACKEND
68
69 PARTMANAGERDIR="${PROGDIR}/backend-partmanager"
70 export PARTMANAGERDIR
71
72 # Start by sourcing our conf file
73 if [ -e "${PROGDIR}/conf/pc-sysinstall.conf" ]
74 then
75   . ${PROGDIR}/conf/pc-sysinstall.conf
76 else
77   echo "ERROR: Could not find ${PROGDIR}/conf/pc-sysinstall.conf"
78   exit 1
79 fi
80
81 # Now source our functions.sh 
82 if [ -e "${PROGDIR}/backend/functions.sh" ]
83 then
84   . ${PROGDIR}/backend/functions.sh
85 else
86   echo "ERROR: Could not find ${PROGDIR}/backend/functions.sh"
87   exit 1
88 fi
89
90
91 # Check if we are called without any flags and display help
92 if [ -z "${1}" ]
93 then
94   # Display the help index
95   display_help
96   exit 0
97 fi
98
99 case $1 in
100   # The -c flag has been given, time to parse the script
101   -c)
102     if [ -z "${2}" ]
103     then
104       display_help
105     else
106       ${BACKEND}/parseconfig.sh ${2}
107       exit $?
108     fi
109   ;;
110
111   # The user requsted help
112   help)
113     if [ -z "${2}" ]
114     then
115       display_help
116     else
117       display_command_help ${2}
118     fi
119   ;;
120
121   # Install an image file to a device
122   install-image) ${BACKEND}/installimage.sh "${2}" "${3}"
123   ;;
124
125   # Parse an auto-install directive, and begin the installation
126   start-autoinstall) ${BACKEND}/startautoinstall.sh ${2}
127   ;;
128
129   # The user is wanting to create a new partition
130   create-part) ${PARTMANAGERDIR}/create-part.sh "${2}" "${3}" "${4}" "${5}"
131   ;;
132
133   # The user is wanting to delete an existing partition
134   delete-part) ${PARTMANAGERDIR}/delete-part.sh "${2}"
135   ;;
136
137   # The user is wanting to check if we are on a laptop or desktop
138   detect-laptop) ${QUERYDIR}/detect-laptop.sh
139   ;;
140
141   # The user is wanting to see what nics are available on the system
142   detect-nics) ${QUERYDIR}/detect-nics.sh
143   ;;
144   
145   # The user is wanting to check if we are in emulation
146   detect-emulation) ${QUERYDIR}/detect-emulation.sh
147   ;;
148
149   # The user is wanting to query a disk's information
150   disk-info) ${QUERYDIR}/disk-info.sh ${2}
151   ;;
152
153   # The user is wanting to query which disks are available
154   disk-list) ${QUERYDIR}/disk-list.sh $*
155   ;;
156   
157   # The user is wanting to query a disk's partitions
158   disk-part) ${QUERYDIR}/disk-part.sh ${2}
159   ;;
160
161   # Function allows the setting of networking by a calling front-end
162   enable-net) ${QUERYDIR}/enable-net.sh "${2}" "${3}" "${4}" "${5}" "${6}" "${7}"
163   ;;
164
165   # Function which lists components available
166   list-components) ${QUERYDIR}/list-components.sh
167   ;;
168
169   # Function which lists pc-sysinstall configuration
170   list-config) ${QUERYDIR}/list-config.sh
171   ;;
172
173   # Function which lists available FTP mirrors
174   list-mirrors) ${QUERYDIR}/list-mirrors.sh "${2}"
175   ;;
176
177   # Function which lists available packages
178   list-packages) ${QUERYDIR}/list-packages.sh "${2}" "${3}"
179   ;;
180
181   # Function which lists available backups on a rsync/ssh server
182   list-rsync-backups) ${QUERYDIR}/list-rsync-backups.sh "${2}" "${3}" "${4}"
183   ;;
184
185   # Function which lists timezones available
186   list-tzones) ${QUERYDIR}/list-tzones.sh
187   ;;
188
189   # Requested a list of languages this install will support
190   query-langs) ${QUERYDIR}/query-langs.sh
191   ;;
192
193   # Function which creates a error report, and mails it to the specified address
194   send-logs) ${QUERYDIR}/send-logs.sh ${2}
195   ;;
196
197   # Function to get package index
198   get-packages) ${QUERYDIR}/get-packages.sh "${2}"
199   ;;
200
201   # Function to set FTP mirror
202   set-mirror) ${QUERYDIR}/set-mirror.sh "${2}"
203   ;;
204
205   # Function which allows setting up of SSH keys
206   setup-ssh-keys) ${QUERYDIR}/setup-ssh-keys.sh "${2}" "${3}" "${4}"
207   ;;
208   
209   # Function which lists the real memory of the system in MB
210   sys-mem) ${QUERYDIR}/sys-mem.sh
211   ;;
212
213   # Run script which determines if we are booted from install media, or on disk
214   test-live) ${QUERYDIR}/test-live.sh
215   ;;
216   
217   # The user is wanting to test if the network is up and working
218   test-netup) ${QUERYDIR}/test-netup.sh
219   ;;
220
221   # The user is wanting to get a list of partitions available to be updated / repaired
222   update-part-list) ${QUERYDIR}/update-part-list.sh
223   ;;
224
225   # Requested a list of keyboard layouts that xorg supports
226   xkeyboard-layouts) ${QUERYDIR}/xkeyboard-layouts.sh
227   ;;
228   
229   # Requested a list of keyboard models that xorg supports
230   xkeyboard-models) ${QUERYDIR}/xkeyboard-models.sh
231   ;;
232   
233   # Requested a list of keyboard variants that xorg supports
234   xkeyboard-variants) ${QUERYDIR}/xkeyboard-variants.sh
235   ;;
236            
237   *) echo "Unknown Command: ${1}" 
238      exit 1 ;;
239 esac
240
241 # Exit with success if we made it to the end
242 exit $?