2024-07-24 00:56:26 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
declare install_str
|
2024-09-12 13:20:44 +08:00
|
|
|
declare version="$(cat /etc/os-release | grep "^ID" | awk -F '=' '{print $2}')"
|
2024-07-27 15:12:30 +08:00
|
|
|
|
|
|
|
declare pkg
|
|
|
|
if [[ -f "/usr/bin/apt-get" ]];then
|
2024-09-21 14:17:49 +08:00
|
|
|
pkg='apt-get install -y'
|
|
|
|
sudo apt-get update -y
|
|
|
|
sudo apt-get dist-upgrade -y
|
2024-07-27 15:12:30 +08:00
|
|
|
elif [[ -f "/usr/bin/apt" ]];then
|
2024-09-21 14:17:49 +08:00
|
|
|
pkg='apt install -y'
|
|
|
|
sudo apt update -y
|
|
|
|
sudo apt dist-upgrade -y
|
2024-07-27 15:12:30 +08:00
|
|
|
else
|
|
|
|
echo "暂不支持该系统一键安装常用软件"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2024-07-24 00:56:26 +08:00
|
|
|
|
|
|
|
declare pick
|
|
|
|
declare -a soft_array
|
|
|
|
soft_array[0]='git'
|
|
|
|
soft_array[1]='vim'
|
|
|
|
soft_array[2]='wget'
|
|
|
|
soft_array[3]='curl'
|
2024-09-10 17:18:11 +08:00
|
|
|
soft_array[4]='ssh'
|
|
|
|
soft_array[5]='zsh'
|
|
|
|
soft_array[6]='zip'
|
2024-07-24 00:56:26 +08:00
|
|
|
|
|
|
|
echo "======一键安装常用软件======"
|
2024-07-24 13:28:46 +08:00
|
|
|
for i in "${soft_array[@]}"
|
2024-07-24 00:56:26 +08:00
|
|
|
do
|
|
|
|
read -p "是否安装${i},输入 n 取消安装:" pick
|
|
|
|
if [[ ! $pick =~ [Nn] ]];then
|
|
|
|
install_str+=" ${i}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
declare pick_x
|
|
|
|
read -p "是否安装x-cmd,输入 n 取消安装:" pick_x
|
|
|
|
|
|
|
|
declare pick_zsh
|
|
|
|
read -p "是否一键美化zsh,输入 n 取消:" pick_zsh
|
|
|
|
|
|
|
|
declare pick_docker
|
|
|
|
read -p "是否安装docker,输入 n 取消:" pick_docker
|
|
|
|
|
|
|
|
if [[ ! $pick_docker =~ [Nn] ]];then
|
|
|
|
declare -A docker_imgs
|
|
|
|
docker_imgs['官方']='https://download.docker.com'
|
|
|
|
docker_imgs['中国科技大学(默认)']='https://mirrors.ustc.edu.cn/docker-ce'
|
|
|
|
docker_imgs['清华大学']='https://mirrors.tuna.tsinghua.edu.cn/docker-ce'
|
|
|
|
docker_imgs['阿里云']='https://mirrors.aliyun.com/docker-ce'
|
2024-07-24 13:25:35 +08:00
|
|
|
docker_imgs['网易云']='https://mirrors.163.com/docker-ce'
|
|
|
|
|
|
|
|
|
2024-07-24 00:56:26 +08:00
|
|
|
declare -a docker_img_number
|
|
|
|
declare docker_img_number_pick=0
|
|
|
|
|
|
|
|
for i in "${!docker_imgs[@]}"; do
|
|
|
|
docker_img_number_pick=$((docker_img_number_pick + 1))
|
|
|
|
docker_img_number[$docker_img_number_pick]=$i
|
2024-07-24 12:50:44 +08:00
|
|
|
echo "${docker_img_number_pick}.${i}"
|
2024-07-24 00:56:26 +08:00
|
|
|
done
|
|
|
|
read -p "请输入需要选择的镜像站:" docker_img_number_pick
|
|
|
|
declare docker_img
|
|
|
|
if [[ ! $docker_img_number_pick =~ [1-${#docker_imgs[@]}] ]];then
|
2024-07-27 15:12:30 +08:00
|
|
|
docker_img='https://mirrors.sustc.edu.cn/docker-ce'
|
2024-07-24 00:56:26 +08:00
|
|
|
else
|
|
|
|
docker_img_number_pick=${docker_img_number[$docker_img_number_pick]}
|
|
|
|
docker_img=${docker_imgs[$docker_img_number_pick]}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [[ ! $pick_x =~ [Nn] ]];then
|
|
|
|
|
|
|
|
eval "$(curl https://get.x-cmd.com)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2024-09-21 14:17:49 +08:00
|
|
|
eval "sudo ${pkg} ${install_str}"
|
2024-07-24 00:56:26 +08:00
|
|
|
if [[ ! $pick_x =~ [Nn] ]];then
|
|
|
|
eval "$(curl https://get.x-cmd.com)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! $pick_docker =~ [Nn] ]];then
|
2024-09-21 14:17:49 +08:00
|
|
|
if [[ ${pkg} =~ '^apt' || ${pkg} =~ '^apt-get' ]];then
|
2024-07-27 15:12:30 +08:00
|
|
|
sudo ${pkg} update
|
|
|
|
sudo ${pkg} install ca-certificates curl -y
|
2024-07-24 00:56:26 +08:00
|
|
|
sudo install -m 0755 -d /etc/apt/keyrings
|
|
|
|
sudo curl -fsSL "${docker_img}/linux/${version}/gpg" -o /etc/apt/keyrings/docker.asc
|
|
|
|
sudo chmod a+r /etc/apt/keyrings/docker.asc
|
|
|
|
echo \
|
|
|
|
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] ${docker_img}/linux/${version} \
|
|
|
|
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
|
|
|
|
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
2024-07-27 15:12:30 +08:00
|
|
|
sudo ${pkg} update
|
|
|
|
sudo ${pkg} install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
|
2024-07-24 00:56:26 +08:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2024-09-12 17:21:16 +08:00
|
|
|
|
|
|
|
if [[ ! $pick_zsh =~ [Nn] ]];then
|
2024-09-21 15:13:43 +08:00
|
|
|
curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | sed 's/read -r opt//g'| sed 's/exec zsh -l//g'| sh
|
2024-09-21 14:17:49 +08:00
|
|
|
while [[ ! -d "$HOME/.oh-my-zsh" ]]; do
|
|
|
|
sleep 3
|
|
|
|
done
|
2024-09-12 17:21:16 +08:00
|
|
|
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
|
|
|
|
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
|
|
|
|
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
|
|
|
|
sudo sed -i 's/^#\?ZSH_THEME.*/ZSH_THEME="powerlevel10k\/powerlevel10k"/g' ~/.zshrc
|
|
|
|
sudo sed -i 's/^#\?plugins.*/plugins=(zsh-syntax-highlighting zsh-autosuggestions command-not-found)/g' ~/.zshrc
|
2024-09-21 15:13:43 +08:00
|
|
|
exec zsh -l
|
2024-09-12 17:21:16 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-24 00:56:26 +08:00
|
|
|
echo "软件已经全部安装成功"
|