-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
63 lines (53 loc) · 1.3 KB
/
Copy pathinstall.sh
File metadata and controls
63 lines (53 loc) · 1.3 KB
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
#!/bin/sh
# Default config
proj=".dotfm"
file="dotfiles.json"
option="None"
################
usage() {
cat << EOF >&2
Usage: $PROGNAME [-f <file>] [-i <install>] [-r <remove>] [-l <list>]
-f <file>: config file you'd like to use
-i <install> -r <remove> -l <list>: option you'd like to use without being prompted
EOF
exit 1
}
init() {
mkdir $proj
cd $proj
mv ../* .
cd ..
cp ./$proj/install.sh ./
cp ./$proj/sample/dotfiles.json ./
cp ./$proj/sample/DEPENDENCIES.md ./
mkdir dotfiles
echo "Installed. You can now place your dotfiles in the ./dotfiles folder."
}
install() {
while getopts "f:ilr" opt; do
case $opt in
(f) file=$OPTARG;;
(i) option="i";;
(l) option="l";;
(r) option="r";;
(*) usage
esac
done
if [ -e "../$proj" ]; then
cd ..
fi
if [ ! -e "./$proj/src/setup_dotfiles.py" ]; then
git submodule update --init --recursive
fi
err_message=$(python ./$proj/src/setup_dotfiles.py -f $file -o $option 1>/dev/stdin 2>&1)
echo $err_message
}
if [ ! -e "$proj" ] && [ ! -e "../$proj" ]; then
init
else
install $*
if [[ option == "i" ]] && [[ -z err_message ]]; then
# post-install
source ./preprocessor.sh
fi
fi