serv00 | CT8无交互一键四协议安装脚本

This commit is contained in:
eooce
2024-08-19 18:38:44 +08:00
committed by GitHub
parent d2f9430d20
commit bc72466ea8
+36 -5
View File
@@ -278,17 +278,39 @@ generate_random_name() {
echo "$name"
}
download_with_fallback() {
local URL=$1
local NEW_FILENAME=$2
curl -L -sS --max-time 2 -o "$NEW_FILENAME" "$URL" &
CURL_PID=$!
CURL_START_SIZE=$(stat -c%s "$NEW_FILENAME" 2>/dev/null || echo 0)
sleep 1
CURL_CURRENT_SIZE=$(stat -c%s "$NEW_FILENAME" 2>/dev/null || echo 0)
if [ "$CURL_CURRENT_SIZE" -le "$CURL_START_SIZE" ]; then
kill $CURL_PID
wait $CURL_PID 2>/dev/null
wget -q -O "$NEW_FILENAME" "$URL"
echo -e "\e[1;32mDownloading $NEW_FILENAME with wget\e[0m"
else
wait $CURL_PID
echo -e "\e[1;32mDownloading $NEW_FILENAME with curl\e[0m"
fi
}
for entry in "${FILE_INFO[@]}"; do
URL=$(echo "$entry" | cut -d ' ' -f 1)
RANDOM_NAME=$(generate_random_name)
NEW_FILENAME="$DOWNLOAD_DIR/$RANDOM_NAME"
if [ -e "$NEW_FILENAME" ]; then
green "$NEW_FILENAME already exists, Skipping download"
echo -e "\e[1;32m$NEW_FILENAME already exists, Skipping download\e[0m"
else
wget -q -O "$NEW_FILENAME" "$URL"
green "Downloading $NEW_FILENAME"
download_with_fallback "$URL" "$NEW_FILENAME"
fi
chmod +x "$NEW_FILENAME"
FILE_MAP[$(echo "$entry" | cut -d ' ' -f 2)]="$NEW_FILENAME"
done
@@ -336,9 +358,18 @@ rm -f "$(basename ${FILE_MAP[npm]})" "$(basename ${FILE_MAP[web]})" "$(basename
get_ip() {
ip=$(curl -s --max-time 2 ipv4.ip.sb)
if [ -z "$ip" ]; then
ip=$( [[ "$HOSTNAME" =~ s[0-9]\.serv00\.com ]] && echo "${HOSTNAME/s/web}" || echo "$HOSTNAME" )
ip=$( [[ "$HOSTNAME" =~ s[0-9]\.serv00\.com ]] && echo "${HOSTNAME/s/web}" || echo "$HOSTNAME" )
else
accessible=false
response=$(ping -c 3 -W 3 www.baidu.com)
if echo "$response" | grep -q "time="; then
accessible=true
fi
if [ "$accessible" = false ]; then
ip=$( [[ "$HOSTNAME" =~ s[0-9]\.serv00\.com ]] && echo "${HOSTNAME/s/web}" || echo "$ip" )
fi
fi
echo $ip
echo "$ip"
}
get_argodomain() {