-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.ubuntu.sh
executable file
·154 lines (124 loc) · 3.94 KB
/
bootstrap.ubuntu.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
#!/bin/sh
if [ "$(whoami)" = "root" ]; then
echo "Please DO NOT execute the script the user who have \`root\` privilege"
exit 1
fi
if [ "$(lsb_release -is)" != "Ubuntu" ]; then
echo "Sorry, this script was written for Ubuntu only"
exit 1
fi
if [ "$(whoami)" != "root" ]; then
SUDO='sudo -E'
else
SUDO=''
fi
DO_INSTALL="${SUDO} apt install -y"
DO_UPGRADE="${SUDO} apt upgrade -y"
# detect current running user
if [ -n "${SUDO_USER}" ]; then
HOMEDIR="$(eval echo ~"${SUDO_USER}")"
else
HOMEDIR="${HOME}"
fi
setupconfig() {
if diff "${1}" "${2}" >/dev/null; then
rm -f "${2}.bak"
return
fi
if [ -f "${2}" ]; then
cp "${2}" "${2}.bak"
fi
cp "${1}" "${2}"
}
setupconfig bash.bashrc "${HOMEDIR}/.bashrc"
setupconfig bash.bashrc.aliases "${HOMEDIR}/.bashrc.aliases"
setupconfig bash.bash_profile "${HOMEDIR}/.bash_profile"
setupconfig vim.vimrc "${HOMEDIR}/.vimrc"
setupconfig tig.tigrc "${HOMEDIR}/.tigrc"
setupconfig zsh.zshrc "${HOMEDIR}/.zshrc"
setupconfig zsh.zshrc.aliases "${HOMEDIR}/.zshrc.aliases"
# ssh config
mkdir -p "${HOMEDIR}/.ssh"
if [ -f "${HOMEDIR}/.ssh/config" ]; then
awk '
/^Host \*$/ || /^$/ { show=0 }
/^Host [a-zA-z0-9][a-zA-z0-9\-]+/ { show=1 }
show { print }
' "${HOMEDIR}/.ssh/config" | tee "${HOMEDIR}/.ssh/config.bak" >/dev/null
fi
cat > "${HOMEDIR}/.ssh/config" <<-EOF
Host *
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
ServerAliveInterval 60
UseRoaming no
# UseKeychain yes
LogLevel quiet
EOF
cat "${HOMEDIR}/.ssh/config.bak" | tee -a "${HOMEDIR}/.ssh/config" >/dev/null
sed -i -e '2,$s/^Host /\nHost /g' "${HOMEDIR}/.ssh/config"
chmod 0640 "${HOMEDIR}/.ssh/config"
# pre-setup
${SUDO} apt update
${DO_INSTALL} git
# ssh services
${DO_INSTALL} openssh-client
${DO_INSTALL} openssh-server
# security upgrade for heartbleed and shellshock
${DO_INSTALL} bash openssl
# develop tools
${DO_INSTALL} git tig git-extras
${DO_INSTALL} curl colordiff meld vim wget ripgrep
${DO_INSTALL} ethtool htop iftop iperf tcpdump fping
${DO_INSTALL} shellcheck jq
# zsh
${DO_INSTALL} zsh
# create link for git-prompt.sh
if [ -f /etc/profile.d/git-prompt.sh ] || [ -L /etc/profile.d/git-prompt.sh ]; then
${SUDO} rm -vf /etc/profile.d/git-prompt.sh
fi
if [ -f /usr/share/git-core/contrib/completion/git-prompt.sh ]; then
${SUDO} ln -s -f /usr/share/git-core/contrib/completion/git-prompt.sh /etc/profile.d/
fi
if [ ! -f /etc/profile.d/git-prompt.sh ]; then
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh | \
${SUDO} tee /etc/profile.d/git-prompt.sh >/dev/null
fi
# setup z jump
curl https://raw.githubusercontent.com/rupa/z/master/z.sh > ${HOMEDIR}/.zjump
# general tools
${DO_INSTALL} p7zip p7zip-full unrar unzip
# bbs
${DO_INSTALL} pcmanx-gtk2
# irc
${DO_INSTALL} hexchat
# chinese fonts
${DO_INSTALL} fonts-wqy-microhei fonts-wqy-zenhei
# input method
${DO_INSTALL} ibus-chewing
# gnome toolkits
${DO_INSTALL} gnome-tweak-tool dconf-editor
${DO_INSTALL} gnome-shell-extensions
${DO_INSTALL} gnome-shell-extension-caffeine
# ruby
${DO_INSTALL} ruby ruby-dev rubygems-integration
# multimedia
${DO_INSTALL} ffmpeg flashplugin-installer \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly
# vlc
${DO_INSTALL} vlc
# virtualbox
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | ${SUDO} apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | ${SUDO} apt-key add -
echo "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" | \
${SUDO} tee /etc/apt/sources.list.d/virtualbox.list
${DO_INSTALL} virtualbox-7.0
# vagrant
curl -fsSL https://apt.releases.hashicorp.com/gpg | ${SUDO} apt-key add -
echo "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \
${SUDO} tee /etc/apt/sources.list.d/hashicorp.list
${SUDO} apt-get update && ${DO_INSTALL} vagrant
# apt upgrade
${DO_UPGRADE}