-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·186 lines (163 loc) · 5.12 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/usr/bin/env bash
################################################################################
# This file is mostly here for convenience purposes
# The meat of the installation scripts will be found in install_files
# There is a linux, osx, and common installer, we will try to detect this
# automatically. Common calls for installs that are common on both systems, such
# as building from source.
#
# Author: Steven Walton
# Contact: dotfiles@walton.mozmail.com
# License: MIT
################################################################################
DOTFILE_DIR="${DOTFILE_DIR:-${HOME%/}/.dotfiles}"
DOTFILE_DIR_NAME="${DOTFILE_DIR_NAME:-".dotfiles"}"
CONFIG_DIR="${CONFIG_DIR:-${HOME%}/.config}"
INSTALLERS_DIR="${INSTALLERS_DIR:-${DOTFILE_DIR}}"
VERBOSE=1
USE_DEFAULTS=
usage() {
cat << EOF
Dotfile Install Script
Install script will try to install a new system setup.
Intended for usage on Linux and OSX. We will try to detech
which system you have and do the appropriate install.
We expect that you have cloned the install directory and
haven't deleted or moved any install files.
USAGE
install [OPTIONS]
OPTIONS:
-h, --help
print this message
-y, --yes
Accept all options
-v, --verbose
Increase verbosity
-d, --dotfiles
Sets dotfiles directory. Default: ${DOT_DIR}
-n, --name
Sets the name of the dotfiles directory. Default: ${DOT_DIR_NAME}
EOF
}
set_git_config() {
# Set git to merge when pulling
git config --global pull.rebase false
}
install() {
if [[ -a "${_DINSTALL}/${1}" ]]; then
source "${_DINSTALL}/${1}" "${@:2}" \
&& success "${1} built" \
|| error "${1} failed to build"
else
error "Couldn't find ${_DINSTALL}/${1}"
fi
}
link_rcfiles() {
# TODO: Fix so ${0} replicated ${HOME%/}/${0}" but anywhere
# TODO: Fix for mac which uses -depth and at the post -name position
find "${DOTFILE_DIR%/}/rc_files" \
-maxdepth 1 \
! -name "*.md" \
! -name "*root" \
! -name "mozilla" \
! -name "zsh" \
-exec bash -c 'ln -Fis "${0}" "${HOME%/}/.${0##*/}"' {} \;
}
link_configs() {
# TODO: Same fixes as above
find "${DOTFILE_DIR%/}/configs/" \
-maxdepth 1 \
! -name "*.md" \
-exec bash -c 'ln -Fis "${0}" "${CONFIG_DIR%/}/${0##*/}"' {} \;
}
install_cargo() {
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rust_installer.sh
sh /tmp/rust_installer.sh -y
}
vim_plugins() {
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
[[ "$!" -eq 0 ]] && echo "Plug installed successfully"
vim -c "PlugInstall" -c "qa"
[[ "$!" -eq 0 ]] && echo "Plug Plugins installed successfully"
}
install_vim() {
if [[ -a "${INSTALLERS_DIR%/}/vim.sh" ]];
then
# Make executable if not already
[[ -x "${INSTALLERS_DIR%/}/vim.sh" ]] || chmod +x "${INSTALLERS_DIR%/}/vim.sh"
echo "Installing Vim"
install "${INSTALLERS_DIR%/}/vim.sh"
[[ "$!" -eq 0 ]] && echo "Vim installed successfully"
else
echo "Could not find vim installer"
fi
}
install_zsh() {
if [[ -a "${INSTALLERS_DIR%/}/zsh.sh" ]];
then
[[ -x "${INSTALLERS_DIR%/}/zsh.sh" ]] || chmod +x "${INSTALLERS_DIR%/}/zsh.sh"
echo "Installing zsh"
install "${INSTALLERS_DIR%/}/zsh.sh"
[[ "$!" -eq 0 ]] && echo "zsh installed successfully"
else
echo "Could not find zsh installer"
fi
}
get_args() {
while [[ $# -gt 0 ]]; do
case $1 in
-h | --help)
;;
-d | --dotfiles)
shift
DOTFILE_DIR="$1"
;;
-n | --name)
shift
DOTFILE_DIR_NAME="$1"
;;
-v | --verbose)
# Export so all scripts get value
export VERBOSE=$(( $VERBOSE+1 ))
;;
-q | --quiet)
export VERBOSE=0
;;
*)
;;
esac
shift
done
}
main() {
echo "Not complete yet"
exit 1
get_args "$@"
INSTALL_FILE_LOC=$(realpath ${0})
DF_PATH=${INSTALL_FILE_LOC%/*}
# Check that we know where files are
if [[ "${DF_PATH##/*}" != ".dotfiles" ]];
then
echo -e "\e[1;31m"
echo -e "ERROR: We expect the install file to be located in our dotfiles path"
echo -e "\e[0m"
exit 1
fi
if [[ -d "${DOTFILE_DIR}/install_files" ]]; then
export INSTALLER_DIR="${DOTFILE_DIR}/install_files"
source ${INSTALLER_DIR}/installer.sh
BUILD_DIR="${BUILD_DIR:-"/tmp/dotfile_builds"}"
if [[ ! -d "${BUILD_DIR}" ]]; then
warn "${BUILD_DIR} doesn't exist, creating..."
mkdir ${BUILD_DIR}
fi
# Install vim
install_vim
# Install Plug
# curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
else
echo "Couldn't find ${BUILD_DIR}"
fi
}
#
main "$@" || exit 1