-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·61 lines (52 loc) · 1.55 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
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
source ./support/functions.sh
cutstring="DO NOT EDIT BELOW THIS LINE"
ignore=" install.sh uninstall.sh README.md .gitignore .gitmodules support "
# Dependencies
source ./support/dependencies.sh
# Create symlinks
for name in *; do
target="$HOME/.$name"
if [ -e "$target" ]; then
if [ ! -L "$target" ]; then
if [ -d "$target" ]; then
warn "$target is an existing directory"
else
cutline=$(grep -n -m1 "$cutstring" "$target" | sed "s/:.*//")
if [ -n "$cutline" ]; then
cutline=$((cutline - 1))
success "Updating $target"
head -n $cutline "$target" >update_tmp
startline=$(sed '1!G;h;$!d' "$name" | grep -n -m1 "$cutstring" | sed "s/:.*//")
if [ -n "$startline" ]; then
tail -n $startline "$name" >>update_tmp
else
cat "$name" >>update_tmp
fi
mv update_tmp "$target"
else
warn "$target exists but is not a symlink"
fi
fi
else
warn "$target is already a symlink"
fi
else
if [[ ! $ignore =~ " $name " ]]; then
# hiding grep, as shel can't do '-a' w/ executing both sides...
testing=false
if [ ! -d "$name" ]; then
testing=[ -a -n "$(grep "$cutstring" "$name")" ]
fi
if [ testing = false ]; then
success "Copying $target"
cp "$PWD/$name" "$target"
else
success "Symlinking $target"
ln -s "$PWD/$name" "$target"
fi
fi
fi
done
# Post-install
source ./support/post_install.sh