添加了一些条件判断
This commit is contained in:
parent
56ae9b08ef
commit
4945bdd752
22
init_root.sh
22
init_root.sh
@ -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
|
||||||
@ -74,7 +80,7 @@ configure_vim() {
|
|||||||
|
|
||||||
configure_apt_upgrade() {
|
configure_apt_upgrade() {
|
||||||
read -p "要运行 apt upgrade 吗?[y/N]: " response
|
read -p "要运行 apt upgrade 吗?[y/N]: " response
|
||||||
|
|
||||||
if [[ $response =~ ^[Yy]$ ]]; then
|
if [[ $response =~ ^[Yy]$ ]]; then
|
||||||
apt update
|
apt update
|
||||||
apt upgrade -y
|
apt upgrade -y
|
||||||
@ -84,7 +90,7 @@ configure_apt_upgrade() {
|
|||||||
|
|
||||||
configure_apt_install() {
|
configure_apt_install() {
|
||||||
read -p "要运行 apt install 吗?[Y/n]: " response
|
read -p "要运行 apt install 吗?[Y/n]: " response
|
||||||
|
|
||||||
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||||
apt update
|
apt update
|
||||||
apt install tmux git curl htop net-tools tcptraceroute tar unzip -y
|
apt install tmux git curl htop net-tools tcptraceroute tar unzip -y
|
||||||
@ -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
|
||||||
@ -130,11 +140,13 @@ configure_tmux() {
|
|||||||
git_clone tmux-plugins/tmux-prefix-highlight ~/.tmux/plugins/tmux-prefix-highlight
|
git_clone tmux-plugins/tmux-prefix-highlight ~/.tmux/plugins/tmux-prefix-highlight
|
||||||
git_clone seebi/tmux-colors-solarized ~/.tmux/plugins/tmux-colors-solarized
|
git_clone seebi/tmux-colors-solarized ~/.tmux/plugins/tmux-colors-solarized
|
||||||
cp $scriptdir/files/.tmux.conf ~/.tmux.conf
|
cp $scriptdir/files/.tmux.conf ~/.tmux.conf
|
||||||
apt install xsel -y # 能够让 tmux 剪切板与 terminal 同步
|
apt install xsel -y # 能够让 tmux 剪切板与 terminal 同步
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
@ -145,8 +157,8 @@ configure_iptables() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if [[ $EUID -ne 0 ]]; then
|
if [[ $EUID -ne 0 ]]; then
|
||||||
echo "This script must be run as root."
|
echo "This script must be run as root."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
check_google_access
|
check_google_access
|
||||||
|
|||||||
22
init_sudo.sh
22
init_sudo.sh
@ -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
|
||||||
@ -74,7 +80,7 @@ configure_vim() {
|
|||||||
|
|
||||||
configure_apt_upgrade() {
|
configure_apt_upgrade() {
|
||||||
read -p "要运行 apt upgrade 吗?[y/N]: " response
|
read -p "要运行 apt upgrade 吗?[y/N]: " response
|
||||||
|
|
||||||
if [[ $response =~ ^[Yy]$ ]]; then
|
if [[ $response =~ ^[Yy]$ ]]; then
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt upgrade -y
|
sudo apt upgrade -y
|
||||||
@ -84,7 +90,7 @@ configure_apt_upgrade() {
|
|||||||
|
|
||||||
configure_apt_install() {
|
configure_apt_install() {
|
||||||
read -p "要运行 apt install 吗?[Y/n]: " response
|
read -p "要运行 apt install 吗?[Y/n]: " response
|
||||||
|
|
||||||
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install tmux git curl htop net-tools tcptraceroute tar unzip -y
|
sudo apt install tmux git curl htop net-tools tcptraceroute tar unzip -y
|
||||||
@ -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
|
||||||
@ -130,11 +140,13 @@ configure_tmux() {
|
|||||||
git_clone tmux-plugins/tmux-prefix-highlight ~/.tmux/plugins/tmux-prefix-highlight
|
git_clone tmux-plugins/tmux-prefix-highlight ~/.tmux/plugins/tmux-prefix-highlight
|
||||||
git_clone seebi/tmux-colors-solarized ~/.tmux/plugins/tmux-colors-solarized
|
git_clone seebi/tmux-colors-solarized ~/.tmux/plugins/tmux-colors-solarized
|
||||||
cp $scriptdir/files/.tmux.conf ~/.tmux.conf
|
cp $scriptdir/files/.tmux.conf ~/.tmux.conf
|
||||||
sudo apt install xsel -y # 能够让 tmux 剪切板与 terminal 同步
|
sudo apt install xsel -y # 能够让 tmux 剪切板与 terminal 同步
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
@ -145,8 +157,8 @@ configure_iptables() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if [[ $EUID -eq 0 ]]; then
|
if [[ $EUID -eq 0 ]]; then
|
||||||
echo "This script should not be run as root."
|
echo "This script should not be run as root."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
check_google_access
|
check_google_access
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user