File size: 1,439 Bytes
af8fa93
 
 
 
 
 
fa7ea27
af8fa93
fa7ea27
 
 
 
 
 
 
 
 
 
 
 
 
af8fa93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fa7ea27
af8fa93
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
set -e

echo "📦 Installing tectonic..."

if ! command -v tectonic &> /dev/null; then
  URL="https://github.com/tectonic-typesetting/tectonic/releases/download/tectonic%400.15.0/tectonic-0.15.0-x86_64-unknown-linux-gnu.tar.gz"
  mkdir -p /tmp/tectonic
  if command -v curl >/dev/null 2>&1; then
    curl -L "$URL" -o /tmp/tectonic.tar.gz
  elif command -v wget >/dev/null 2>&1; then
    wget -O /tmp/tectonic.tar.gz "$URL"
  else
    if command -v apt-get >/dev/null 2>&1; then
      apt-get update && apt-get install -y wget
      wget -O /tmp/tectonic.tar.gz "$URL"
    else
      echo "❌ Neither curl nor wget available, and apt-get not present." >&2
      exit 1
    fi
  fi
  tar -xzf /tmp/tectonic.tar.gz -C /tmp/tectonic

  # 找到可执行文件路径
  TECTONIC_BIN=$(find /tmp/tectonic -type f -name tectonic | head -n 1)

  # 默认安装路径
  INSTALL_DIR="/usr/local/bin"
  if [ ! -w "$INSTALL_DIR" ]; then
    INSTALL_DIR="$HOME/.local/bin"
    mkdir -p "$INSTALL_DIR"
    echo "⚠️  No permission for /usr/local/bin, installing to $INSTALL_DIR"
  fi

  cp "$TECTONIC_BIN" "$INSTALL_DIR/tectonic"
  chmod +x "$INSTALL_DIR/tectonic"

  # 自动提示 PATH 设置
  if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
    echo "⚙️  You may need to add this to your PATH: $INSTALL_DIR"
  fi

  echo "✅ Tectonic installed successfully at $INSTALL_DIR/tectonic"
else
  echo "Tectonic already installed."
fi