lazy/init_root.sh
2023-07-16 01:00:54 +08:00

39 lines
843 B
Bash
Executable File

#!/bin/bash
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 "Intenet: abroad"
abroad=1
else
echo "Intenet: internal"
abroad=0
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
ssh-keygen -t ed25519 -C "ubuntu"
fi
}
check_google_access
configure_ssh
configure_ssh_keygen
# scriptdir=$(dirname $(realpath $0))