46 lines
1.0 KiB
Bash
Executable File
46 lines
1.0 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
|
|
}
|
|
|
|
update_file() {
|
|
local A="$1"
|
|
local B="$2"
|
|
|
|
if [ -f "$A" ] && [ -f "$B" ] && [ "$(cat "$A")" != "$(cat "$B")" ]; then
|
|
cp "$A" "$B"
|
|
echo "File $B has been updated."
|
|
fi
|
|
}
|
|
|
|
# ============================================================
|
|
|
|
check_google_access
|