-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.sh
executable file
·137 lines (115 loc) · 4.99 KB
/
setup.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
#/usr/bin/env bash
# Note: You'll notice a lot of `set +/-x` in this file. This controls where
# bash echos the executed commands.
# set -x; # enables
# set +x; # disables
# When enabled all executed commands are echo'd included those in executed scripts
# Example `set -x && source ~/.bashrc` would echo every command ~/.bashrc
# Logging everything would be fairly verbose therefore some commands are
# disabled line by line with `set +x; command; set -x`
test -r ~/.dotfiles_initialized && echo "dotfiles already setup; ~/.dotfiles_initialized exists!" && exit 0
read -p "Setup requires an internet connection, is long, and requires checkins. Is this okay? (Y/n)? " answer
case ${answer:0:1} in
y|Y )
;;
* )
exit 0
;;
esac
set -x
find ~ -mindepth 1 -maxdepth 1 -type d -exec rmdir {} \;
# Setup home directories
test ! -d ~/downloads && test -d ~/Downloads && mv ~/Downloads ~/downloads
mkdir -p ~/downloads
xdg-user-dirs-update --set DOWNLOAD ~/downloads
mkdir -p ~/scripts
mkdir -p ~/projects/c
mkdir -p ~/projects/go
mkdir -p ~/projects/go/src
mkdir -p ~/projects/go/pkg
mkdir -p ~/projects/go/bin
mkdir -p ~/projects/go-mod/src
mkdir -p ~/projects/python
echo "===== Replicating Folder Structure ====="
# Find all directories and make in $HOME. Directories cannot be symlinked from
# dotfiles as they won't always have all of the needed configs and I don't want
# to track everything in them nor maintain a .gitignore
(cd home/zaq && find . -type d -exec test ! -d ~/'{}' \; -and -exec mkdir ~/'{}' \;)
test -f ~/.bashrc && \
read -p "Existing ~/.bashrc found. Overwrite (Y/n)? " answer && \
case ${answer:0:1} in
y|Y )
rm ~/.bashrc
;;
* )
;;
esac
echo "===== Symlinking Files ====="
# Find all files and create symlinks from $HOME
(cd home/zaq && find . -type f -exec test ! -r ~/'{}' \; -and -exec ln -s `pwd`/'{}' ~/'{}' \;)
# needed for PATH and GO env vars
set +x; source ~/.bashrc; set -x
echo '===== "system" packages ====='
sudo apt update
sudo apt install -y neovim tmux keychain xclip scrot graphviz keynav curl xinit jq ripgrep
sudo apt install -y x11-xserver-utils
sudo apt install -y build-essential cmake libxinerama-dev
# Get Applications
if ! [ -x "$(command -v go)" ]; then
set +x; echo "===== Downloading latest GoLang ====="; set -x
curl -L "https://golang.org/dl$(curl -s -L https://golang.org/dl | grep 'download downloadBox.\+linux-amd64' | cut -d'"' -f 4)" | sudo tar -C /usr/local/ -xzf -
fi
if ! [ -x "$(command -v hub)" ]; then
set +x; echo "===== Getting hub ====="; set -x
go get github.com/github/hub
fi
if ! [ -x "$(command -v gh)" ]; then
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
sudo apt-add-repository https://cli.github.com/packages
sudo apt update
sudo apt install gh
fi
if ! [ -x "$(command -v lab)" ]; then
set +x; echo "===== Getting lab ====="; set -x
curl -s https://raw.githubusercontent.com/zaquestion/lab/master/install.sh | bash
fi
if ! [ -x "$(command -v dwm)" ]; then
set +x; echo "===== Compiling dwm ====="; set -x
go get github.com/zaquestion/gods
git clone git://git.suckless.org/dwm ~/projects/c/dwm
cp ~/suckless/dwm/* ~/projects/c/dwm/
(cd ~/projects/c/dwm && sudo make install)
fi
if ! [ -x "$(command -v st)" ]; then
set +x; echo "===== Compiling st ====="; set -x
git clone https://go.googlesource.com/image /tmp/image-go-fonts
sudo cp /tmp/image-go-fonts/font/gofont/ttfs/Go-Mono* /usr/share/fonts/truetype/
git clone git://git.suckless.org/st ~/projects/c/st
cp ~/suckless/st/* ~/projects/c/st/
(cd ~/projects/c/st && sudo make install)
fi
if ! [ -x "$(command -v gopls)" ]; then
GO111MODULE=on go get golang.org/x/tools/gopls@latest
fi
# Python Stuff
echo "===== Python Environment ====="
sudo apt install -y make openssl libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev
sudo apt install -y llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev liblzma-dev libgdbm-dev
set +x; source ~/.bashrc; set -x
pip install pynvim seqdiag yapf awscli
# Config Applications
echo "===== nvim Environment ====="
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
nvim +PlugInstall +UpdateRemotePlugins +GoInstallBinaries +qall
# From https://docs.docker.com/engine/installation/linux/debian/
echo "===== Docker ====="
sudo apt install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common && \
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - && \
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" && \
sudo apt update && \
sudo apt install -y docker-ce && \
sudo gpasswd -a ${USER} docker && \
sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -sL "https://api.github.com/repos/docker/compose/releases/latest" | jq -r .tag_name)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \
sudo chmod a+x /usr/local/bin/docker-compose
touch ~/.dotfiles_initialized