This commit is contained in:
Konano 2023-07-16 01:00:54 +08:00
parent bd2059fbc8
commit c51791344a

View File

@ -1,7 +1,38 @@
#!/bin/bash #!/bin/bash
scriptdir=$(dirname $(realpath $0)) 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 mkdir -p ~/.ssh
cat $scriptdir/files/authorized_keys >> ~/.ssh/authorized_keys 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))