-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·199 lines (177 loc) · 7.26 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
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#! /bin/bash
noop=0
prefix=""
ui=0
repo=$(pwd)
usage="usage ./install.sh [-t|--test] -p|--prefix /prefix/path -[u|--both-de]"
[[ $# -eq 0 ]] && { echo "$usage"; exit 1; }
while [[ $# -gt 0 ]]
do
key=$1
case $key in
-t|--test)
noop=1
;;
-p|--prefix)
prefix="$2"
shift
;;
-u|--both-de)
ui=1
;;
*)
echo "$usage"
exit 1
;;
esac
shift
done
[[ $noop -eq 1 ]] && echo "Not performing any operation"
function installYayStuff() {
echo "installing vscode"
[[ $noop -eq 0 ]] && yay -Sy code || { echo "error installing vscode"; exit 1; }
}
function installFonts() {
echo "Getting and setting up otf-overpass ttf-ubuntu-font-family awesome-terminal-fonts otf-font-awesome ttf-font-awesome powerline-fonts"
[[ $noop -eq 0 ]] && sudo pacman -Sy otf-overpass ttf-ubuntu-font-family awesome-terminal-fonts {otf,ttf}-font-awesome powerline-fonts || { echo "could not install fonts"; exit 1; }
echo "refreshing font cache"
[[ $noop -eq 0 ]] && fc-cache -fv
}
function moveOlder() {
echo "Aggressively moving exiting rcs, if they exist"
cmd="echo"
[[ $noop -eq 0 ]] && cmd="mv"
$cmd ${prefix}/.zshrc{,.bak}
$cmd ${prefix}/.bashrc{,.bak}
$cmd ${prefix}/.vimrc{,.bak}
}
function prepareMirrors(){
sudo mv /etc/pacman.d/mirrorlist{,.orig}
cat >/tmp/mirrorlist <<-EOF
Server = http://mirrors.evowise.com/archlinux/\$repo/os/\$arch
Server = http://mirror.rise.ph/archlinux/\$repo/os/\$arch
Server = http://mirror-hk.koddos.net/archlinux/\$repo/os/\$arch
Server = http://mirrors.kernel.org/archlinux/\$repo/os/\$arch
Server = http://mirror.0x.sg/archlinux/\$repo/os/\$arch
Server = http://mirror.cse.iitk.ac.in/archlinux/\$repo/os/\$arch
EOF
sudo mv /tmp/mirrorlist /etc/pacman.d/
}
function installCommon(){
echo "Will install git zsh curl wget axel lua vim arc-gtk-theme xfce4-terminal chromium firefox chrome-gnome-shell xorg-server networkmanager network-manager-applet redshift openssh termite"
[[ $noop -eq 0 ]] && sudo pacman -Sy git zsh curl wget axel lua vim arc-gtk-theme xfce4-terminal firefox chrome-gnome-shell xorg-server networkmanager network-manager-applet termite || { echo "could not install common packages"; exit 1; }
[[ $noop -eq 0 ]] && yay -Sy google-chrome || { echo "could not install common packages"; exit 1; }
}
function installI3Based() {
echo "Will install i3-gaps i3lock i3status lxappearance bumblebee-status"
[[ $noop -eq 0 ]] && sudo pacman -Sy i3-gaps i3lock i3status lxappearance || { echo "could not install i3 packages"; exit 1; }
[[ $noop -eq 0 ]] && yay -Sy bumblebee-status || { echo "could not install i3 packages"; exit 1; }
}
function installGnomeshell() {
echo "Will install gnome-shell gnome-session gnome-search-tool gnome-backgrounds gnome-control-center gnome-tweaks"
[[ $noop -eq 0 ]] && sudo pacman -Sy gnome-shell gnome-session gnome-search-tool gnome-backgrounds gnome-control-center gnome-tweaks || { echo "could not install gnome packages"; exit 1; }
}
function installLoginMgr(){
[[ $1 -eq 1 ]] && lm="gdm" || lm="lightdm lightdm-gtk-greeter"
echo "installing $lm"
[[ $noop -eq 0 ]] && sudo pacman -Sy "$lm" || { echo "unable to install login mgr"; exit 1; }
}
function installZsh() {
[[ -e "$prefix/.oh-my-zsh" ]] && { echo "oh-my-zsh exists"; return; }
echo "Will clone and install oh-my-zsh"
[[ $noop -eq 0 ]] && sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
}
function installVim() {
[[ -e '~/.vim/autoload/plug.vim' ]] && { echo "plug.vim exists"; return; }
echo "Will clone and install vim plug"
[[ $noop -eq 0 ]] && curl -fLo ~/.vim/autoload/plug.vim --create-dirs 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
}
function clonePrograms() {
[[ -e "$prefix/programs" ]] && { echo "programs exists"; return; }
echo "Cloning programs into ~"
[[ $noop -eq 0 ]] && git clone https://github.com/smjn/programs "$prefix/programs"
}
function dictionary() {
#dictionary
echo "Downloading and setting up stardict"
if [[ $noop -eq 0 ]]; then
wget 'https://www.dropbox.com/s/f293v4w310inrut/stardict.tgz?dl=0' -O /tmp/stardict.tgz
tar -xvf /tmp/stardict.tgz -C ${prefix}
fi
}
function makeDirs() {
echo "Will make if needed ${prefix}/.config/{i3,xfce4/terminal}"
if [[ $noop -eq 0 ]]; then
mkdir -p ${prefix}/.config/{i3,xfce4/terminal,termite}
fi
}
function setupMiscLinks() {
echo "setting up misc links"
# sudo ln -sf /etc/profile.d/vte-2.91.sh /etc/profile.d/vte.sh
}
function setupRcs() {
for i in $(ls -a)
do
case "$i" in
.oh-my-zsh)
for theme in `ls "$i"`
do
echo "${prefix}/.oh-my-zsh/themes/$theme -> ${repo}/.oh-my-zsh/themes/$theme"
if [[ $noop -eq 0 ]]; then
ln -sf "${repo}/.oh-my-zsh/themes/$theme" "${prefix}/.oh-my-zsh/themes/$theme"
fi
done
;;
.config)
echo "${prefix}/.config/xfce4/terminal/terminalrc -> ${repo}/.config/xfce4/terminal/terminalrc"
echo "${prefix}/.config/redshift.conf -> ${repo}/.config/redshift.conf"
echo "${prefix}/.config/i3/config -> ${repo}/.config/i3/config"
echo "${prefix}/.config/termite/config -> ${repo}/.config/termite/config"
if [[ $noop -eq 0 ]]; then
ln -sf ${repo}/.config/xfce4/terminal/terminalrc ${prefix}/.config/xfce4/terminal/terminalrc
ln -sf ${repo}/.config/i3/config ${prefix}/.config/i3/config
ln -sf ${repo}/.config/redshift.conf ${prefix}/.config/redshift.conf
ln -sf ${repo}/.config/termite/config ${prefix}/.config/termite/config
fi
;;
vimrc.local)
echo "${prefix}/vimrc.local -> ${repo}/vimrc.local"
[[ $noop -eq 0 ]] && ln -sf ${repo}/vimrc.local ${prefix}/vimrc.local
;;
".zshrc" | ".bashrc" | ".vimrc" | ".i3status.conf" | ".dircolors")
echo "${prefix}/$i -> ${repo}/$i"
[[ $noop -eq 0 ]] && ln -sf ${repo}/$i ${prefix}/$i
;;
"wall.png")
[[ -e ${prefix}/$i ]] && { echo "wallpaper link exists"; return; }
echo "${prefix}/$i -> ${repo}/$i \n ${prefix}/Pictures/$i -> ${repo}/$i"
ln -sf ${repo}/$i ${prefix}/$i
[[ -d ${prefix}/Pictures ]] && ln -sf ${repo}/$i ${prefix}/Pictures/$i
;;
*)
echo "Ignoring $i"
;;
esac
done
}
function setupSysdServices() {
sudo systemctl enable NetworkManager sshd
[[ $1 -eq 0 ]] && sudo systemctl enable lightdm || sudo systemctl enable gdm
sudo systemctl disable netctl netctl-auto
}
if [[ $noop -eq 0 ]]; then
installCommon
installI3Based
[[ $ui -eq 1 ]] && installGnomeshell
installLoginMgr $ui
installZsh
installVim
installFonts
clonePrograms
moveOlder
makeDirs
setupMiscLinks
setupRcs
dictionary
setupSysdServices $ui
fi