Repository navigation
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·142 lines (115 loc) · 3.81 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·142 lines (115 loc) · 3.81 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
#!/bin/bash
MIRROR="http://mirrors.cernet.edu.cn/"
handle_error() {
echo "Error: $1"
exit 1
}
setup_environment() {
echo "This script will set up your development environment."
read -p "Do you want to continue? [Y/n] " choice
[[ "$choice" == "n" ]] && handle_error "Script aborted by user."
echo "Starting setup..."
}
configure_apt_sources() {
echo "Configuring apt sources..."
source /etc/os-release
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo cp $ID-$VERSION_CODENAME.list /etc/apt/sources.list
read -p "Change apt source? [default=CERNET] " MIRROR
[[ $MIRROR ]] && sudo sed -i "s|deb http://mirrors.cernet.edu.cn/|deb ${MIRROR}|g" /etc/apt/sources.list
echo "Apt sources updated. Running apt update..."
sudo apt update
}
install_core_tools() {
echo "Installing core development tools..."
sudo apt install -y build-essential git tmux screen \
strace htop nodejs \
tcpdump nmap netcat iproute2 iptables \
zsh fzf wget curl \
vim trash-cli exa \
lsscsi || handle_error "Failed to install core tools."
# may fail for unofficial kernel release
sudo apt install -y linux-tools-$(uname -r)
}
add_llvm_source() {
wget https://mirrors.cernet.edu.cn/llvm-apt/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh all -m https://mirrors.cernet.edu.cn/llvm-apt
}
deploy_dotfiles() {
echo "Deploying dotfiles..."
cp ".zshrc" "$HOME/"
cp ".vimrc" "$HOME/"
cp ".tmux.conf" "$HOME/"
chsh -s $(which zsh)
}
set_proxy() {
read -p "Set http_proxy [empty for no proxy]: " HTTP_PROXY
export HTTPS_PROXY=$HTTP_PROXY
export HTTP_PROXY=$HTTP_PROXY
read -p "Set socks_proxy [empty for no proxy]: " SOCKS_PROXY
export SOCKS_PROXY=$SOCKS_PROXY
echo "export HTTP_PROXY='$HTTP_PROXY'" >> $HOME/.zshrc
echo "export HTTPS_PROXY='$HTTP_PROXY'" >> $HOME/.zshrc
echo "export http_proxy='$HTTP_PROXY'" >> $HOME/.zshrc
echo "export https_proxy='$HTTP_PROXY'" >> $HOME/.zshrc
echo "export SOCKS_PROXY='$SOCKS_PROXY'">> $HOME/.zshrc
echo "export socks_proxy='$SOCKS_PROXY'">> $HOME/.zshrc
sed -i "s|HTTP_PROXY_SUBSTITUTE|$HTTP_PROXY|" $HOME/.zshrc
sed -i "s|SOCKS_PROXY_SUBSTITUTE|$SOCKS_PROXY|" $HOME/.zshrc
}
install_ccls() {
sudo apt install clang libclang-19-dev llvm-19
git clone --recurse https://github.com/MaskRay/ccls.git
cd ccls
cmake -S. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/usr/lib/llvm-19 -DLLVM_INCLUDE_DIR=/usr/lib/llvm-19/include -DLLVM_BUILD_INCLUDE_DIR=/usr/include/llvm-19/
cmake --build Release
cd Release
sudo make install
cd ../..
}
configure_dev_env() {
echo "Configuring programming environment..."
sudo apt install -y python3 python3-pip python3-pygments || handle_error "Failed to install python."
git config --global user.name "Tilnel Sun"
git config --global user.email "sunbweng@outlook.com"
git config --global core.editor "vim"
git config --global http.proxy "$HTTP_PROXY"
install_ccls
which ccls || handle_error "Failed to install ccls"
}
preconfigure_vim() {
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
cp filetype.vim coc-settings.json ~/.vim
mkdir ~/.vim/.undo
}
install_latest_vim() {
sudo apt install -y libncurses-dev
cd vim
./configure --prefix=/usr
sudo make install
cd ..
preconfigure_vim
}
generate_ssh_key() {
ssh-keygen
}
install_latest_gcc() {
source install_latest_gcc.sh
}
main() {
setup_environment
configure_apt_sources
install_core_tools
add_llvm_source
deploy_dotfiles
set_proxy
configure_dev_env
install_latest_vim
generate_ssh_key
read -p "Do you want to install latest GCC? [y/N] " GCC
[[ "$GCC" == "y" ]] && install_latest_gcc
echo "Setup complete!"
}
main