-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·130 lines (115 loc) · 3.52 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
#!/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: [email protected]
# License: MIT
################################################################################
DOT_DIR_NAME="${DOT_DIR_NAME:-.dotfiles}"
DOT_DIR="${DOT_DIR:-${HOME%/}/${DOT_DIR_NAME%/}}"
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
}
get_args() {
while [[ $# -gt 0 ]]; do
case $1 in
-h | --help)
;;
-d | --dotfiles)
shift
DOT_DIR="$1"
;;
-n | --name)
shift
DOT_DIR_NAME="$1"
;;
-v | --verbose)
# Export so all scripts get value
export VERBOSE=$(( $VERBOSE+1 ))
;;
-q | --quiet)
export VERBOSE=0
;;
*)
;;
esac
shift
done
}
main() {
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 "${DOT_DIR}/install_files" ]]; then
export INSTALLER_DIR="${DOT_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
if [[ -a "${INSTALLER_DIR}/vim.sh" ]]; then
#source "${_DINSTALL}/vim.sh" -b ${BUILD_DIR} -t \
# && success "vim built successfully" \
# || error "vim failed to install"
install "${INSTALLER_DIR}/vim.sh" -b ${BUILD_DIR} -t
fi
# Make sure to install vundle into the right directory
# git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
# Install zsh
#if [[ -a
else
echo "Couldn't find ${BUILD_DIR}"
fi
}
#
main "$@" || exit 1