-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·92 lines (67 loc) · 3.11 KB
/
bootstrap.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
#!/bin/bash
# ----------------------------------------------------------------------
# | Init |
# ----------------------------------------------------------------------
#
# WARNING
# =======
#
# This section was written in this way to make sure that it can be run
# remotely or locally with the same behaviour.
#
# Please do not change anything here unless you know very well well
# what you are doing.
#
# =======
#
[ ! -v DOTFILES_ROOT_DIR ] && declare -r DOTFILES_ROOT_DIR="$HOME/.dotfiles"
mkdir -p "$DOTFILES_ROOT_DIR"
cd "$DOTFILES_ROOT_DIR" || exit 1
[ ! -v CURRENT_BRANCH ] \
&& declare -r CURRENT_BRANCH=$(git branch --show-current 2> /dev/null || echo "main")
[ ! -v DOTFILES_GITHUB_RAW_CONTENT_ORIGIN ] \
&& declare -r DOTFILES_GITHUB_RAW_CONTENT_ORIGIN="https://raw.githubusercontent.com/omar-besbes/.dotfiles/$CURRENT_BRANCH"
source "$DOTFILES_ROOT_DIR/scripts/utils.sh" &>/dev/null ||
source <(curl -fsSL "$DOTFILES_GITHUB_RAW_CONTENT_ORIGIN/scripts/utils.sh")
source "$DOTFILES_ROOT_DIR/scripts/setup_topics.sh" &>/dev/null ||
source <(curl -fsSL "$DOTFILES_GITHUB_RAW_CONTENT_ORIGIN/scripts/setup_topics.sh")
source "$DOTFILES_ROOT_DIR/scripts/sync_files.sh" &>/dev/null ||
source <(curl -fsSL "$DOTFILES_GITHUB_RAW_CONTENT_ORIGIN/scripts/sync_files.sh")
# ----------------------------------------------------------------------
# | Global Dependencies |
# ----------------------------------------------------------------------
install_dependencies() {
# install git
execute "sudo apt-get install -y git" "Installing git ..."
# install curl
execute "sudo apt-get install -y curl" "Installing curl ..."
# install rustup & cargo
if ! cmd_exists rustup; then
execute "curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- --no-modify-path -y" "Installing rustup ..."
source "$HOME/.cargo/env"
mkdir -p "$HOME/.bash_completion.d"
rustup completions bash > "$HOME/.bash_completion.d/rustup"
fi
# install nvm & node
! cmd_exists nvm && \
execute "PROFILE=/dev/null bash -c 'curl -fSL -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash'" "Installing nvm ..."
# install shellcheck
execute "sudo apt-get install -y shellcheck" "Installing shellcheck ..."
# install xclip
execute "sudo apt-get install -y xclip" "Installing xclip ..."
# isntall necessary compression and extraction tools
execute "sudo apt-get install -y bzip2 gzip zip xz-utils tar" "Installing extraction/compression tools ..."
# install gcc, g++ & some other tools
execute "sudo apt-get install -y ca-certificates fontconfig build-essential software-properties-common" "Installing essential tools ..."
}
# ----------------------------------------------------------------------
# | Main |
# ----------------------------------------------------------------------
main() {
ask_for_sudo
install_dependencies
execute "sync_dotfiles" "Synchronizing files with remote ..."
# begin installing configs
setup_topics $DOTFILES_SOURCE_DIR
}
main