53 lines
1.1 KiB
Bash
Executable File
53 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
git_clone() {
|
|
local repo=$1
|
|
local dir=$2
|
|
|
|
if [ ! -d "$dir" ]; then
|
|
if [ "$3" = "--depth=1" ]; then
|
|
git clone --depth=1 "$github/$repo" $dir
|
|
elif [ "$3" = "--norecursive" ]; then
|
|
git clone --single-branch "$github/$repo" $dir
|
|
else
|
|
git clone --single-branch --recursive "$github/$repo" $dir
|
|
fi
|
|
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
|
|
}
|
|
|
|
confirm_action() {
|
|
local prompt="$1"
|
|
local default_response="$2"
|
|
|
|
read -p "$prompt [$default_response]: " response
|
|
|
|
if [[ -z "$response" ]]; then
|
|
response="$default_response"
|
|
fi
|
|
|
|
[[ $response =~ ^[Yy]$ ]]
|
|
}
|
|
|
|
command_exists() {
|
|
command -v "$@" >/dev/null 2>&1;
|
|
}
|
|
|
|
# ============================================================
|
|
|
|
check_google_access
|