-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·47 lines (37 loc) · 1.21 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
#!/bin/sh -e
# Note that filenames MUST NOT CONTAIN NEWLINES!
symlink_file() {
canonical=$(echo $1 | sed "s|^\./||")
target="$HOME/$canonical"
origin="$(pwd)/$canonical"
if [ ! -e "$target" ] || [ -L "$target" ]; then
# target either doesn't exist or is a symbolic link and can thus be
# safely replaced
ln -sfn "$origin" "$target"
elif [ -d "$target" ]; then
# target is not a symbolic link, but a directory, thus we link
# everything into that directory instead
find "$canonical" -maxdepth 1 -mindepth 1 ! -name .gitignore \
-print | while IFS= read -r file
do
symlink_file "$file"
done
else
echo "Target file '$target' exists, but is not a symlink. Skipping."
fi
}
# make sure all submodules are there
git submodule update --init --recursive
# ensure mail directory exists
mkdir -p ~/.mail/[email protected]
find . -maxdepth 1 ! -path . ! -name .git ! -name .gitmodules \
! -name .gitignore ! -name .updated -name '.*' -print | while IFS= read -r file
do
symlink_file "$file"
done
# fix .gnupg permissions
chmod 700 .gnupg
mkdir -p ~/bin
find "$(pwd)/bin" -maxdepth 1 ! -name '.gitignore' -type f -exec ln -sf {} ~/bin/ \;
# remove broken symlinks
find -L "$HOME" -maxdepth 1 -type l -delete