#!/bin/bash # Telfax Enterprise Fax Server Installation Script # # Usage: sudo ./install.sh set -e INSTALL_DIR="/opt/telfax" DATA_DIR="/var/lib/telfax" LOG_DIR="/var/log/telfax" CONFIG_FILE="$INSTALL_DIR/config.toml" echo "=== Telfax Enterprise Fax Server Installation ===" # Create user and group echo "Creating telfax user..." if ! id -u telfax &>/dev/null; then useradd -r -s /bin/false telfax fi # Create directories echo "Creating directories..." mkdir -p "$INSTALL_DIR/bin" mkdir -p "$DATA_DIR" mkdir -p "$LOG_DIR" # Build the binary echo "Building telfax..." cd "$(dirname "$0")/.." cargo build --release cp target/release/telfax "$INSTALL_DIR/bin/" # Copy default config if not exists if [ ! -f "$CONFIG_FILE" ]; then echo "Copying default configuration..." cp deployment/config.toml "$CONFIG_FILE" echo "IMPORTANT: Edit $CONFIG_FILE and set your authentication tokens!" fi # Install systemd service echo "Installing systemd service..." cp deployment/telfax.service /etc/systemd/system/ systemctl daemon-reload # Set permissions echo "Setting permissions..." chown -R telfax:telfax "$INSTALL_DIR" chown -R telfax:telfax "$DATA_DIR" chown -R telfax:telfax "$LOG_DIR" chmod 600 "$CONFIG_FILE" echo "" echo "=== Installation Complete ===" echo "" echo "Configuration file: $CONFIG_FILE" echo "Data directory: $DATA_DIR" echo "Log directory: $LOG_DIR" echo "" echo "Next steps:" echo " 1. Edit $CONFIG_FILE and configure your modems and auth tokens" echo " 2. systemctl enable telfax" echo " 3. systemctl start telfax" echo " 4. journalctl -u telfax -f # View logs" echo ""