添加了一些条件判断

This commit is contained in:
Konano 2023-07-22 14:55:25 +08:00
parent 56ae9b08ef
commit 4945bdd752
2 changed files with 34 additions and 10 deletions

View File

@ -36,6 +36,8 @@ check_google_access() {
}
configure_ssh() {
[ -f "~/.ssh/authorized_keys" ] && return
read -p "要配置 .ssh 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
@ -45,6 +47,8 @@ configure_ssh() {
}
configure_ssh_keygen() {
[ -f "~/.ssh/id_ed25519.pub" ] && return
read -p "要生成 sshkey 吗?[y/N]: " response
if [[ $response =~ ^[Yy]$ ]]; then
@ -55,6 +59,8 @@ configure_ssh_keygen() {
}
configure_nano() {
[ -f "~/.nanorc" ] && return
read -p "要配置 nano 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
@ -74,7 +80,7 @@ configure_vim() {
configure_apt_upgrade() {
read -p "要运行 apt upgrade 吗?[y/N]: " response
if [[ $response =~ ^[Yy]$ ]]; then
apt update
apt upgrade -y
@ -84,7 +90,7 @@ configure_apt_upgrade() {
configure_apt_install() {
read -p "要运行 apt install 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
apt update
apt install tmux git curl htop net-tools tcptraceroute tar unzip -y
@ -102,6 +108,8 @@ configure_apt_install() {
}
configure_zsh() {
[ -f "~/.zshrc" ] && return
read -p "要配置 zsh 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
@ -120,6 +128,8 @@ configure_zsh() {
}
configure_tmux() {
[ -f "~/.tmux.conf" ] && return
read -p "要配置 tmux 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
@ -130,11 +140,13 @@ configure_tmux() {
git_clone tmux-plugins/tmux-prefix-highlight ~/.tmux/plugins/tmux-prefix-highlight
git_clone seebi/tmux-colors-solarized ~/.tmux/plugins/tmux-colors-solarized
cp $scriptdir/files/.tmux.conf ~/.tmux.conf
apt install xsel -y # 能够让 tmux 剪切板与 terminal 同步
apt install xsel -y # 能够让 tmux 剪切板与 terminal 同步
fi
}
configure_iptables() {
[ -f "/etc/network/if-pre-up.d/iptables-load" ] && return
read -p "要配置 iptables 吗?[n/Y]: " response
if [[ $response =~ ^[Yy]$ ]]; then
@ -145,8 +157,8 @@ configure_iptables() {
}
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
exit 1
echo "This script must be run as root."
exit 1
fi
check_google_access

View File

@ -36,6 +36,8 @@ check_google_access() {
}
configure_ssh() {
[ -f "~/.ssh/authorized_keys" ] && return
read -p "要配置 .ssh 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
@ -45,6 +47,8 @@ configure_ssh() {
}
configure_ssh_keygen() {
[ -f "~/.ssh/id_ed25519.pub" ] && return
read -p "要生成 sshkey 吗?[y/N]: " response
if [[ $response =~ ^[Yy]$ ]]; then
@ -55,6 +59,8 @@ configure_ssh_keygen() {
}
configure_nano() {
[ -f "~/.nanorc" ] && return
read -p "要配置 nano 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
@ -74,7 +80,7 @@ configure_vim() {
configure_apt_upgrade() {
read -p "要运行 apt upgrade 吗?[y/N]: " response
if [[ $response =~ ^[Yy]$ ]]; then
sudo apt update
sudo apt upgrade -y
@ -84,7 +90,7 @@ configure_apt_upgrade() {
configure_apt_install() {
read -p "要运行 apt install 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
sudo apt update
sudo apt install tmux git curl htop net-tools tcptraceroute tar unzip -y
@ -102,6 +108,8 @@ configure_apt_install() {
}
configure_zsh() {
[ -f "~/.zshrc" ] && return
read -p "要配置 zsh 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
@ -120,6 +128,8 @@ configure_zsh() {
}
configure_tmux() {
[ -f "~/.tmux.conf" ] && return
read -p "要配置 tmux 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
@ -130,11 +140,13 @@ configure_tmux() {
git_clone tmux-plugins/tmux-prefix-highlight ~/.tmux/plugins/tmux-prefix-highlight
git_clone seebi/tmux-colors-solarized ~/.tmux/plugins/tmux-colors-solarized
cp $scriptdir/files/.tmux.conf ~/.tmux.conf
sudo apt install xsel -y # 能够让 tmux 剪切板与 terminal 同步
sudo apt install xsel -y # 能够让 tmux 剪切板与 terminal 同步
fi
}
configure_iptables() {
[ -f "/etc/network/if-pre-up.d/iptables-load" ] && return
read -p "要配置 iptables 吗?[n/Y]: " response
if [[ $response =~ ^[Yy]$ ]]; then
@ -145,8 +157,8 @@ configure_iptables() {
}
if [[ $EUID -eq 0 ]]; then
echo "This script should not be run as root."
exit 1
echo "This script should not be run as root."
exit 1
fi
check_google_access