-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
executable file
·88 lines (73 loc) · 1.68 KB
/
init.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
#!/usr/bin/env bash
set -e
DOTFILES=$HOME/.dotfiles
lua_ver="lua5.3"
###############################################################################
# Helper functions
log_info() {
printf "\u001b[36m[*] %s\u001b[0m\n" "$@"
}
linux() {
uname | grep -i Linux &>/dev/null
}
osx() {
uname | grep -i Darwin &>/dev/null
}
not_supported() {
printf "\u001b[31m[!] This OS is not yet supported.\u001b[0m\n"
exit 1
}
install_brew() {
if ! command -v brew &>/dev/null; then
log_info "Installing Homebrew"
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
log_info "Homebrew already installed"
fi
log_info "Installing lua"
brew install lua
}
install_apt() {
log_info "Installing lua"
sudo apt update
sudo apt install -y "$lua_ver"
}
install_pacman() {
log_info "Installing lua"
yes | sudo pacman -S lua
}
install_dnf() {
log_info "Installing lua"
sudo dnf install -y lua
}
###############################################################################
# Install lua depending on OS
if osx; then
log_info "Mac OS detected!"
install_brew
elif linux; then
distro=$(grep "^ID=" /etc/os-release | cut -d'=' -f2 | sed -e 's/"//g')
log_info "$distro detected!"
case $distro in
"ubuntu")
install_apt
;;
"endeavouros" | "arch")
install_pacman
;;
"fedora")
install_dnf
;;
*)
if command -v apt &>/dev/null; then
install_apt
else
not_supported
fi
;;
esac
else
not_supported
fi
# Install dotfiles with lua script
exec "$DOTFILES"/install.lua