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 # Copyright 2010 iXsystems
12 # Redistribution and use in source and binary forms, with or without
13 # modification, are permitted providing that the following conditions
15 # 1. Redistributions of source code must retain the above copyright
16 # notice, this list of conditions and the following disclaimer.
17 # 2. Redistributions in binary form must reproduce the above copyright
18 # notice, this list of conditions and the following disclaimer in the
19 # documentation and/or other materials provided with the distribution.
21 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
25 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30 # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 # POSSIBILITY OF SUCH DAMAGE.
34 #####################################################################
36 # User-editable configuration variables
38 # Set this to the program location
39 if [ -z "${PROGDIR}" ]
41 PROGDIR="/usr/share/pc-sysinstall"
45 # Set this to the components location
46 COMPDIR="${PROGDIR}/components"
49 CONFDIR="${PROGDIR}/conf"
52 # Set this to the packages location
56 # End of user-editable configuration
57 #####################################################################
60 QUERYDIR="${PROGDIR}/backend-query"
64 BACKEND="${PROGDIR}/backend"
67 PARTMANAGERDIR="${PROGDIR}/backend-partmanager"
70 # Start by sourcing our conf file
71 if [ -e "${PROGDIR}/conf/pc-sysinstall.conf" ]
73 . ${PROGDIR}/conf/pc-sysinstall.conf
75 echo "ERROR: Could not find ${PROGDIR}/conf/pc-sysinstall.conf"
79 # Now source our functions.sh
80 if [ -e "${PROGDIR}/backend/functions.sh" ]
82 . ${PROGDIR}/backend/functions.sh
84 echo "ERROR: Could not find ${PROGDIR}/backend/functions.sh"
89 # Check if we are called without any flags and display help
92 # Display the help index
98 # The -c flag has been given, time to parse the script
104 ${BACKEND}/parseconfig.sh ${2}
109 # The user requsted help
115 display_command_help ${2}
119 # Install an image file to a device
120 install-image) ${BACKEND}/installimage.sh "${2}" "${3}"
123 # Parse an auto-install directive, and begin the installation
124 start-autoinstall) ${BACKEND}/startautoinstall.sh ${2}
127 # The user is wanting to create a new partition
128 create-part) ${PARTMANAGERDIR}/create-part.sh "${2}" "${3}" "${4}" "${5}"
131 # The user is wanting to delete an existing partition
132 delete-part) ${PARTMANAGERDIR}/delete-part.sh "${2}"
135 # The user is wanting to check if we are on a laptop or desktop
136 detect-laptop) ${QUERYDIR}/detect-laptop.sh
139 # The user is wanting to see what nics are available on the system
140 detect-nics) ${QUERYDIR}/detect-nics.sh
143 # The user is wanting to check if we are in emulation
144 detect-emulation) ${QUERYDIR}/detect-emulation.sh
147 # The user is wanting to query a disk's information
148 disk-info) ${QUERYDIR}/disk-info.sh ${2}
151 # The user is wanting to query which disks are available
152 disk-list) ${QUERYDIR}/disk-list.sh $*
155 # The user is wanting to query a disk's partitions
156 disk-part) ${QUERYDIR}/disk-part.sh ${2}
159 # Function allows the setting of networking by a calling front-end
160 enable-net) ${QUERYDIR}/enable-net.sh "${2}" "${3}" "${4}" "${5}" "${6}" "${7}"
163 # Function which lists components available
164 list-components) ${QUERYDIR}/list-components.sh
167 # Function which lists pc-sysinstall configuration
168 list-config) ${QUERYDIR}/list-config.sh
171 # Function which lists available FTP mirrors
172 list-mirrors) ${QUERYDIR}/list-mirrors.sh "${2}"
175 # Function which lists available packages
176 list-packages) ${QUERYDIR}/list-packages.sh "${2}" "${3}"
179 # Function which lists available backups on a rsync/ssh server
180 list-rsync-backups) ${QUERYDIR}/list-rsync-backups.sh "${2}" "${3}" "${4}"
183 # Function which lists timezones available
184 list-tzones) ${QUERYDIR}/list-tzones.sh
187 # Requested a list of languages this install will support
188 query-langs) ${QUERYDIR}/query-langs.sh
191 # Function which creates a error report, and mails it to the specified address
192 send-logs) ${QUERYDIR}/send-logs.sh ${2}
195 # Function to get package index
196 get-packages) ${QUERYDIR}/get-packages.sh "${2}"
199 # Function to set FTP mirror
200 set-mirror) ${QUERYDIR}/set-mirror.sh "${2}"
203 # Function which allows setting up of SSH keys
204 setup-ssh-keys) ${QUERYDIR}/setup-ssh-keys.sh "${2}" "${3}" "${4}"
207 # Function which lists the real memory of the system in MB
208 sys-mem) ${QUERYDIR}/sys-mem.sh
211 # Run script which determines if we are booted from install media, or on disk
212 test-live) ${QUERYDIR}/test-live.sh
215 # The user is wanting to test if the network is up and working
216 test-netup) ${QUERYDIR}/test-netup.sh
219 # The user is wanting to get a list of partitions available to be updated / repaired
220 update-part-list) ${QUERYDIR}/update-part-list.sh
223 # Requested a list of keyboard layouts that xorg supports
224 xkeyboard-layouts) ${QUERYDIR}/xkeyboard-layouts.sh
227 # Requested a list of keyboard models that xorg supports
228 xkeyboard-models) ${QUERYDIR}/xkeyboard-models.sh
231 # Requested a list of keyboard variants that xorg supports
232 xkeyboard-variants) ${QUERYDIR}/xkeyboard-variants.sh
235 *) echo "Unknown Command: ${1}"
239 # Exit with success if we made it to the end