






















@@ -1127,23 +1127,50 @@ set -euo pipefail
11271127root=${REMOTE_ROOT}
11281128tdlib_sha256=${tdlibSha256}
11291129tdlib_url=${tdlibUrl}
1130+setup_step_timeout_kill_after="\${OPENCLAW_TELEGRAM_USER_SETUP_KILL_AFTER_SECONDS:-30}s"
1131+apt_timeout="\${OPENCLAW_TELEGRAM_USER_APT_TIMEOUT_SECONDS:-900}s"
1132+download_timeout="\${OPENCLAW_TELEGRAM_USER_DOWNLOAD_TIMEOUT_SECONDS:-600}"
1133+download_connect_timeout="\${OPENCLAW_TELEGRAM_USER_DOWNLOAD_CONNECT_TIMEOUT_SECONDS:-15}"
1134+download_retries="\${OPENCLAW_TELEGRAM_USER_DOWNLOAD_RETRIES:-3}"
1135+download_retry_delay="\${OPENCLAW_TELEGRAM_USER_DOWNLOAD_RETRY_DELAY_SECONDS:-5}"
1136+tdlib_clone_timeout="\${OPENCLAW_TELEGRAM_USER_TDLIB_CLONE_TIMEOUT_SECONDS:-600}s"
1137+tdlib_build_timeout="\${OPENCLAW_TELEGRAM_USER_TDLIB_BUILD_TIMEOUT_SECONDS:-1800}s"
1138+run_setup_step() {
1139+ local label="$1"
1140+ local timeout_value="$2"
1141+ shift 2
1142+ echo "==> $label" >&2
1143+ timeout --kill-after="$setup_step_timeout_kill_after" "$timeout_value" "$@"
1144+}
1145+download_file() {
1146+ local url="$1"
1147+ local output="$2"
1148+ curl -fL \
1149+ --connect-timeout "$download_connect_timeout" \
1150+ --max-time "$download_timeout" \
1151+ --retry "$download_retries" \
1152+ --retry-delay "$download_retry_delay" \
1153+ --retry-all-errors \
1154+ -o "$output" \
1155+ "$url"
1156+}
11301157mkdir -p "$root"
11311158tar -xzf "$root/state.tgz" -C "$root"
1132-sudo apt-get update -y
1133-sudo DEBIAN_FRONTEND=noninteractive apt-get install -y curl git cmake g++ make zlib1g-dev libssl-dev python3 ffmpeg scrot xz-utils tar wmctrl xdotool x11-utils zbar-tools libopengl0 libxcb-cursor0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-shape0 libxcb-xfixes0 libxcb-xinerama0 libxkbcommon-x11-0 >/tmp/openclaw-telegram-apt.log
1159+run_setup_step "apt-get update" "$apt_timeout" sudo apt-get update -y
1160+run_setup_step "apt-get install" "$apt_timeout" sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y curl git cmake g++ make zlib1g-dev libssl-dev python3 ffmpeg scrot xz-utils tar wmctrl xdotool x11-utils zbar-tools libopengl0 libxcb-cursor0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-shape0 libxcb-xfixes0 libxcb-xinerama0 libxkbcommon-x11-0 >/tmp/openclaw-telegram-apt.log
11341161if ! command -v python3 >/dev/null 2>&1; then
11351162 echo "python3 is required" >&2
11361163 exit 127
11371164fi
11381165if [ ! -x "$root/Telegram/Telegram" ]; then
1139- curl -fL https://telegram.org/dl/desktop/linux -o "$root/telegram.tar.xz"
1166+ download_file https://telegram.org/dl/desktop/linux "$root/telegram.tar.xz"
11401167 tar -xJf "$root/telegram.tar.xz" -C "$root"
11411168fi
11421169if ! ldconfig -p | grep -q libtdjson.so; then
11431170 if [ -n "$tdlib_url" ]; then
1144- curl -fL "$tdlib_url" -o "$root/tdlib-linux.tgz"
1171+ download_file "$tdlib_url" "$root/tdlib-linux.tgz"
11451172 if [ -z "$tdlib_sha256" ]; then
1146- curl -fL "$tdlib_url.sha256" -o "$root/tdlib-linux.tgz.sha256"
1173+ download_file "$tdlib_url.sha256" "$root/tdlib-linux.tgz.sha256"
11471174 tdlib_sha256="$(awk '{print $1; exit}' "$root/tdlib-linux.tgz.sha256")"
11481175 fi
11491176 printf '%s %s\\n' "$tdlib_sha256" "$root/tdlib-linux.tgz" | sha256sum -c -
@@ -1154,10 +1181,10 @@ if ! ldconfig -p | grep -q libtdjson.so; then
11541181 sudo install -m 0755 "$lib" /usr/local/lib/libtdjson.so
11551182 else
11561183 rm -rf "$root/td" "$root/td-build"
1157- git clone --depth 1 --branch v1.8.0 https://github.com/tdlib/td.git "$root/td"
1158- cmake -S "$root/td" -B "$root/td-build" -DCMAKE_BUILD_TYPE=Release -DTD_ENABLE_JNI=OFF
1159- cmake --build "$root/td-build" --target tdjson -j "$(nproc)"
1160- sudo cmake --install "$root/td-build"
1184+ run_setup_step "tdlib clone" "$tdlib_clone_timeout" git clone --depth 1 --branch v1.8.0 https://github.com/tdlib/td.git "$root/td"
1185+ run_setup_step "tdlib configure" "$tdlib_build_timeout" cmake -S "$root/td" -B "$root/td-build" -DCMAKE_BUILD_TYPE=Release -DTD_ENABLE_JNI=OFF
1186+ run_setup_step "tdlib build" "$tdlib_build_timeout" cmake --build "$root/td-build" --target tdjson -j "$(nproc)"
1187+ run_setup_step "tdlib install" "$apt_timeout" sudo cmake --install "$root/td-build"
11611188 fi
11621189 sudo ldconfig
11631190fi
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。