summaryrefslogtreecommitdiffstats
path: root/PCBSD/pc-sysinstall/pc-sysinstall
blob: dc5a594cd47c883def15f9d4c1f9859a7cf6c7fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/bin/sh
#####################################################################
#       Author: Kris Moore
#      License: BSD 
#  Description: pc-sysinstall provides a backend for performing 
#  system installations, as well as calls which a front-end can use
#  to retrive information about the system
#####################################################################
# Copyright 2010 Kris Moore
# All rights reserved
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted providing that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#####################################################################

# User-editable configuration variables

# Set this to the program location
PROGDIR="/PCBSD/pc-sysinstall"
export PROGDIR

# Set this to the components location
COMPDIR="${PROGDIR}/components"
export COMPDIR

# End of user-editable configuration
#####################################################################

# Set our QUERYDIR
QUERYDIR="${PROGDIR}/backend-query" 
export QUERYDIR

# Set our BACKEND
BACKEND="${PROGDIR}/backend" 
export BACKEND

PARTMANAGERDIR="${PROGDIR}/backend-partmanager"
export PARTMANAGERDIR

# Start by sourcing our conf file
if [ -e "${PROGDIR}/conf/pc-sysinstall.conf" ]
then
  . ${PROGDIR}/conf/pc-sysinstall.conf
else
  echo "ERROR: Could not find ${PROGDIR}/conf/pc-sysinstall.conf"
  exit 1
fi

# Now source our functions.sh 
if [ -e "${PROGDIR}/backend/functions.sh" ]
then
  . ${PROGDIR}/backend/functions.sh
else
  echo "ERROR: Could not find ${PROGDIR}/backend/functions.sh"
  exit 1
fi


# Check if we are called without any flags and display help
if [ -z "${1}" ]
then
   # Display the help index
   display_help
   exit 0
fi

case $1 in
  # The -c flag has been given, time to parse the script
  -c) if [ -z "${2}" ]
        then
          display_help
        else
          ${BACKEND}/parseconfig.sh ${2}
          exit $?
        fi
  ;;

  # The user requsted help
  help) if [ -z "${2}" ]
        then
          display_help
        else
          display_command_help ${2}
        fi
  ;;

  # Parse an auto-install directive, and begin the installation
  start-autoinstall) ${BACKEND}/startautoinstall.sh ${2}
  ;;

  # The user is wanting to create a new partition
  create-part) ${PARTMANAGERDIR}/create-part.sh "${2}" "${3}"
  ;;

  # The user is wanting to delete an existing partition
  delete-part) ${PARTMANAGERDIR}/delete-part.sh "${2}"
  ;;

  # The user is wanting to check if we are on a laptop or desktop
  detect-laptop) ${QUERYDIR}/detect-laptop.sh
  ;;

  # The user is wanting to see what nics are available on the system
  detect-nics) ${QUERYDIR}/detect-nics.sh
  ;;
  
  # The user is wanting to check if we are in vmware
  detect-vmware) ${QUERYDIR}/detect-vmware.sh
  ;;

  # The user is wanting to query a disk's information
  disk-info) ${QUERYDIR}/disk-info.sh ${2}
  ;;

  # The user is wanting to query which disks are available
  disk-list) ${QUERYDIR}/disk-list.sh
  ;;
  
  # The user is wanting to query a disk's partitions
  disk-part) ${QUERYDIR}/disk-part.sh ${2}
  ;;

  # Function allows the setting of networking by a calling front-end
  enable-net) ${QUERYDIR}/enable-net.sh "${2}" "${3}" "${4}" "${5}" "${6}" "${7}"
  ;;

  # Function which lists components available
  list-components) ${QUERYDIR}/list-components.sh
  ;;

  # Function which lists available backups on a rsync/ssh server
  list-rsync-backups) ${QUERYDIR}/list-rsync-backups.sh "${2}" "${3}" "${4}"
  ;;

  # Function which lists timezones available
  list-tzones) ${QUERYDIR}/list-tzones.sh
  ;;

  # Requested a list of languages this install will support
  query-langs) ${QUERYDIR}/query-langs.sh
  ;;

  # Function which creates a error report, and mails it to the specified address
  send-logs) ${QUERYDIR}/send-logs.sh ${2}
  ;;

  # Function which allows setting up of SSH keys
  setup-ssh-keys) ${QUERYDIR}/setup-ssh-keys.sh "${2}" "${3}" "${4}"
  ;;
  
  # Function which lists the real memory of the system in MB
  sys-mem) ${QUERYDIR}/sys-mem.sh
  ;;

  # Run script which determines if we are booted from install media, or on disk
  test-live) ${QUERYDIR}/test-live.sh
  ;;
  
  # The user is wanting to test if the network is up and working
  test-netup) ${QUERYDIR}/test-netup.sh
  ;;

  # The user is wanting to get a list of partitions available to be updated / repaired
  update-part-list) ${QUERYDIR}/update-part-list.sh
  ;;

  # Requested a list of keyboard layouts that xorg supports
  xkeyboard-layouts) ${QUERYDIR}/xkeyboard-layouts.sh
  ;;
  
  # Requested a list of keyboard models that xorg supports
  xkeyboard-models) ${QUERYDIR}/xkeyboard-models.sh
  ;;
  
  # Requested a list of keyboard variants that xorg supports
  xkeyboard-variants) ${QUERYDIR}/xkeyboard-variants.sh
  ;;
           
  *) echo "Unknown Command: ${1}" 
     exit 1 ;;
esac

# Exit with success if we made it to the end
exit 0
OpenPOWER on IntegriCloud