Files
Warren 55bca92691 V1.0: Class 1 fax — real-world 4-page send to external number confirmed
Core features:
- Class 1 T.30 protocol: full send/receive implementation
- HDLC: DLE-stuffing, FCS strip, USR5637 bit-reversal handling
- T.4 MH encoder/decoder (1728px A4 standard)
- Document pipeline: PDF (Ghostscript), PNG, TIFF input
- Width clamping: US Letter 1734px → 1728px fax standard
- Cover page: CJK rasterization (TW/CN/JP/EN), TIFF + HTML output
- OCR verification: Tesseract 5 with eng+chi_tra, CJK space-tolerant
- API server (axum): health, send, jobs, cover, retry, cancel
- Background worker: auto-poll queue, speed fallback, retry policy
- Modem detection, pool management

Real-world test results (2026-07-23):
- V90 → 25153038: 4 pages, V.17 12000 bps, 2:33 ✅
- USR5637 → 25153038: 4 pages, V.17 12000 bps, 2:26 ✅
- Both faxes confirmed received on remote machine

Tested: loopback (100% pixel match), multi-page, all input formats,
cover pages, OCR verify, API endpoints, worker processing.
13 unit tests pass, 0 new clippy warnings.
2026-07-24 18:47:15 +08:00

103 lines
2.8 KiB
Bash
Executable File

#!/bin/bash
# Telfax Enterprise Fax Server Installation Script for macOS
#
# Usage: sudo ./install-macos.sh
set -e
INSTALL_DIR="/usr/local"
BIN_DIR="$INSTALL_DIR/bin"
CONFIG_DIR="$INSTALL_DIR/etc/telfax"
DATA_DIR="$INSTALL_DIR/var/lib/telfax"
LOG_DIR="$INSTALL_DIR/var/log/telfax"
PLIST_NAME="com.telfax.server.plist"
PLIST_DEST="/Library/LaunchDaemons/$PLIST_NAME"
echo "=== Telfax Enterprise Fax Server Installation (macOS) ==="
echo ""
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "Error: Please run as root (sudo ./install-macos.sh)"
exit 1
fi
# Create directories
echo "Creating directories..."
mkdir -p "$BIN_DIR"
mkdir -p "$CONFIG_DIR"
mkdir -p "$DATA_DIR"
mkdir -p "$LOG_DIR"
# Build the binary if needed
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
if [ ! -f "$PROJECT_DIR/target/release/telfax" ]; then
echo "Building telfax (release mode)..."
cd "$PROJECT_DIR"
cargo build --release
fi
# Install binary
echo "Installing binary..."
cp "$PROJECT_DIR/target/release/telfax" "$BIN_DIR/"
chmod +x "$BIN_DIR/telfax"
# Install configuration
if [ ! -f "$CONFIG_DIR/config.toml" ]; then
echo "Installing production configuration..."
cp "$PROJECT_DIR/deployment/config.production.toml" "$CONFIG_DIR/config.toml"
echo ""
echo "⚠️ IMPORTANT: Edit $CONFIG_DIR/config.toml"
echo " - Change all authentication tokens"
echo " - Verify modem device paths"
echo " - Set your station_id and header"
echo ""
else
echo "Configuration file already exists, skipping..."
fi
# Install launchd plist
echo "Installing launchd service..."
cp "$PROJECT_DIR/deployment/$PLIST_NAME" "$PLIST_DEST"
chmod 644 "$PLIST_DEST"
# Set permissions
echo "Setting permissions..."
chown -R root:wheel "$CONFIG_DIR"
chown -R root:wheel "$DATA_DIR"
chown -R root:wheel "$LOG_DIR"
chmod 600 "$CONFIG_DIR/config.toml"
echo ""
echo "=== Installation Complete ==="
echo ""
echo "Binary: $BIN_DIR/telfax"
echo "Configuration: $CONFIG_DIR/config.toml"
echo "Data directory: $DATA_DIR"
echo "Log directory: $LOG_DIR"
echo "Service plist: $PLIST_DEST"
echo ""
echo "Next steps:"
echo " 1. Edit $CONFIG_DIR/config.toml and configure:"
echo " - Authentication tokens (IMPORTANT!)"
echo " - Modem device paths"
echo " - Station ID and header"
echo ""
echo " 2. Load and start the service:"
echo " sudo launchctl load -w $PLIST_DEST"
echo ""
echo " 3. Check service status:"
echo " sudo launchctl list | grep telfax"
echo ""
echo " 4. View logs:"
echo " tail -f $LOG_DIR/telfax.log"
echo " tail -f $LOG_DIR/telfax-error.log"
echo ""
echo " 5. Test API:"
echo " curl -H 'Authorization: Bearer YOUR_TOKEN' http://localhost:3000/api/v1/status"
echo ""
echo "To stop the service:"
echo " sudo launchctl unload $PLIST_DEST"
echo ""