aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/scripts/iperd.profile
diff options
context:
space:
mode:
Diffstat (limited to 'src/scripts/iperd.profile')
-rw-r--r--src/scripts/iperd.profile135
1 files changed, 135 insertions, 0 deletions
diff --git a/src/scripts/iperd.profile b/src/scripts/iperd.profile
new file mode 100644
index 0000000..90fb621
--- /dev/null
+++ b/src/scripts/iperd.profile
@@ -0,0 +1,135 @@
1#!/bin/sh
2#
3# IP Engineering Rescue Disk
4# Copyright (C) 2017, 2018 David M. Syzdek <david@syzdek.net>.
5#
6# @SYZDEK_BSD_LICENSE_START@
7#
8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions are
10# met:
11#
12# * Redistributions of source code must retain the above copyright
13# notice, this list of conditions and the following disclaimer.
14# * Redistributions in binary form must reproduce the above copyright
15# notice, this list of conditions and the following disclaimer in the
16# documentation and/or other materials provided with the distribution.
17# * Neither the name of David M. Syzdek nor the
18# names of its contributors may be used to endorse or promote products
19# derived from this software without specific prior written permission.
20#
21# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID M. SYZDEK BE LIABLE FOR
25# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31# SUCH DAMAGE.
32#
33# @SYZDEK_BSD_LICENSE_END@
34#
35
36# set defaults
37BASEDIR="$(dirname "${0}")/../../"
38DISTRODIR="${DISTRODIR:-${BASEDIR}/src/distros}"
39CONFIGDIR="${CONFIGDIR:-${BASEDIR}/var/config}"
40CONFIG="${CONFIG:-${CONFIGDIR}/iperd.conf}"
41
42
43# load configuration
44if test -f ${CONFIG};then
45 . ${CONFIG}
46fi
47
48
49# set missing defaults
50DEFAULT_PART_TYPE="hybrid"
51DEFAULT_PART_SIZE="0"
52DEFAULT_IMG_SIZE="1900"
53DEFAULT_ISO_TYPE="bios"
54CONFIG_PART_TYPE="${CONFIG_PART_TYPE:-${DEFAULT_PART_TYPE}}"
55CONFIG_PART_SIZE="${CONFIG_PART_SIZE:-${DEFAULT_PART_SIZE}}"
56CONFIG_IMG_SIZE="${CONFIG_IMG_SIZE:-${DEFAULT_IMG_SIZE}}"
57CONFIG_ISO_TYPE="${CONFIG_ISO_TYPE:-${DEFAULT_ISO_TYPE}}"
58
59
60# set exit codes to trigger specific xargs exit codes
61DIALOG_OK=0 # xargs => 0
62DIALOG_CANCEL=255 # xargs => 124
63DIALOG_ESC=255 # xargs => 124
64DIALOG_EXTRA=126 # xargs => 126
65DIALOG_HELP=0 # xargs => 0
66export DIALOG_OK DIALOG_CANCEL DIALOG_HELP DIALOG_EXTRA DIALOG_ESC
67
68
69###############
70# #
71# Functions #
72# #
73###############
74
75list_cfg_distros()
76{
77 egrep '^#[[:alnum:]]+-' "${CONFIG}" \
78 |cut -d- -f1 \
79 |cut -d'#' -f2 \
80 |sort \
81 |uniq
82}
83
84
85list_distros()
86{
87 egrep '^[[:space:]]{0,}[a-zA-Z0-9]{1,}[[:space:]]' ${DISTRODIR}/*/option* \
88 |sed \
89 -e 's/^[a-zA-Z0-9/]\{1,\}://g' \
90 -e 's/ @[[:alnum:][:punct:]]\{1,\}@$//g' \
91 -e "s/[[:space:]]\{2,\}/ /g" \
92 -e 's/^ //g' \
93 -e 's/ $//g' \
94 |cut -d: -f2 \
95 |sort -n \
96 |uniq
97}
98
99
100list_vers()
101{
102 egrep '^[[:space:]]{0,}[a-zA-Z0-9]{1,}-' "${1}" \
103 |sed \
104 -e 's/[[:space:]]\{1,\}/ /g' \
105 -e 's/[-a-z0-9_/]\{1,\}: //g' \
106 -e 's/^ //g' \
107 |cut -d\ -f1 \
108 |sort -n \
109 |uniq
110}
111
112
113list_vers_opts()
114{
115 OPTFILE="${1}"
116
117 # generate list of options
118 for VERS in $(list_vers ${OPTFILE});do
119 grep "^#${VERS}$" "${CONFIG}.new" > /dev/null 2> /dev/null
120 if test $? -eq 0;then
121 STATE=on
122 else
123 STATE=off
124 fi
125 egrep "^[[:space:]]{0,}${VERS}[[:space:]]" ${OPTFILE} |sed -e "s/$/ ${STATE}/g"
126 done \
127 |sed \
128 -e "s/[[:space:]]\{1,\}/ /g" \
129 -e 's/^ //g' \
130 -e 's/ $//g' \
131 |sort -n
132}
133
134
135# end of profile