-
Notifications
You must be signed in to change notification settings - Fork 3
/
bootstrap
executable file
·40 lines (35 loc) · 1.25 KB
/
bootstrap
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
#!/usr/bin/env bash
SOURCE="https://github.com/finalangel/dotfiles"
TARBALL="$SOURCE/tarball/master"
TARGET="$HOME/.dotfiles"
TAR_CMD="tar -xzv -C "$TARGET" --strip-components=1"
# barebone functions as utils is not yet available
is_executable() { type "$1" > /dev/null 2>&1; }
info () { printf "\r [ \033[00;34m..\033[0m ] $1\n"; }
success () { printf "\r\033[2K [ \033[00;32mOK\033[0m ] $1\n"; }
fail_hard () { printf "\r\033[2K [\033[0;31mFAIL\033[0m] $1\n" && echo "" && exit; }
# check if we can bootstrap the dotfiles
info "👉 Initiating dotfiles bootstrap"
# either git, curl or wget is required
if is_executable "git"; then
CMD="git clone $SOURCE $TARGET"
elif is_executable "curl"; then
CMD="curl -#L $TARBALL | $TAR_CMD"
elif is_executable "wget"; then
CMD="wget --no-check-certificate -O - $TARBALL | $TAR_CMD"
fi
# use scripts/install instead if already setup
if [ -d "$TARGET" ]; then
fail_hard "Repository already setup, use 'dot' manager instead. Aborting!"
fi
# one last check
if [ -z "$CMD" ]; then
fail_hard "No git, curl or wget available. Aborting!"
else
info "Setup \033[0;37m[repository]\033[0m"
mkdir -p "$TARGET"
eval "$CMD"
success "Repository successfully setup"
# now load the installer
source "$TARGET/scripts/install"
fi