/
install
64 lines (50 loc) · 1.56 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
#!/usr/bin/env bash
{ # this ensures the entire script is downloaded #
shopt -s extglob
set -o errtrace
set -o errexit
set -o pipefail
log() { printf "%b\n" "$*"; }
debug(){ [[ ${rvm_debug_flag:-0} -eq 0 ]] || printf "%b\n" "$*" >&2; }
warn() { log "WARN: $*" >&2 ; }
fail() { fail_with_code 1 "$*" ; }
fail_with_code() { code="$1" ; shift ; log "\nERROR: $*\n" >&2 ; exit "$code" ; }
# Check and Install all dependencies
function require_util() {
type "$1" > /dev/null 2>&1 || command -v "$1" > /dev/null 2>&1 ||
oops "you do not have '$1' installed, which I need to $2"
}
function install_dependencies_osx() {
echo "Installing dependencies for $OSTYPE"
if [[ `xcode-select -p` ]];
then
echo "xcode cli already installed";
else
xcode-select --install
fi
}
function install_dependencies_linux() {
echo "Installing dependencies for $OSTYPE"
if [ -f /etc/lsb-release ]; then
sudo apt update -y
sudo apt install -y git
else
fail_with_code 1 "Installation is not support for your distribution"
fi
}
if [[ "$OSTYPE" == "linux-gnu" ]]; then
install_dependencies_linux
elif [[ "$OSTYPE" == "darwin"* ]]; then
install_dependencies_osx
else
fail_with_code 1 "Installation is not supported for your platform $OS"
fi
require_util git "install git"
mkdir -p ~/projects/sw/repos/personal && cd "$_"
if ! [[ -d "${HOME}/projects/sw/repos/personal/dotfiles" ]];
then
git clone https://github.com/ageekymonk/dotfiles.git
fi
cd dotfiles
make setup
} # this ensures the entire script is downloaded #