添加了一些条件判断

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() { configure_ssh() {
[ -f "~/.ssh/authorized_keys" ] && return
read -p "要配置 .ssh 吗?[Y/n]: " response read -p "要配置 .ssh 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
@ -45,6 +47,8 @@ configure_ssh() {
} }
configure_ssh_keygen() { configure_ssh_keygen() {
[ -f "~/.ssh/id_ed25519.pub" ] && return
read -p "要生成 sshkey 吗?[y/N]: " response read -p "要生成 sshkey 吗?[y/N]: " response
if [[ $response =~ ^[Yy]$ ]]; then if [[ $response =~ ^[Yy]$ ]]; then
@ -55,6 +59,8 @@ configure_ssh_keygen() {
} }
configure_nano() { configure_nano() {
[ -f "~/.nanorc" ] && return
read -p "要配置 nano 吗?[Y/n]: " response read -p "要配置 nano 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
@ -102,6 +108,8 @@ configure_apt_install() {
} }
configure_zsh() { configure_zsh() {
[ -f "~/.zshrc" ] && return
read -p "要配置 zsh 吗?[Y/n]: " response read -p "要配置 zsh 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
@ -120,6 +128,8 @@ configure_zsh() {
} }
configure_tmux() { configure_tmux() {
[ -f "~/.tmux.conf" ] && return
read -p "要配置 tmux 吗?[Y/n]: " response read -p "要配置 tmux 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
@ -135,6 +145,8 @@ configure_tmux() {
} }
configure_iptables() { configure_iptables() {
[ -f "/etc/network/if-pre-up.d/iptables-load" ] && return
read -p "要配置 iptables 吗?[n/Y]: " response read -p "要配置 iptables 吗?[n/Y]: " response
if [[ $response =~ ^[Yy]$ ]]; then if [[ $response =~ ^[Yy]$ ]]; then

View File

@ -36,6 +36,8 @@ check_google_access() {
} }
configure_ssh() { configure_ssh() {
[ -f "~/.ssh/authorized_keys" ] && return
read -p "要配置 .ssh 吗?[Y/n]: " response read -p "要配置 .ssh 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
@ -45,6 +47,8 @@ configure_ssh() {
} }
configure_ssh_keygen() { configure_ssh_keygen() {
[ -f "~/.ssh/id_ed25519.pub" ] && return
read -p "要生成 sshkey 吗?[y/N]: " response read -p "要生成 sshkey 吗?[y/N]: " response
if [[ $response =~ ^[Yy]$ ]]; then if [[ $response =~ ^[Yy]$ ]]; then
@ -55,6 +59,8 @@ configure_ssh_keygen() {
} }
configure_nano() { configure_nano() {
[ -f "~/.nanorc" ] && return
read -p "要配置 nano 吗?[Y/n]: " response read -p "要配置 nano 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
@ -102,6 +108,8 @@ configure_apt_install() {
} }
configure_zsh() { configure_zsh() {
[ -f "~/.zshrc" ] && return
read -p "要配置 zsh 吗?[Y/n]: " response read -p "要配置 zsh 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
@ -120,6 +128,8 @@ configure_zsh() {
} }
configure_tmux() { configure_tmux() {
[ -f "~/.tmux.conf" ] && return
read -p "要配置 tmux 吗?[Y/n]: " response read -p "要配置 tmux 吗?[Y/n]: " response
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
@ -135,6 +145,8 @@ configure_tmux() {
} }
configure_iptables() { configure_iptables() {
[ -f "/etc/network/if-pre-up.d/iptables-load" ] && return
read -p "要配置 iptables 吗?[n/Y]: " response read -p "要配置 iptables 吗?[n/Y]: " response
if [[ $response =~ ^[Yy]$ ]]; then if [[ $response =~ ^[Yy]$ ]]; then