-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup-ubuntu
More file actions
executable file
·214 lines (177 loc) · 5.76 KB
/
setup-ubuntu
File metadata and controls
executable file
·214 lines (177 loc) · 5.76 KB
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#!/usr/bin/env bash
set -ex
script_dir="$(cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd)"
gui=true
setup_home_partition=true
while getopts fgh OPT; do
case "$OPT" in
g)
gui=false
;;
h)
setup_home_partition=false
;;
\?)
exit 2
;;
esac
done
sudo apt-get update
# For add-apt-repository
sudo apt install software-properties-common
sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse"
#sudo add-apt-repository -y "deb http://archive.canonical.com/ubuntu $(lsb_release -sc) partner"
snaps=""
pkgs="\
cscope \
curl \
expect \
exuberant-ctags \
git \
git-email \
python3-pip \
moreutils \
tmux \
vim \
"
if $gui; then
pkgs="$pkgs \
acpi \
apt-file \
apt-rdepends \
docker \
ibus-pinyin \
net-tools \
ppa-purge \
vlc \
"
snaps="$snaps \
signal-desktop \
telegram-desktop \
"
# Usefull stuff that does not come by default or Canonical would have to pay royalties.
# MANUAL accept ncurses confirmation
# https://askubuntu.com/questions/16225/how-can-i-accept-the-microsoft-eula-agreement-for-ttf-mscorefonts-installer/25614#25614
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections
pkgs="$pkgs ubuntu-restricted-extras"
# Browser
pkgs="$pkgs chromium-browser"
# 14.04
# 14.04 < 21.04
#pkgs="$pkgs flashplugin-installer"
# X utils
pkgs="$pkgs wmctrl xbacklight xsel"
# 17.04
# https://askubuntu.com/questions/829592/how-can-i-stop-gvim-from-crashing-when-opening-a-file/904727#904727
# http://askubuntu.com/questions/33260/difference-between-vim-gtk-and-vim-gnome
#pkgs="$pkgs vim-gtk"
#" < 17.04
#pkgs="$pkgs vim-gnome"
#" > 21.04
#pkgs="$pkgs vim-gtk"
# LXCE does not have a toolbar.
# https://askubuntu.com/questions/69556/how-to-check-battery-status-using-terminal
pkgs="$pkgs acpi"
## Google talk.
#wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
#sudo sh -c 'echo "deb http://dl.google.com/linux/talkplugin/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
#pkgs="$pkgs google-talkplugin"
fi
sudo apt install -y $pkgs
for snap in $snaps; do
# 21.04
# https://askubuntu.com/questions/1008731/how-to-install-multiple-snaps-simultaneously/1344260#1344260
sudo snap install $snap
done
if $gui; then
sudo snap install pycharm-community --classic
fi
## System settings.
# Not needed and privacy concern.
# https://serverfault.com/questions/684771/best-way-to-disable-swap-in-linux
sudo swapoff -a
sudo sed -i '/\tswap\t/d' /etc/fstab
# sudo without password.
sudo sh -c "echo '$(id -un) ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers"
# Disable suspend on lid close.
# https://askubuntu.com/questions/15520/how-can-i-tell-ubuntu-to-do-nothing-when-i-close-my-laptop-lid/830653#830653
sudo sed -i '/HandleLidSwitch/d' /etc/systemd/logind.conf >/dev/null 1&>2
echo 'HandleLidSwitch=ignore' | sudo tee -a /etc/systemd/logind.conf
# TTY without sudo
# https://askubuntu.com/questions/133235/how-do-i-allow-non-root-access-to-ttyusb0-on-12-04
sudo usermod -a -G dialout "$USER"
# Quick OS system choice and show kernel messages:
printf 'GRUB_TIMEOUT=1\nGRUB_CMDLINE_LINUX_DEFAULT=""\n' | sudo tee -a /etc/default/grub
sudo update-grub
if $setup_home_partition; then
# Git
f="$HOME/.ssh/id_rsa"
if [ ! -f "$f" ]; then
ssh-keygen -b 4096 -C "ciro.santilli@gmail.com" -f "$f" -t rsa -P ''
fi
# Dotfiles
if [ ! -e $HOME/.homesick/repos/homeshick ]; then
git clone git://github.com/andsens/homeshick.git $HOME/.homesick/repos/homeshick
fi
. "$HOME/.homesick/repos/homeshick/homeshick.sh"
if [ ! -e "${HOME}/.homesick/repos/dotfiles" ]; then
yes | homeshick clone cirosantilli/dotfiles
fi
# Vim
# Manual.
# TODO fails from bash pipe becuase not TTY.
# http://stackoverflow.com/questions/23322744/vim-run-commands-from-bash-script-and-exit-without-leaving-shell-in-a-bad-state
#vim +PluginInstall +qall
# nodejs
# https://askubuntu.com/questions/594656/how-to-install-the-latest-versions-of-nodejs-and-npm/971612#971612
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | sh
. ~/.nvm/nvm.sh
nvm install --lts
nvm use --lts
# https://rvm.io/rvm/install
#
# Ubuntu 20.10
# https://unix.stackexchange.com/questions/399027/gpg-keyserver-receive-failed-server-indicated-a-failure/632238#632238
# gpgconf --kill dirmngr
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -sSL https://get.rvm.io | bash -s stable --ruby
bundle update --bundler
fi
if $gui; then
dconf load / < "${script_dir}/dconf.conf"
# Python
pip install --user --upgrade pip virtualenv
# chinese-input
# MANUAL settings > text entry > chinese (pinyin ibus)
ibus restart
# Automatically run upgrades without confirmation.
# MANUAL accept ncurses confirmation.
sudo dpkg-reconfigure unattended-upgrades
sudo apt-file update
# TODO terminal background color from purple to black.
# I think I had researched and it was impossible to automate, but lost thread now.
fi
if false; then
# Go
# https://askubuntu.com/questions/959932/installation-instructions-for-golang-1-9-into-ubuntu-16-04/1075726#1075726
# https://github.com/moovweb/gvm/issues/302
sudo apt-get install golang-go
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
. ~/.gvm/scripts/gvm
v=go1.11
gvm install "$v"
gvm use "$v"
fi
## Settings post install
sudo usermod -aG docker $USER
## Home dependant
. ~/.bashrc
mkdir -p \
"$CIROSANTILLI_BIN_DIR" \
"$CIROSANTILLI_TMP_DIR" \
"$DOWNLOAD_DIR" \
"$MEDIA_DIR" \
"$PROGRAM_DIR" \
"$TEST_DIR" \
"$CIROSANTILLI_VAR_LOG_DIR" \
;