2 #####################################################################
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
11 # Copyright 2010 iXsystems
14 # Redistribution and use in source and binary forms, with or without
15 # modification, are permitted providing that the following conditions
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.
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.
36 #####################################################################
38 # User-editable configuration variables
40 # Set this to the program location
41 if [ -z "${PROGDIR}" ]
43 PROGDIR="/usr/share/pc-sysinstall"
47 # Set this to the components location
48 COMPDIR="${PROGDIR}/components"
51 CONFDIR="${PROGDIR}/conf"
54 # Set this to the packages location
58 # End of user-editable configuration
59 #####################################################################
62 QUERYDIR="${PROGDIR}/backend-query"
66 BACKEND="${PROGDIR}/backend"
69 PARTMANAGERDIR="${PROGDIR}/backend-partmanager"
72 # Start by sourcing our conf file
73 if [ -e "${PROGDIR}/conf/pc-sysinstall.conf" ]
75 . ${PROGDIR}/conf/pc-sysinstall.conf
77 echo "ERROR: Could not find ${PROGDIR}/conf/pc-sysinstall.conf"
81 # Now source our functions.sh
82 if [ -e "${PROGDIR}/backend/functions.sh" ]
84 . ${PROGDIR}/backend/functions.sh
86 echo "ERROR: Could not find ${PROGDIR}/backend/functions.sh"
91 # Check if we are called without any flags and display help
94 # Display the help index
100 # The -c flag has been given, time to parse the script
106 ${BACKEND}/parseconfig.sh ${2}
111 # The user requsted help
117 display_command_help ${2}
121 # Install an image file to a device
122 install-image) ${BACKEND}/installimage.sh "${2}" "${3}"
125 # Parse an auto-install directive, and begin the installation
126 start-autoinstall) ${BACKEND}/startautoinstall.sh ${2}
129 # The user is wanting to create a new partition
130 create-part) ${PARTMANAGERDIR}/create-part.sh "${2}" "${3}" "${4}" "${5}"
133 # The user is wanting to delete an existing partition
134 delete-part) ${PARTMANAGERDIR}/delete-part.sh "${2}"
137 # The user is wanting to check if we are on a laptop or desktop
138 detect-laptop) ${QUERYDIR}/detect-laptop.sh
141 # The user is wanting to see what nics are available on the system
142 detect-nics) ${QUERYDIR}/detect-nics.sh
145 # The user is wanting to check if we are in emulation
146 detect-emulation) ${QUERYDIR}/detect-emulation.sh
149 # The user is wanting to query a disk's information
150 disk-info) ${QUERYDIR}/disk-info.sh ${2}
153 # The user is wanting to query which disks are available
154 disk-list) ${QUERYDIR}/disk-list.sh $*
157 # The user is wanting to query a disk's partitions
158 disk-part) ${QUERYDIR}/disk-part.sh ${2}
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}"
165 # Function which lists components available
166 list-components) ${QUERYDIR}/list-components.sh
169 # Function which lists pc-sysinstall configuration
170 list-config) ${QUERYDIR}/list-config.sh
173 # Function which lists available FTP mirrors
174 list-mirrors) ${QUERYDIR}/list-mirrors.sh "${2}"
177 # Function which lists available packages
178 list-packages) ${QUERYDIR}/list-packages.sh "${2}" "${3}"
181 # Function which lists available backups on a rsync/ssh server
182 list-rsync-backups) ${QUERYDIR}/list-rsync-backups.sh "${2}" "${3}" "${4}"
185 # Function which lists timezones available
186 list-tzones) ${QUERYDIR}/list-tzones.sh
189 # Requested a list of languages this install will support
190 query-langs) ${QUERYDIR}/query-langs.sh
193 # Function which creates a error report, and mails it to the specified address
194 send-logs) ${QUERYDIR}/send-logs.sh ${2}
197 # Function to get package index
198 get-packages) ${QUERYDIR}/get-packages.sh "${2}"
201 # Function to set FTP mirror
202 set-mirror) ${QUERYDIR}/set-mirror.sh "${2}"
205 # Function which allows setting up of SSH keys
206 setup-ssh-keys) ${QUERYDIR}/setup-ssh-keys.sh "${2}" "${3}" "${4}"
209 # Function which lists the real memory of the system in MB
210 sys-mem) ${QUERYDIR}/sys-mem.sh
213 # Run script which determines if we are booted from install media, or on disk
214 test-live) ${QUERYDIR}/test-live.sh
217 # The user is wanting to test if the network is up and working
218 test-netup) ${QUERYDIR}/test-netup.sh
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
225 # Requested a list of keyboard layouts that xorg supports
226 xkeyboard-layouts) ${QUERYDIR}/xkeyboard-layouts.sh
229 # Requested a list of keyboard models that xorg supports
230 xkeyboard-models) ${QUERYDIR}/xkeyboard-models.sh
233 # Requested a list of keyboard variants that xorg supports
234 xkeyboard-variants) ${QUERYDIR}/xkeyboard-variants.sh
237 *) echo "Unknown Command: ${1}"
241 # Exit with success if we made it to the end