-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·75 lines (63 loc) · 1.62 KB
/
install
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
#!/bin/bash -eu
function clone_or_pull() {
local repo="${1}"
local location="${2}"
if [[ -d "${location}" ]]; then
echo "Pulling ${location}..."
git -C "${location}" pull
else
git clone "${repo}" "${location}"
fi
}
function install_aur_package() {
local package="${1}"
clone_or_pull "https://aur.archlinux.org/${package}.git" "${HOME}/aur/${package}"
pushd "${HOME}/aur/${package}" > /dev/null
makepkg -si --noconfirm
popd > /dev/null
}
function install_aur_packages() {
local file="${1}"
for package in $(cat ${file} | grep -v '#');
do
install_aur_package ${package}
done
}
function clone_or_pull_repos() {
local file="${1}"
while IFS=, read repo destination; do
clone_or_pull "${repo}" "${HOME}/${destination}"
done < ${file}
}
function update_nvim() {
nvim +PlugInstall +PlugUpdate +PlugUpgrade +qall --headless
}
function arch_install() {
echo "Installing on Arch..."
sudo pacman -Sy --noconfirm $(cat config/arch/packages)
install_aur_packages "config/arch/aur-packages"
}
function ubuntu_install() {
echo "Installing on Ubuntu..."
sudo apt update
sudo apt install -y $(cat config/ubuntu/packages)
}
function main() {
local os_name="$(cat /etc/os-release | grep '^NAME' | cut -d'"' -f2)"
case "${os_name}" in
"Ubuntu")
ubuntu_install
;;
"Arch Linux")
arch_install
;;
*)
echo "Unsupported OS ${os_name}"
;;
esac
clone_or_pull_repos "config/repos"
"${HOME}/.gem/ruby/2.7.0/bin/homesick" clone https://github.com/christianang/dotfiles.git
"${HOME}/.gem/ruby/2.7.0/bin/homesick" link dotfiles
update_nvim
}
main