添加了一些条件判断
This commit is contained in:
parent
56ae9b08ef
commit
4945bdd752
18
init_root.sh
18
init_root.sh
@ -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
|
||||
@ -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
|
||||
|
||||
18
init_sudo.sh
18
init_sudo.sh
@ -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
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user