WWW.YOUINFO.SITE
标签聚合 file

/tag/file

LinuxDo 最新话题 · 2026-06-11 20:48:22+08:00 · tech

脚本 #!/data/data/com.termux/files/usr/bin/bash set -euo pipefail readonly SCRIPT_NAME="$(basename "$0")" readonly MIMO_PACKAGE_NAME="@mimo-ai/cli" readonly MIMO_PACKAGE_VERSION="${MIMO_CODE_VERSION:-${MIMOCODE_VERSION:-latest}}" readonly PREFIX_DIR="${PREFIX:-/data/data/com.termux/files/usr}" readonly HOST_MIMO_PATH="$PREFIX_DIR/bin/mimo" readonly MIMO_CLI_PKG_DIR="$PREFIX_DIR/lib/node_modules/@mimo-ai/cli" readonly MIMO_ARCH_PKG_NAME="@mimo-ai/mimocode-linux-arm64" readonly MIMO_ARCH_PKG_DIR="$PREFIX_DIR/lib/node_modules/$MIMO_ARCH_PKG_NAME" readonly TMP_ROOT="$HOME/tmp" readonly BACKUP_DIR="$TMP_ROOT/mimocode-backups" readonly WRAPPER_MARKER="# mimocode-termux-glibc-wrapper" # Resolved by install_mimo_package() after locating the real glibc ELF. MIMO_BINARY_PATH="" MIMO_RESOLVED_VERSION="" readonly C_BOLD_BLUE="\033[1;34m" readonly C_BOLD_GREEN="\033[1;32m" readonly C_BOLD_YELLOW="\033[1;33m" readonly C_BOLD_RED="\033[1;31m" readonly C_RESET="\033[0m" info() { printf '%b[INFO]%b %s\n' "$C_BOLD_BLUE" "$C_RESET" "$*"; } success() { printf '%b[ OK ]%b %s\n' "$C_BOLD_GREEN" "$C_RESET" "$*"; } warn() { printf '%b[WARN]%b %s\n' "$C_BOLD_YELLOW" "$C_RESET" "$*" >&2; } die() { printf '%b[ERR ]%b %s\n' "$C_BOLD_RED" "$C_RESET" "$*" >&2; exit 1; } usage() { cat <<EOF Usage: bash $SCRIPT_NAME What it does (glibc-runner mode, no proot): 1. Installs glibc-repo, refreshes apt metadata, installs glibc-runner. 2. Installs nodejs-lts + npm in Termux (if missing). 3. npm installs ${MIMO_PACKAGE_NAME} globally, then force-installs the ${MIMO_ARCH_PKG_NAME} native linux-arm64 package. 4. Skips MiMoCode's postinstall script because Termux Node reports process.platform='android' and the upstream script looks for a non-existent @mimo-ai/mimocode-android-arm64 package. 5. Replaces \$PREFIX/bin/mimo with a grun wrapper that runs the glibc ELF directly on Termux. Environment overrides: MIMO_CODE_VERSION npm package version/tag, default: ${MIMO_PACKAGE_VERSION} examples: latest, preview, 0.1.0, v0.1.0 MIMOCODE_VERSION alias for MIMO_CODE_VERSION Notes: - Official MiMoCode install docs: https://github.com/XiaomiMiMo/MiMo-Code - glibc-runner injects glibc via LD_LIBRARY_PATH; kernel calls are native. EOF } command_exists() { command -v "$1" >/dev/null 2>&1; } # ELF magic = 7f 45 4c 46; e_machine at offset 18 = 0xb7 for EM_AARCH64. is_valid_aarch64_elf() { local f="$1" [ -f "$f" ] || return 1 local magic machine magic=$(od -An -tx1 -N4 "$f" 2>/dev/null | tr -d ' \n') [ "$magic" = "7f454c46" ] || return 1 machine=$(od -An -tx1 -j18 -N1 "$f" 2>/dev/null | tr -d ' \n') [ "$machine" = "b7" ] } find_arch_binary() { local candidate for candidate in \ "$MIMO_ARCH_PKG_DIR/bin/mimo" \ "$MIMO_CLI_PKG_DIR/bin/.mimocode"; do if is_valid_aarch64_elf "$candidate"; then MIMO_BINARY_PATH="$candidate" return 0 fi done while IFS= read -r candidate; do if is_valid_aarch64_elf "$candidate"; then MIMO_BINARY_PATH="$candidate" return 0 fi done < <(find "$MIMO_ARCH_PKG_DIR" "$MIMO_CLI_PKG_DIR" -type f -size +10M 2>/dev/null) return 1 } ensure_tmp_root() { mkdir -p "$TMP_ROOT" [ -w "$TMP_ROOT" ] || die "Temp directory is not writable: $TMP_ROOT" export TMPDIR="$TMP_ROOT" } require_termux() { [ -d "$PREFIX_DIR" ] || die "This script must run in Termux." command_exists pkg || die "pkg not found. This script must run in Termux." if [ -r /proc/1/status ] && grep -q 'TracerPid:.*[1-9]' /proc/1/status 2>/dev/null; then warn "Detected non-zero TracerPid on PID 1 -- looks like a proot session." warn "Run this script from a plain Termux shell, not from inside proot-distro." fi } ensure_termux_package() { local package_name="$1" if dpkg -s "$package_name" >/dev/null 2>&1; then success "Termux package already installed: $package_name" return 0 fi info "Installing Termux package: $package_name" pkg install -y "$package_name" success "Installed Termux package: $package_name" } ensure_glibc_runner() { ensure_termux_package "glibc-repo" if ! apt-cache show glibc-runner >/dev/null 2>&1; then info "Refreshing apt metadata so glibc-repo becomes visible" pkg update -y || apt-get update -y || true fi ensure_termux_package "glibc-runner" command_exists grun || die "grun not found after installing glibc-runner." } ensure_nodejs() { if command_exists node && command_exists npm; then success "Termux node present: $(node --version), npm $(npm --version)" return 0 fi if dpkg -s nodejs >/dev/null 2>&1; then success "nodejs already installed" else ensure_termux_package "nodejs-lts" fi command_exists node && command_exists npm || die "node/npm not found after installing nodejs." } resolve_mimo_version() { local requested="$MIMO_PACKAGE_VERSION" if [ "$requested" != "latest" ]; then requested="${requested#v}" fi local pkg_spec="$MIMO_PACKAGE_NAME" if [ "$requested" != "latest" ]; then pkg_spec="${MIMO_PACKAGE_NAME}@${requested}" fi info "Resolving version for ${pkg_spec}" local resolved resolved=$(npm view "$pkg_spec" version 2>/dev/null | tail -n1) \ || die "Failed to resolve version for ${pkg_spec} via npm view" [[ "$resolved" =~ ^[0-9]+\.[0-9]+ ]] \ || die "npm view returned a bogus version: '$resolved'" MIMO_RESOLVED_VERSION="$resolved" } backup_existing_launcher() { mkdir -p "$BACKUP_DIR" [ -e "$HOST_MIMO_PATH" ] || return 0 if grep -Fq "$WRAPPER_MARKER" "$HOST_MIMO_PATH" 2>/dev/null; then success "glibc-runner wrapper already in place" return 0 fi local backup_path="$BACKUP_DIR/mimo.host-backup.$(date +%Y%m%d_%H%M%S)" cp -P "$HOST_MIMO_PATH" "$backup_path" success "Backed up existing launcher to $backup_path" } install_mimo_package() { resolve_mimo_version local main_version="$MIMO_RESOLVED_VERSION" local pinned_main="${MIMO_PACKAGE_NAME}@${main_version}" local arch_spec="${MIMO_ARCH_PKG_NAME}@${main_version}" info "Installing ${pinned_main} without upstream optional platform packages" npm install -g --force --ignore-scripts --omit=optional "$pinned_main" info "Installing ${arch_spec} for Termux via glibc-runner" npm install -g --force --ignore-scripts --os=linux --cpu=arm64 "$arch_spec" find_arch_binary || die "No valid aarch64 ELF found under $MIMO_ARCH_PKG_DIR. \ The arch package may not have unpacked correctly; inspect with: \ ls -la $MIMO_ARCH_PKG_DIR" success "MiMoCode native binary: $MIMO_BINARY_PATH ($(stat -c %s "$MIMO_BINARY_PATH" 2>/dev/null || echo '?') bytes)" } install_host_wrapper() { local tmp_wrapper tmp_wrapper="$(mktemp "$TMP_ROOT/mimo-grun.XXXXXX")" cat >"$tmp_wrapper" <<EOF #!/data/data/com.termux/files/usr/bin/sh $WRAPPER_MARKER mkdir -p "\$HOME/tmp" 2>/dev/null || true export TMPDIR="\${TMPDIR:-\$HOME/tmp}" exec grun "$MIMO_BINARY_PATH" "\$@" EOF chmod 755 "$tmp_wrapper" rm -f "$HOST_MIMO_PATH" mv "$tmp_wrapper" "$HOST_MIMO_PATH" chmod 755 "$HOST_MIMO_PATH" success "Installed Termux launcher: $HOST_MIMO_PATH" } verify_install() { info "Verifying binary via grun" grun "$MIMO_BINARY_PATH" --version info "Verifying Termux launcher" "$HOST_MIMO_PATH" --version local path_mimo="" path_mimo="$(command -v mimo 2>/dev/null || true)" if [ -n "$path_mimo" ] && [ "$path_mimo" != "$HOST_MIMO_PATH" ]; then warn "Your PATH resolves 'mimo' to $path_mimo, not $HOST_MIMO_PATH." warn "Move $PREFIX_DIR/bin earlier in PATH or remove the older launcher." fi success "MiMoCode setup completed (glibc-runner mode)" } main() { if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then usage exit 0 fi ensure_tmp_root require_termux ensure_glibc_runner ensure_nodejs backup_existing_launcher install_mimo_package install_host_wrapper verify_install cat <<EOF Run MiMoCode with: mimo Configuration: mode: glibc-runner (no proot) binary: $MIMO_BINARY_PATH launcher: $HOST_MIMO_PATH temp: $TMP_ROOT If the official installer previously added ~/.mimocode/bin before $PREFIX_DIR/bin, that older launcher may shadow this Termux wrapper. Troubleshooting: - If npm cannot resolve a preview version, install with: MIMO_CODE_VERSION=preview bash $SCRIPT_NAME - If subprocess errors mention libc/ld.so, the binary is loading Termux bionic libs via inherited LD_LIBRARY_PATH. Check glibc-runner docs. EOF } main "$@" 1 个帖子 - 1 位参与者 阅读完整话题

LinuxDo 最新话题 · 2026-06-08 14:18:32+08:00 · tech

codex-profile.zip (5.3 KB) 分享一个自用的 Codex 多账号切换脚本。 主要用途是把不同账号的登录状态分别保存成 profile,方便在多个 Codex 账号之间快速切换,不用每次都重新登录。 基本思路是: ~/.codex-profiles/<profile-name>/auth.json 保存各个账号的登录文件,当前生效的账号仍然使用: ~/.codex/auth.json 切换时脚本会把对应 profile 的 auth.json 复制过去。 常用命令: ./codex-profile-v6.sh list ./codex-profile-v6.sh current ./codex-profile-v6.sh use fastgogo ./codex-profile-v6.sh login fastgogo 脚本只是本地账号 profile 管理,不涉及共享账号或绕过限制。有类似需求的可以参考。 codex resume --last 8 个帖子 - 4 位参与者 阅读完整话题

LinuxDo 最新话题 · 2026-06-05 16:17:05+08:00 · tech

drive.google.com 置身钉内 14.34.50.pdf Google Drive file. 7.5万字,花了大概2小时看完了。 感觉这篇文章之于互联网职场人,就像《上海交通大学生存手册》之于大学生。推特上有很多用AI写这篇文章的摘要的,但大多管中窥豹,还是建议慢慢看看。 涉及到的方面有很多:如何思考产品、做产品、做好产品;在公司中有哪些问题需要克服、哪些是系统的问题无法克服;以及大厂是怎么样的 ······ 3 个帖子 - 3 位参与者 阅读完整话题

LinuxDo 最新话题 · 2026-06-05 09:31:17+08:00 · tech

Google – 4 Jun 26 A new profile to help publishers and creators highlight their work on Search We’re introducing a new, dedicated space for creators, publishers and brands. [!quote]+ 我们将推出搜索档案,这是出版商和创作者在搜索上塑造自己形象的一种新方式。搜索档案是一个专用的、可共享的空间,用于突出跨平台的内容,帮助受众在搜索中找到有关来源的最新准确信息。 搜索档案为出版商和创作者提供了一个集中展示其最新文章、视频和社交帖子的地方。人们可以通过个人资料轻松关注信息来源,这样他们就更有可能在谷歌应用主屏幕上的 "发现 "中看到这些内容。在移动设备上,可以通过创作者或发布者的知识面板("搜索 "中有关著名人物、地点和事物的信息框)、点击 "发现 "中发布者或创作者的名称或通过直接 URL 访问 "搜索 "配置文件。 搜索档案最初将在美国推出。今后,我们将把搜索档案扩展到全球更多的出版商和创作者,并增加更多的功能,使档案更加有用。我们期待看到这些新的简介如何帮助出版商和创作者塑造他们的形象,并突出他们在搜索上的作品。 2 个帖子 - 2 位参与者 阅读完整话题