-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·96 lines (86 loc) · 2.05 KB
/
install
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
. ./bin/vars.sh
. ./bin/formatting.sh
show_help() {
echo "Usage: ./install [options]"
echo ""
echo "Options:"
echo " -l, --link Create symbolic links instead of copying files"
echo " -b, --backup Backup any non-symlink files to be overwritten"
echo " -h, --help Display this help message and exit"
}
INSTALL="cp -r"
INSTALL_MSG="Copying"
BACKUP=false
while [ $# -gt 0 ]; do
case "$1" in
-l | --link)
INSTALL="ln -svf"
INSTALL_MSG="Symlinking"
shift
;;
-b | --backup)
BACKUP=true
shift
;;
-h | --help)
show_help
exit
;;
*)
show_help
exit 1
;;
esac
done
export INSTALL
export INSTALL_MSG
export BACKUP
remove_existing_installation() {
"$DOTFILES_DIR"/uninstall
}
ensure_config_dirs() {
if [ ! -d "$HOME"/.config ]; then
info "Creating $HOME/.config directory...\n"
mkdir "$HOME"/.config
fi
}
ensure_script_dirs() {
if [ ! -d "$HOME"/.local ]; then
info "Creating $HOME/.local directory...\n"
mkdir "$HOME"/.local
info "Creating $HOME/.local/bin directory...\n"
mkdir "$HOME"/.local/bin
elif [ ! -d "$HOME"/.local/bin ]; then
info "Creating $HOME/.local/bin directory...\n"
mkdir "$HOME"/.local/bin
fi
}
install_config () {
ensure_config_dirs
info "$INSTALL_MSG config folders...\n"
for config in "$DOTFILES_DIR"/config/*; do
eval "$INSTALL" "$config" "$XDG_CONFIG_HOME/${config##*/}"
done
eval "$INSTALL" "$DOTFILES_DIR"/.bashrc "$HOME"/.bashrc
}
install_scripts() {
ensure_script_dirs
info "$INSTALL_MSG scripts/excecutables...\n"
for executable in "$DOTFILES_DIR"/bin/*; do
eval "$INSTALL" "$executable" "$HOME/.local/bin/${executable##*/}"
done
}
OS_script() {
if [ "$(uname)" = "Darwin" ]; then
"$DOTFILES_DIR"/darwin/install
fi
}
main() {
remove_existing_installation
install_config
install_scripts
OS_script
info "Done!\n"
}
main