#!/bin/bash scriptdir=$(dirname $(realpath $0)) tempdir="/tmp" 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 echo "Internet: abroad" abroad=1 github="https://github.com" else echo "Internet: internal" abroad=0 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 [[ -z "$response" ]] || [[ $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 apt install nano -y cp $scriptdir/files/nanorc ~/.nanorc fi } configure_install_bin() { apt update apt upgrade -y apt autoremove -y apt install tmux git curl htop net-tools tcptraceroute ifupdown tar unzip -y 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 } configure_zsh() { read -p "要配置 zsh 吗?[Y/n]: " response if [[ -z "$response" ]] || [[ $response =~ ^[Yy]$ ]]; then apt install zsh -y # touch -p ~/.ssh # read -p "sshkey 的名字: " sshkeyname # ssh-keygen -t ed25519 -C $sshkeyname fi } check_google_access configure_ssh configure_ssh_keygen configure_nano configure_install_bin configure_zsh