-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·138 lines (116 loc) · 4.3 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
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
#!/usr/bin/env bash
log=$(mktemp)
here=$(readlink -f $(dirname $0))
# Handlers
die() {
echo "Error: $1" >&2
echo "See logfile $log" >&2
exit 1
}
info_() {
echo "$1" >&2
}
info_ "Writing logfile $log"v
# Checks
[ -x /bin/zsh ] || die "Please install zsh"
sudo -v &>/dev/null || die "Please make sure you have sudo"
install_pacman_packages() {
info_ "Installing pacman packages"
file=$(mktemp)
url=https://gist.githubusercontent.com/simonvpe/7025b1c75e6d310ec305b1fb380d8509/raw/
curl "$url" -o "$file" &>>$log
sudo pacman -S --needed &>>$log - < "$file"
}
install_pacman_packages
install_pacaur_packages() {
info_ "Installing pacaur packages"
file=$(mktemp)
url=https://gist.githubusercontent.com/simonvpe/556352c06c14f0753f4a7df7ad9090a6/raw
curl "$url" -o "$file" &>>$log
xargs < "$file" sudo pacaur -S --noedit --needed &>>$log
}
install_pacaur_packages
# Configure the shell to be zsh
shell=$(getent passwd $LOGNAME |cut -d: -f7)
if [[ "$shell" != "/bin/zsh" ]]; then
info_ "Configuring user shell to be zsh"
sudo usermod -s /bin/zsh $(id -un) &>>$log || die "Failed to set user shell"
fi
# Create a temp dir to work in
tmp=$(mktemp -d)
[[ "$?" == "0" ]] && cd "$tmp" || die "Failed to create temp directory"
install_oh_my_zsh() {
info_ "Installing oh-my-zsh"
git clone http://github.com/simonvpe/oh-my-zsh &>>$log && cd oh-my-zsh &>>$log \
|| die "Failed to clone oh-my-zsh"
rm -rf ~/.zshrc ~/.oh-my-zsh &>>$log
export SHELL=/bin/zsh && zsh ./tools/install.sh 0>&- 1>>$log 2>>$log || die "Failed to install zsh"
}
[ -f ~/.zshrc ] && info_ "oh-my-zsh seems to be installed already" || install_oh_my_zsh
install_asdf() {
info_ "Installing asdf"
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.4.0 &>>$log \
|| die "Failed to install asdf"
}
asdf --version >/dev/null && info_ "asdf seems to be installed already" || install_asdf
activate_asdf_bash() {
info "Activating asdf for bash"
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc
. $HOME/.asdf/asdf.sh &>>$log
. $HOME/.asdf/completions/asdf.bash &>>$log
}
grep -q '. $HOME/.asdf/asdf.sh' ~/.bashrc || activate_asdf_bash
activate_asdf_zsh() {
info "Activating asdf for zsh"
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.zshrc
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.zshrc
. $HOME/.asdf/asdf.sh &>>$log
. $HOME/.asdf/completions/asdf.bash &>>$log
}
grep -q '. $HOME/.asdf/asdf.sh' ~/.zshrc || activate_asdf_zsh
install_ruby_plugin() {
info_ "Installing ruby plugin"
asdf plugin-add ruby &>>$log
}
asdf plugin-list | grep -q ruby && info_ "ruby plugin already installed" || install_ruby_plugin
install_ruby() {
info_ "Installing ruby"
version="$(asdf list-all ruby | grep ^[0-9.]*$ | tail -n1)"
asdf install ruby "$version" &>>$log || die "Failed to install ruby"
asdf global ruby "$version" &>>$log
. ~/.bashrc
}
asdf list ruby >/dev/null && info_ "ruby is already installed" || install_ruby
# Install ruby packages
gemfile="${here}/gems"
install_ruby_gems() {
info_ "Installing ruby gems"
cat "$gemfile" | while read x; do
gem list | grep "$x" >/dev/null && info_ "$x seems to be installed ready" && continue
info_ "Installing ruby gem $x"
gem install "$x" &>>$log || die "Failed to install gem $x"
done
}
[ -f "$gemfile" ] && install_ruby_gems || info_ "$gemfile does not exist"
install_python_plugin() {
info_ "Installing python plugin"
asdf plugin-add python &>>$log
}
asdf plugin-list | grep -q python && info_ "python plugin already installed" || install_python_plugin
install_python27() {
info_ "Installing python27"
version="$(asdf list-all python|grep ^2.7|tail -n1)"
asdf install python "$version" &>>$log || die "Failed to install python27"
asdf global python "$version" &>>$log
. ~/.bashrc
}
asdf list python | grep -q ^2.7 && info_ "python27 is already installed" || install_python27
install_python36() {
info_ "Installing python36"
version="$(asdf list-all python|grep ^3.6|tail -n1)"
asdf install python "$version" &>>$log || die "Failed to install python36"
asdf global python "$version" &>>$log
. ~/.bashrc
}
asdf list python | grep -q ^3.6 && info_ "python36 is already installed" || install_python36