This repository has been archived by the owner on Feb 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
minstall.sh
183 lines (152 loc) · 3.13 KB
/
minstall.sh
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
#!/bin/bash
# Script Loader
# Disable Ctrl+C
trap '' 2
# Change Directory
cd $(dirname $0)
# Load Variables
source config.sh
# Load Libraries (External)
for file in $LIBRARYPATH/external/*.sh; do
# Source Libraries
source $file
done
# Load Libraries
for file in $LIBRARYPATH/*.sh; do
# Source Libraries
source $file
done
# Load Module Specific Libraries
for file in $LIBRARYPATH/module/*.sh; do
# Source Libraries
source $file
done
# Load Platform Specific Libraries
for file in $LIBRARYPATH/platform/*.$DISTRIBUTION.sh $LIBRARYPATH/platform/*.$DISTRIBUTION-$VERSION.sh; do
# Source Libraries
source $file
done
# Check Arguments
while getopts ":c:hlm:su" option; do
# Argument List
case $option in
# Config File
c)
# Check Config File Existance
if [ -f $OPTARG ]; then
# Print Warning
warning "Loaded Custom Config File \"$OPTARG\"."
# Set Config File Variable
CONFIGFILE=$OPTARG
# Error Condition
else
# Print Error
error "Custom Config File \"$OPTARG\" does not exist."
# Exit
exit
fi
;;
# Help
h)
# Load Help
source $MODULEPATH/help/init.sh
# Exit
exit
;;
# Module List
l)
# Load Module Listing Script
source $MODULEPATH/help-modules/init.sh
# Exit
exit
;;
# Module Definition
m)
# Set Module List Variable
MODULELIST=$OPTARG,
;;
# Setup Mode
s)
# Print Warning
warning "Setup Mode Running..."
# Set Setup Variable State
SETUP=1
;;
# Unattended Mode
u)
# Print Warning
warning "Unattended Mode Running..."
# Enable Unattended Mode
UNATTENDED=1
;;
# No Arguments
\?)
# Load Module Listing Script
source $MODULEPATH/help/init.sh
# Exit
exit
;;
# Invalid Argument
:)
# Print Error
error "Option -$OPTARG requires an argument."
# Exit
exit
;;
esac
done
# Setup Mode
if [[ -n "$SETUP" ]]; then
# Create Base Configuration File
cp $LIBRARYPATH/default/config.ini $CONFIGFILE
# Loop Through Modules
for MODULE in $MODULEPATH/*/config.ini; do
# Check If File Empty
if [ -s $MODULE ]; then
# Append Space
echo >> $CONFIGFILE
# Append Module Configuration
cat $MODULE >> $CONFIGFILE
fi
done
# Exit
exit
fi
# Read Configuration
read_ini $CONFIGFILE
# Execute Modules
while echo $MODULELIST | grep -q \,; do
# Define Module
MODULE=${MODULELIST%%\,*}
# Remove Current Module From Module List
MODULELIST=${MODULELIST#*\,}
# Check If Module Exists
if [ -f $MODULEPATH/$MODULE/init.sh ]; then
# Print Module Description
header $(describe $MODULEPATH/$MODULE/init.sh)
# Load Module
source $MODULEPATH/$MODULE/init.sh
# Error Condition
else
# Ask If User Wants To Abort
if question --default no "Module $MODULE not found. Do you want to abort? (y/N)" || [ $UNATTENDED = 1 ]; then
# Print Message
error "Module $MODULE not found. Aborting."
# Exit Script
exit
fi
fi
# Remove Temporary Files
rm -f temp.*
# Debug Pause
if [ $(read_variable minstall__debug) = 1 ]; then
# Enable Ctrl+C
trap 2
# Wait For User Input
read -p "Press any key to continue or press Ctrl+C to exit..."
# Disable Ctrl+C
trap '' 2
fi
done
# Enable Ctrl+C
trap 2