-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·70 lines (63 loc) · 1.96 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
#!/usr/bin/env bash
CONFIG_DIR="$HOME/.config"
PACKAGES=(
"expect"
"rsync"
"git"
"zsh"
"neofetch"
"tmux"
)
install_package() {
if type brew &> /dev/null; then
# macOS
brew install "$@"
elif type apt-get &> /dev/null; then
# Debian-based
sudo apt-get install -y "$@"
elif type dnf &> /dev/null; then
# Fedora-based
sudo dnf install -y "$@"
elif type yum &> /dev/null; then
# Red Hat-based
sudo yum install -y "$@"
elif type apk &> /dev/null; then
# Alpine Linux
sudo apk add --no-cache "$@"
elif type pacman &> /dev/null; then
# Arch-based
sudo pacman -Syu --noconfirm "$@"
else
echo "Error: Unsupported Package manager, please update script."
return 1
fi
}
echo "Bootstrap script. Please press return to start."
read -r -n 1
#### macOS INSTALL BREW & XCODE TOOLS ####
# macOS doesn't come with git preinstalled, we need to install XCode Command Line Tools
# This is handled automatically by the Brew install which is needed later anyway
if [[ $OSTYPE =~ ^darwin ]] && ! type brew >/dev/null 2>&1; then
echo "Install Homebrew & Xcode Command Line Tools."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
#### INSTALL NEEDED PACKAGES ####
for package in "${PACKAGES[@]}"; do
if ! type "$package" >/dev/null 2>&1; then
installpack+=("$package")
else
echo "already present $package"
fi
done
if [[ "${#installpack[@]}" -gt 0 ]]; then
install_package "${installpack[@]}"
unset installpack
fi
#### CREATE DIRS, CLONE REPO & START MAIN INSTALL SCRIPT ####
if [[ ! -d "$CONFIG_DIR/dotfiles/.git" ]]; then
git clone https://github.com/fl4shback/dotfiles.git "$HOME/.config/dotfiles"
else
git -C "$CONFIG_DIR/dotfiles/" fetch && git -C "$CONFIG_DIR/dotfiles/" pull
fi
# shellcheck disable=SC1091
source "$HOME/.config/dotfiles/bootstrap_main.sh"