-
Notifications
You must be signed in to change notification settings - Fork 22
/
install.sh
executable file
·51 lines (40 loc) · 948 Bytes
/
install.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
#!/bin/bash
# Install dotfiles into $HOME
#
function get_all_components
{
/bin/ls -1d */install.sh 2>/dev/null | sed 's|/install\.sh$||'
}
function usage
{
echo "Usage: $0 [component]"
echo "List of components:" $(get_all_components)
}
function install_component
{
local component=${1:?}
echo "Installing component '$component' ..."
[[ -d $component ]] || {
echo "Component dir $component does not exist" >&2
return 1
}
[[ -x $component/install.sh ]] || {
echo "Installer for $component is not implemented yet, skipping" >&2
return 0
}
(cd $component && ./install.sh)
}
function main
{
local components
local component
if [[ ${1:-} == "-h" ]] || [[ ${1:-} == "--help" ]]; then
usage
return 0
fi
components=${@:-$(get_all_components)}
for component in $components; do
install_component $component
done
}
main "$@"