source: src-sh/pc-sysinstall/pc-sysinstall @ e8cdd4d

9.2-releasereleng/10.0releng/10.0.1
Last change on this file since e8cdd4d was e8cdd4d, checked in by Kris Moore <kris@…>, 6 months ago

Add 'detect-country' option to pc-sysinstall, which will attempt to detect
the country-code of the system based upon IP geo-location

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