-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap
executable file
·33 lines (30 loc) · 1.41 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
#!/usr/bin/env bash
# vim: set tabstop=2 shiftwidth=2 expandtab:
function _bootstrap() {
local repo_git_url repo_raw_files requirements repo_folder
repo_git_url='https://github.com/aallrd/dotfiles.git'
repo_raw_files='https://raw.githubusercontent.com/aallrd/dotfiles/master'
requirements=("git" "find" "sudo")
repo_folder="${HOME}/dotfiles"
for requirement in "${requirements[@]}" ; do
command -v "${requirement}" >/dev/null 2>&1 || {
[[ "${requirement}" = "find" ]] && requirement="findutils"
printf "\\e[1;35mInstalling %s on the system...\\e[0m " "${requirement}"
(while :; do for c in / - \\ \|; do printf '%s\b' "$c"; sleep 1; done; done) &
curl -s ${repo_raw_files}/bin/pacapt | bash /dev/stdin --noconfirm -S "${requirement}" >/dev/null
{ echo -ne "\\b"; printf ' \e[1;35m[DONE]\e[0m\n'; kill $! && wait $!; } 2>/dev/null
}
done
command -v git >/dev/null 2>&1 || {
echo -e "\\e[1;31mFailed to install git on the system, cannot clone the dotfiles repo.\\e[0m";
return 1;
}
git clone "${repo_git_url}" "${repo_folder}" || {
echo -e "\\e[1;31mFailed to clone the dotfiles repo in ${repo_folder}.\\e[0m";
return 1;
}
echo -e "\\e[1;32mUsing revision: $(cd "${repo_folder}" && git rev-parse --short HEAD)\\e[0m";
echo -e "\\e[1;32mYou can now run 'cd ${repo_folder} && make help' to start the dotfiles installation.\\e[0m";
return 0
}
_bootstrap "${@}"