-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·99 lines (80 loc) · 3.49 KB
/
start.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
#!/bin/bash
set -xe
ROOT=$(pwd)/$(dirname "${BASH_SOURCE}")
echo $ROOT
## Global VAR
pkgs="wget curl vim tmux git gcc g++ make automake autoconf patch libtool \
ntpdate ack-grep tcpdump python3 openssh-server unzip python3-pip \
jq locales cmake colordiff zsh ripgrep"
export DEBIAN_FRONTEND=noninteractive
export TZ=Etc/UTC
### Apt Install
if [ "$CI" != "true" ]; then
# travis ci connect 163.com timeout
sed -i 's#/archive.ubuntu.com#/cn.archive.ubuntu.com#g' /etc/apt/sources.list
fi
apt-get update && apt-get install -y $pkgs
### System Config
unlink /etc/localtime && ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
if [ "$CI" != "true" ]; then
ntpdate -u -o3 time1.aliyun.com
fi
mkdir -p /etc/cron.d && echo "0 * * * * root (/usr/sbin/ntpdate -u -o3 time1.aliyun.com)" > /etc/cron.d/ntpdate
echo "nameserver 223.5.5.5" > /etc/resolv.conf
export LANGUAGE=en_US.UTF-8; export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8; locale-gen en_US.UTF-8
dpkg-reconfigure locales
### Install Oh My Zsh
git clone https://github.com/ohmyzsh/ohmyzsh.git /tmp/ohmyzsh && /tmp/ohmyzsh/tools/install.sh --unattended
### Config it
if [ ! -f $HOME/.bashrc.user ]; then
echo ". $HOME/.bashrc.user" >> $HOME/.bashrc \
&& echo ". $HOME/.zshrc.user" >> $HOME/.zshrc \
&& find ${ROOT}/etc/ -type f | xargs -i ln -s {} $HOME/
fi
### Motd
rm -rf /etc/update-motd.d/* && cp ${ROOT}/bin/motd.py /etc/update-motd.d/50-sysinfo && chmod +x /etc/update-motd.d/50-sysinfo
sed -i -e 's|\(PrintLastLog\s*\)yes|\1no|' /etc/ssh/sshd_config
sed -i -e 's|#\(PrintLastLog\s*no\)|\1|' /etc/ssh/sshd_config
sed -i -e 's|#\(PrintLastLog\s*\)yes|\1no|' /etc/ssh/sshd_config
sed -i -e 's|\(PrintMotd\s*\)no|\1yes|' /etc/ssh/sshd_config
sed -i -e 's|#\(PrintMotd\s*yes\)|\1|' /etc/ssh/sshd_config
sed -i -e 's|#\(PrintMotd\s*\)no|\1yes|' /etc/ssh/sshd_config
### SSH Client Config
echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config
echo "UserKnownHostsFile /dev/null" >> /etc/ssh/ssh_config
if [ ! -f /root/.ssh/id_rsa ]; then
ssh-keygen -t rsa -N "" -f /root/.ssh/id_rsa
fi
### Install Golang From Source
mkdir -p $HOME/golang/3rdpkg \
&& cd $HOME/golang \
&& wget http://collection.b0.upaiyun.com/softwares/go-src.tar.gz -O go-src.tar.gz \
&& tar zxvf go-src.tar.gz && rm go-src.tar.gz && mv go go-src \
&& cp -R go-src go-1.4 && cp -R go-src go-1.17
export GOROOT=$HOME/golang/go
export GOROOT_BOOTSTRAP=$HOME/golang/go-1.4
ln -s $HOME/golang/go-1.4 $GOROOT
cd $GOROOT && git checkout go1.4.3 && cd src && CGO_ENABLED=0 ./make.bash
unlink $GOROOT
ln -s $HOME/golang/go-1.17 $GOROOT
cd $GOROOT && git checkout go1.17.7 && cd src && ./make.bash
. $HOME/.bashrc.user
### Install Vim Plugins
mkdir -p $HOME/.vim/bundle && git clone https://github.com/VundleVim/Vundle.vim.git $HOME/.vim/bundle/Vundle.vim
if [[ -t 0 ]]; then
vim -u $HOME/.vimrc.vundle +'PluginInstall' +qall
else
### non-interactive https://github.com/VundleVim/Vundle.vim/issues/511#issuecomment-134251209
echo | vim -u $HOME/.vimrc.vundle +'PluginInstall' +qall &>/dev/null
fi
$HOME/.vim/bundle/fzf/install --all
### Install Docker
curl -fsSL https://get.docker.com | sh
### Install upx
GOPROXY="https://goproxy.cn,direct" go install github.com/upyun/upx@v0.3.6
### Install https://github.com/wg/wrk
cd /tmp && git clone https://github.com/wg/wrk && cd wrk && make && mv wrk /usr/bin
### Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rustup.sh && sh /tmp/rustup.sh -y
source $HOME/.cargo/env
chsh -s `which zsh`