-
Notifications
You must be signed in to change notification settings - Fork 15
/
auto-installer.sh
168 lines (151 loc) · 5.06 KB
/
auto-installer.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/bash
APT_PACKAGES=(fd-find ripgrep libtool-bin cmake tidy)
BREW_PACKAGES=(fd ripgrep readline openssl zlib postgresql sqlite ruby-build rbenv libffi libgccjit gcc)
NPM_PACKAGES=(vscode-css-languageserver-bin vscode-html-languageserver-bin typescript-language-server @tailwindcss/[email protected] stylelint js-beautify import-js)
GEMS=(solargraph bundler)
DOOM_GIT=(https://github.com/hlissner/doom-emacs)
DOTFILES_GIT=(https://github.com/otavioschwanck/doom_emacs_dotfiles.git)
get_bash_profile () {
if test -f ".zshrc"; then
BASH_PROFILE=(.zshrc)
else
BASH_PROFILE=(.bashrc)
fi
}
get_machine_type () {
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac
echo "Proceeding instalation for OS ${machine}"
}
ask_question () {
echo "Do you wish to install $1?"
select yn in "Yes" "No"; do
case $yn in
Yes ) echo "Installing $1";$2;break;;
No ) echo "Not installing $1";break;;
esac
done
}
# Install base packages
install_packages_linux () {
echo "================= INSTALLING PACKAGES ================="
sudo apt-get -qq update
sudo apt-get -qq install ${APT_PACKAGES[*]} -y
sudo npm install -s -g ${NPM_PACKAGES[*]} -y
}
install_packages_mac () {
echo "================= INSTALLING PACKAGES ================="
brew install ${BREW_PACKAGES[*]}
brew link libpq --force
}
prompt_ruby_versions () {
echo "Which ruby versions would you like to install? Use spaces to install more than one"
echo "Example: 2.7.1 3.0.1 3.1.1"
echo "Leave blank to not install any"
IFS= read -rp 'Ruby Verions: ' USER_RUBY_INPUT
IFS=' '
read -a RUBY_VERSIONS <<< "$USER_RUBY_INPUT"
}
install_ruby_linux () {
echo "================= INSTALLING RUBY ================="
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash
git clone https://github.com/rbenv/ruby-build.git
cat ruby-build/install.sh
PREFIX=/usr/local sudo ./ruby-build/install.sh
echo "gem: --no-document" > ~/.gemrc
prompt_ruby_versions
for i in "${RUBY_VERSIONS[@]}"; do rbenv install $i -s; echo "Installed ruby version $i"; done
}
install_ruby_mac () {
echo "================= INSTALLING RUBY ON MAC ================="
echo "gem: --no-document" > ~/.gemrc
prompt_ruby_versions
for i in "${RUBY_VERSIONS[@]}"; do rbenv install $i -s; echo "Installed ruby version $i"; done
}
install_fonts () {
echo "================= INSTALLING FONTS ================="
if [ -d ~/$FONTS_LIBRARY ]; then
echo "Fonts folder located, proceeding to install fonts"
else
mkdir ~/$FONTS_LIBRARY
fi
cd; wget -q https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/JetBrainsMono.zip
unzip -q -o JetBrainsMono.zip -d ~/$FONTS_LIBRARY
cd; rm JetBrainsMono.zip
}
install_gems () {
echo "================= INSTALLING GEMS ================="
if [ "$(which rbenv)" = "" ]
then
echo "Rbenv not found"
else
cd ~/.rbenv/versions/; RUBY_VERSION=(*);rbenv local "$RUBY_VERSION"; rbenv global "$RUBY_VERSION"; cd
echo "Ruby version $RUBY_VERSION was set as global"
echo 'eval "$(rbenv init -)"' >> ~/$BASH_PROFILE
eval "$(rbenv init -)"
rbenv local $RUBY_VERSION
fi
for i in $GEMS; do gem install $i; done
}
install_emacs_linux () {
echo "================= INSTALLING EMACS ================="
# Install Emacs using snap
sudo snap install emacs --classic
}
install_emacs_mac () {
echo "================= INSTALLING EMACS ================="
brew tap d12frosted/emacs-plus
brew install emacs-plus
}
install_emacs_doom () {
echo "================= INSTALLING DOOM ================="
git clone --quiet --depth 1 $DOOM_GIT ~/.emacs.d
git clone --quiet $DOTFILES_GIT ~/.doom.d
~/.emacs.d/bin/doom install
}
linux_workflow () {
FONTS_LIBRARY=".fonts"
ask_question "base packages for emacs" install_packages_linux
if [ "$(which emacs)" = "" ]
then
'We did not find a working emacs client within your system, proceeding to ask for instalation'
ask_question "Emacs client" install_emacs_linux
fi
if [ "$(which rbenv)" = "" ]
then
'We did not find a working rbenv within your system, proceeding to ask for instalation'
ask_question "Ruby on Rails with Rbenv" install_ruby_linux
fi
}
mac_workflow () {
FONTS_LIBRARY="Library/Fonts"
ask_question "base packages for emacs" install_packages_mac
if [ "$(which emacs)" = "" ]
then
'We did not find a working emacs client within your system, proceeding to ask for instalation'
ask_question "Emacs client" install_emacs_mac
fi
if [ "$(which rbenv)" = "" ]
then
'We did not find a working rbenv within your system, proceeding to ask for instalation'
ask_question "Ruby on Rails with Rbenv" install_ruby_mac
fi
}
# SCRIPT QUESTIONAIRE
get_machine_type
get_bash_profile
case "${machine}" in
Linux) linux_workflow;;
Mac) mac_workflow;;
*) echo "OS not recognized"
esac
install_fonts
install_gems
install_emacs_doom
echo "Script finished!"