-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·112 lines (93 loc) · 3.05 KB
/
install.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
set -u
set -e
DOTFILE_REPO_ROOT='https://github.com/NellyWhadsDev/dotfiles'
# Sudo check
if [ "$USER" != "root" ]; then
printf '\e[31;1m%s\e[0m\n' "Warning: This script is expected to run as root" 1>&2
SUDO_USER=$USER
fi
# Env check
printf '\e[34m%s\e[0m\n' "Installing for user $SUDO_USER with home directory $HOME" 1>&2
read -r -p "Is this correct? " response
case "$response" in
[yY]) ;;
*) exit 1;;
esac
# Get system type
unameOut="$(uname -s)"
case "$unameOut" in
Linux*) machine=Linux;;
Darwin*) machine=MacOS;;
*) machine="UNKNOWN:$unameOut";;
esac
# If this is a Linux system, check for Ubuntu vs unknown
if [ "$machine" = "Linux" ]; then
unameOut="$(uname -v)"
case "$unameOut" in
*Ubuntu*) machine=Ubuntu;;
*) machine="UNKNOWN:$unameOut";;
esac
fi
# If this is an unknown distro, ask user to override using Ubuntu or MacOS config
if [ "$machine" = "UNKNOWN:$unameOut" ]; then
read -r -p "Unknown installation ($machine); Assume [U]buntu [M]acOS or [A]rch? " response
case "$response" in
[uU]) machine=Ubuntu;;
[mM]) machine=MacOS;;
[aA]) machine=Arch;;
*) ;;
esac
fi
# If nothing matched, ask user to optionally override
export MACHINE=$machine
if [ "$MACHINE" = "Ubuntu" ] || [ "$MACHINE" = "MacOS" ] || [ "$MACHINE" = "Arch" ]; then
printf '\e[34m%s\e[0m\n' "Installing on $MACHINE" 1>&2
else
printf '\e[31;1m%s\e[0m\n' "Unsupported environment: '$MACHINE'" 1>&2
exit 1
fi
# Get UI type from CLI args
export UI_TYPE=default
if [ "${1-}" = "--headless" ]; then
printf '\e[34;1m%s\e[0m\n' "Only installing heeadless components..." 1>&2
export UI_TYPE="headless"
fi
export REPOS_DIR=$HOME/Repos
printf '\e[34m%s\e[0m\n' "Setting up 'Repos' dir @ '$REPOS_DIR'..." 1>&2
mkdir -p $REPOS_DIR
printf '\e[34m%s\e[0m\n' "Setting script permissions..." 1>&2
chmod +x ./*/install.sh
printf '\e[34m%s\e[0m\n' "Installing universal dependancies..." 1>&2
if [ "$MACHINE" = "Ubuntu" ]; then
apt-get update
apt-get install curl git -y
elif [ "$MACHINE" = "MacOS" ]; then
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" </dev/null
brew install curl git
elif [ "$MACHINE" = "Arch" ]; then
pacman -Sy --noconfirm
pacman -S curl git --noconfirm
fi
printf '\e[34m%s\e[0m\n' "Installing Dependancy: Python 3.x ..." 1>&2
if ! python --version &>/dev/null; then
curl https://pyenv.run | bash
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
pyenv install 3
fi
# ZSH setup
(cd zsh ; ./install.sh)
# Tmux setup
(cd tmux ; ./install.sh)
# VSCode setup
(cd vscode ; ./install.sh)
# User setup
if [ ! -f $HOME/.gitconfig ]; then
printf '\e[34m%s\e[0m\n' "Setting global git user..." 1>&2
git config --global user.name "Nelly Whads"
git config --global user.email "[email protected]"
fi
printf '\n\e[34;1m%s\e[0m\n\n' "Done setting up OS tools" 1>&2
exit 0