-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·50 lines (40 loc) · 1.01 KB
/
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
#!/bin/bash
######################################################################
# Author : bhargavg
# Created : 2015-11-03
#
# Usage : ./install.sh
# Description : Setup new Mac machine
######################################################################
### Utils
export CONF_SRC_DIR
CONF_SRC_DIR=$(pwd)
die_if_exists() {
if [ -d "$1" ] || [ -f "$1" ]
then
echo "$1 exists"
exit 2
fi
}
die_if_no_conf_src_set() {
if [ -z "$CONF_SRC_DIR" ]
then
echo "Cannot invoke this script directly"
exit 2
fi
}
link_file () {
die_if_exists "$2"
ln -s "$1" "$2"
}
export -f die_if_exists
export -f die_if_no_conf_src_set
export -f link_file
### Installation
echo "Starting the configuration:"
find "$CONF_SRC_DIR" -not -path '*/\.*' -type d -depth 1 | sort | while read -r dir; do
find "$dir" -depth 1 -type f \( -name '*.sh' -o -name '*.fish' \) | sort | while read -r file; do
[[ -f $file ]] && "$file"
done
done
echo "Success!!!"