]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.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 # Copyright 2010 iXsystems
10 # All rights reserved
11 #
12 # Redistribution and use in source and binary forms, with or without
13 # modification, are permitted providing that the following conditions
14 # are met:
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.
20 #
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.
32 #
33 # $FreeBSD$
34 #####################################################################
35
36 # User-editable configuration variables
37
38 # Set this to the program location
39 if [ -z "${PROGDIR}" ]
40 then
41   PROGDIR="/usr/share/pc-sysinstall"
42   export PROGDIR
43 fi
44
45 # Set this to the components location
46 COMPDIR="${PROGDIR}/components"
47 export COMPDIR
48
49 CONFDIR="${PROGDIR}/conf"
50 export CONFDIR
51
52 # Set this to the packages location
53 PKGDIR="${CONFDIR}"
54 export PKGDIR
55
56 # End of user-editable configuration
57 #####################################################################
58
59 # Set our QUERYDIR
60 QUERYDIR="${PROGDIR}/backend-query" 
61 export QUERYDIR
62
63 # Set our BACKEND
64 BACKEND="${PROGDIR}/backend" 
65 export BACKEND
66
67 PARTMANAGERDIR="${PROGDIR}/backend-partmanager"
68 export PARTMANAGERDIR
69
70 # Start by sourcing our conf file
71 if [ -e "${PROGDIR}/conf/pc-sysinstall.conf" ]
72 then
73   . ${PROGDIR}/conf/pc-sysinstall.conf
74 else
75   echo "ERROR: Could not find ${PROGDIR}/conf/pc-sysinstall.conf"
76   exit 1
77 fi
78
79 # Now source our functions.sh 
80 if [ -e "${PROGDIR}/backend/functions.sh" ]
81 then
82   . ${PROGDIR}/backend/functions.sh
83 else
84   echo "ERROR: Could not find ${PROGDIR}/backend/functions.sh"
85   exit 1
86 fi
87
88
89 # Check if we are called without any flags and display help
90 if [ -z "${1}" ]
91 then
92   # Display the help index
93   display_help
94   exit 0
95 fi
96
97 case $1 in
98   # The -c flag has been given, time to parse the script
99   -c)
100     if [ -z "${2}" ]
101     then
102       display_help
103     else
104       ${BACKEND}/parseconfig.sh ${2}
105       exit $?
106     fi
107   ;;
108
109   # The user requsted help
110   help)
111     if [ -z "${2}" ]
112     then
113       display_help
114     else
115       display_command_help ${2}
116     fi
117   ;;
118
119   # Install an image file to a device
120   install-image) ${BACKEND}/installimage.sh "${2}" "${3}"
121   ;;
122
123   # Parse an auto-install directive, and begin the installation
124   start-autoinstall) ${BACKEND}/startautoinstall.sh ${2}
125   ;;
126
127   # The user is wanting to create a new partition
128   create-part) ${PARTMANAGERDIR}/create-part.sh "${2}" "${3}" "${4}" "${5}"
129   ;;
130
131   # The user is wanting to delete an existing partition
132   delete-part) ${PARTMANAGERDIR}/delete-part.sh "${2}"
133   ;;
134
135   # The user is wanting to check if we are on a laptop or desktop
136   detect-laptop) ${QUERYDIR}/detect-laptop.sh
137   ;;
138
139   # The user is wanting to see what nics are available on the system
140   detect-nics) ${QUERYDIR}/detect-nics.sh
141   ;;
142   
143   # The user is wanting to check if we are in emulation
144   detect-emulation) ${QUERYDIR}/detect-emulation.sh
145   ;;
146
147   # The user is wanting to query a disk's information
148   disk-info) ${QUERYDIR}/disk-info.sh ${2}
149   ;;
150
151   # The user is wanting to query which disks are available
152   disk-list) ${QUERYDIR}/disk-list.sh $*
153   ;;
154   
155   # The user is wanting to query a disk's partitions
156   disk-part) ${QUERYDIR}/disk-part.sh ${2}
157   ;;
158
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}"
161   ;;
162
163   # Function which lists components available
164   list-components) ${QUERYDIR}/list-components.sh
165   ;;
166
167   # Function which lists pc-sysinstall configuration
168   list-config) ${QUERYDIR}/list-config.sh
169   ;;
170
171   # Function which lists available FTP mirrors
172   list-mirrors) ${QUERYDIR}/list-mirrors.sh "${2}"
173   ;;
174
175   # Function which lists available packages
176   list-packages) ${QUERYDIR}/list-packages.sh "${2}" "${3}"
177   ;;
178
179   # Function which lists available backups on a rsync/ssh server
180   list-rsync-backups) ${QUERYDIR}/list-rsync-backups.sh "${2}" "${3}" "${4}"
181   ;;
182
183   # Function which lists timezones available
184   list-tzones) ${QUERYDIR}/list-tzones.sh
185   ;;
186
187   # Requested a list of languages this install will support
188   query-langs) ${QUERYDIR}/query-langs.sh
189   ;;
190
191   # Function which creates a error report, and mails it to the specified address
192   send-logs) ${QUERYDIR}/send-logs.sh ${2}
193   ;;
194
195   # Function to get package index
196   get-packages) ${QUERYDIR}/get-packages.sh "${2}"
197   ;;
198
199   # Function to set FTP mirror
200   set-mirror) ${QUERYDIR}/set-mirror.sh "${2}"
201   ;;
202
203   # Function which allows setting up of SSH keys
204   setup-ssh-keys) ${QUERYDIR}/setup-ssh-keys.sh "${2}" "${3}" "${4}"
205   ;;
206   
207   # Function which lists the real memory of the system in MB
208   sys-mem) ${QUERYDIR}/sys-mem.sh
209   ;;
210
211   # Run script which determines if we are booted from install media, or on disk
212   test-live) ${QUERYDIR}/test-live.sh
213   ;;
214   
215   # The user is wanting to test if the network is up and working
216   test-netup) ${QUERYDIR}/test-netup.sh
217   ;;
218
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
221   ;;
222
223   # Requested a list of keyboard layouts that xorg supports
224   xkeyboard-layouts) ${QUERYDIR}/xkeyboard-layouts.sh
225   ;;
226   
227   # Requested a list of keyboard models that xorg supports
228   xkeyboard-models) ${QUERYDIR}/xkeyboard-models.sh
229   ;;
230   
231   # Requested a list of keyboard variants that xorg supports
232   xkeyboard-variants) ${QUERYDIR}/xkeyboard-variants.sh
233   ;;
234            
235   *) echo "Unknown Command: ${1}" 
236      exit 1 ;;
237 esac
238
239 # Exit with success if we made it to the end
240 exit $?