更新了一下
This commit is contained in:
parent
e8c4a634a8
commit
d864da840c
50
init_root.sh
50
init_root.sh
@ -41,9 +41,9 @@ configure_ssh() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configure_ssh_keygen() {
|
configure_ssh_keygen() {
|
||||||
read -p "要生成 sshkey 吗?[Y/n]: " response
|
read -p "要生成 sshkey 吗?[y/N]: " response
|
||||||
|
|
||||||
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
if [[ $response =~ ^[Yy]$ ]]; then
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
read -p "sshkey 的名字: " sshkeyname
|
read -p "sshkey 的名字: " sshkeyname
|
||||||
ssh-keygen -t ed25519 -C $sshkeyname
|
ssh-keygen -t ed25519 -C $sshkeyname
|
||||||
@ -59,20 +59,32 @@ configure_nano() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
configure_install_bin() {
|
configure_apt_upgrade() {
|
||||||
apt update
|
read -p "要运行 apt upgrade 吗?[y/N]: " response
|
||||||
apt upgrade -y
|
|
||||||
apt autoremove -y
|
if [[ $response =~ ^[Yy]$ ]]; then
|
||||||
apt install tmux git curl htop net-tools tcptraceroute ifupdown tar unzip -y
|
apt update
|
||||||
apt install hexyl bat neofetch fd-find fzf -y
|
apt upgrade -y
|
||||||
|
apt autoremove -y
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
apt install exa -y
|
configure_apt_install() {
|
||||||
if [ $? -ne 0 ]; then
|
read -p "要运行 apt install 吗?[Y/n]: " response
|
||||||
unzip $scriptdir/files/exa-linux-x86_64-v0.10.1.zip -d $tempdir/exa
|
|
||||||
cp $tempdir/exa/bin/* /usr/local/bin/
|
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||||
cp $tempdir/exa/man/* /usr/share/man/man1/
|
apt update
|
||||||
cp $tempdir/exa/completions/exa.zsh /usr/local/share/zsh/site-functions
|
apt install tmux git curl htop net-tools tcptraceroute ifupdown tar unzip -y
|
||||||
rm $tempdir/exa -r
|
apt install hexyl bat neofetch fd-find fzf -y
|
||||||
|
|
||||||
|
apt install exa -y
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
unzip $scriptdir/files/exa-linux-x86_64-v0.10.1.zip -d $tempdir/exa
|
||||||
|
cp $tempdir/exa/bin/* /usr/local/bin/
|
||||||
|
cp $tempdir/exa/man/* /usr/share/man/man1/
|
||||||
|
cp $tempdir/exa/completions/exa.zsh /usr/local/share/zsh/site-functions
|
||||||
|
rm $tempdir/exa -r
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,10 +121,16 @@ configure_tmux() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
echo "This script must be run as root."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
check_google_access
|
check_google_access
|
||||||
configure_ssh
|
configure_ssh
|
||||||
configure_ssh_keygen
|
configure_ssh_keygen
|
||||||
configure_nano
|
configure_nano
|
||||||
configure_install_bin
|
configure_apt_upgrade
|
||||||
|
configure_apt_install
|
||||||
configure_zsh
|
configure_zsh
|
||||||
configure_tmux
|
configure_tmux
|
||||||
|
|||||||
136
init_sudo.sh
Executable file
136
init_sudo.sh
Executable file
@ -0,0 +1,136 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
scriptdir=$(dirname $(realpath $0))
|
||||||
|
tempdir="/tmp"
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
|
||||||
|
git_clone() {
|
||||||
|
local repo=$1
|
||||||
|
local dir=$2
|
||||||
|
|
||||||
|
if [ ! -d "$dir" ]; then
|
||||||
|
git clone --single-branch --recursive "$github/$repo" $dir
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
|
||||||
|
check_google_access() {
|
||||||
|
abroad=0
|
||||||
|
local response=$(curl -s -o /dev/null -w "%{http_code}" -m 5 "http://www.google.com")
|
||||||
|
|
||||||
|
if [ "$response" -eq 200 ]; then
|
||||||
|
abroad=1
|
||||||
|
echo "Internet: abroad"
|
||||||
|
github="https://github.com"
|
||||||
|
else
|
||||||
|
abroad=0
|
||||||
|
echo "Internet: internal"
|
||||||
|
github="https://g.nano.ac/https://github.com"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
configure_ssh() {
|
||||||
|
read -p "要配置 .ssh 吗?[Y/n]: " response
|
||||||
|
|
||||||
|
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
cp $scriptdir/files/authorized_keys ~/.ssh/authorized_keys
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
configure_ssh_keygen() {
|
||||||
|
read -p "要生成 sshkey 吗?[y/N]: " response
|
||||||
|
|
||||||
|
if [[ $response =~ ^[Yy]$ ]]; then
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
read -p "sshkey 的名字: " sshkeyname
|
||||||
|
ssh-keygen -t ed25519 -C $sshkeyname
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
configure_nano() {
|
||||||
|
read -p "要配置 nano 吗?[Y/n]: " response
|
||||||
|
|
||||||
|
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||||
|
sudo apt install nano -y
|
||||||
|
cp $scriptdir/files/.nanorc ~/.nanorc
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
configure_apt_upgrade() {
|
||||||
|
read -p "要运行 apt upgrade 吗?[y/N]: " response
|
||||||
|
|
||||||
|
if [[ $response =~ ^[Yy]$ ]]; then
|
||||||
|
sudo apt update
|
||||||
|
sudo apt upgrade -y
|
||||||
|
sudo apt autoremove -y
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
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 ifupdown tar unzip -y
|
||||||
|
sudo apt install hexyl bat neofetch fd-find fzf -y
|
||||||
|
|
||||||
|
sudo apt install exa -y
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
unzip $scriptdir/files/exa-linux-x86_64-v0.10.1.zip -d $tempdir/exa
|
||||||
|
sudo cp $tempdir/exa/bin/* /usr/local/bin/
|
||||||
|
sudo cp $tempdir/exa/man/* /usr/share/man/man1/
|
||||||
|
sudo cp $tempdir/exa/completions/exa.zsh /usr/local/share/zsh/site-functions
|
||||||
|
rm $tempdir/exa -r
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
configure_zsh() {
|
||||||
|
read -p "要配置 zsh 吗?[Y/n]: " response
|
||||||
|
|
||||||
|
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||||
|
sudo apt install zsh -y
|
||||||
|
git_clone ohmyzsh/ohmyzsh ~/.oh-my-zsh
|
||||||
|
RUNZSH=no ZSH=~/.oh-my-zsh $scriptdir/files/install-ohmyzsh.sh
|
||||||
|
|
||||||
|
git_clone zsh-users/zsh-autosuggestions ~/.oh-my-zsh/plugins/zsh-autosuggestions
|
||||||
|
git_clone zsh-users/zsh-syntax-highlighting ~/.oh-my-zsh/plugins/zsh-syntax-highlighting
|
||||||
|
git_clone paulirish/git-open ~/.oh-my-zsh/plugins/git-open
|
||||||
|
sudo apt install autojump -y
|
||||||
|
|
||||||
|
cp $scriptdir/files/.zshrc ~/.zshrc
|
||||||
|
cp $scriptdir/files/ys-simple.zsh-theme ~/.oh-my-zsh/themes/ys-simple.zsh-theme
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
configure_tmux() {
|
||||||
|
read -p "要配置 tmux 吗?[Y/n]: " response
|
||||||
|
|
||||||
|
if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then
|
||||||
|
sudo apt install tmux -y
|
||||||
|
git_clone tmux-plugins/tpm ~/.tmux/plugins/tpm
|
||||||
|
git_clone tmux-plugins/tmux-sensible ~/.tmux/plugins/tmux-sensible
|
||||||
|
git_clone tmux-plugins/tmux-yank ~/.tmux/plugins/tmux-yank
|
||||||
|
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 同步
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $EUID -eq 0 ]]; then
|
||||||
|
echo "This script should not be run as root."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
check_google_access
|
||||||
|
configure_ssh
|
||||||
|
configure_ssh_keygen
|
||||||
|
configure_nano
|
||||||
|
configure_apt_upgrade
|
||||||
|
configure_apt_install
|
||||||
|
configure_zsh
|
||||||
|
configure_tmux
|
||||||
Loading…
Reference in New Issue
Block a user