-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap
More file actions
executable file
·65 lines (57 loc) · 2.48 KB
/
bootstrap
File metadata and controls
executable file
·65 lines (57 loc) · 2.48 KB
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
#!/usr/bin/env bash
DOTFILES_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# load installation helpers
source "$DOTFILES_ROOT/cross-platform/.functions"
# find out which platform we're running on
pf=`platforms`
function find_bootstrap_script_of_type_for_platform {
# can be 'packages', 'dotfiles', 'platform'
local bootstrap_script_type=$1
# can be any platform ('windows', 'macos')
local platform=$2
# check for file in platform-specific bootstrap folder
local bootstrap_script_path="$DOTFILES_ROOT/${platform}/bootstrap/${bootstrap_script_type}.sh"
if [[ -f $bootstrap_script_path ]]; then
# return path to boostrap script
echo "$bootstrap_script_path"
else
fail "Bootstrap script of type $bootstrap_script_type for platform $platform not found"
fi
}
# update all submodules
info "$(printf "Updating %b%s%b" $light_green "Git Submodules" $reset_color)"
git submodule update --init --recursive .
success "$(printf "%b%s%b successfully updated" $light_green "Git Submodules" $reset_color)"
# Package Management
# run any platform specific package management tasks
packages_bootstrap_script_path=$(find_bootstrap_script_of_type_for_platform 'packages' $pf)
if [[ -f $packages_bootstrap_script_path ]]; then
info "$(printf "Installing / Updating Packages using %b%s%b" $light_green "Package Manager" $reset_color)"
source "$packages_bootstrap_script_path"
fi
# Symlink / Dotfile Management
info "$(printf "Taking care of dotfiles through %b%s%b" $light_green "symlinking" $reset_color)"
dotfiles_bootstrap_script_path=$(find_bootstrap_script_of_type_for_platform 'dotfiles' $pf)
if [[ -f $dotfiles_bootstrap_script_path ]]; then
info "$(printf "Installing dotfiles to %b\$HOME%b=%b%s%b for %b\$OSTYPE%b=%b%s%b" \
$light_red $reset_color \
$green "$HOME" $reset_color \
$light_red $reset_color \
$light_yellow "$pf" $reset_color)"
source "$dotfiles_bootstrap_script_path"
fi
# run any platform specific bootstrap scripts (e.g. osx-defaults on macos)
platform_bootstrap_script_path=$(find_bootstrap_script_of_type_for_platform 'platform' $pf)
if [[ -f $platform_bootstrap_script_path ]]; then
info "$(printf "Running platform-specific scripts for %b%s%b" $light_green $pf $reset_color)"
source "$platform_bootstrap_script_path"
fi
info "Updating bash / zsh configuration"
if [[ ( "$pf" == 'linux' ) || ( "$pf" == 'macos' ) ]]; then
# reload shell as zsh
exec zsh -l
source $HOME/.zshrc
else
fail "Platform $pf not supported"
fi
success "Bootstrap done"