-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·52 lines (35 loc) · 1.25 KB
/
setup.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
#!/usr/bin/env bash
############################################
# Prepare environment
packages_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$packages_dir"
# Load predefined functions
. ../utils/functions.sh
############################################
# Script body
find * -name "*.sh" -not -path "setup.sh" | while read setup; do
# NOTE: We cd back to make sure the directory is correct
cd "$packages_dir"
info "Running $setup..."
. ./$setup
done
############################################
COMMENT=\#*
find * -name "*.txt" -type f | while read fileName; do
# %% is "parameter expansion" operator, extract fileName before FIRST dot
# Ref: https://tldp.org/LDP/abs/html/parameter-substitution.html#PSUB2
cmd="${fileName%%.*}"
# NOTE: We prepend $1_ to file name so it will install first
# Strip FIRST characters between $ and _
cmd="${cmd#\$*_}"
# Set $1 to $cmd
set -- "$cmd"
info "Installing \"$1\" packages..."
while read package; do
if [[ $package == $COMMENT || $package == "" ]]; then continue; fi
info "Installing $package..."
# Install $package with $cmd
$cmd $package
done < "$fileName"
success "Finished installing \"$1\" packages."
done