Tutorial

Novas atualizações e melhorias para a Macfleet.

Aviso importante

Os exemplos de código e scripts fornecidos nestes tutoriais são apenas para fins educacionais. A Macfleet não é responsável por quaisquer problemas, danos ou vulnerabilidades de segurança que possam surgir do uso, modificação ou implementação destes exemplos. Sempre revise e teste o código em um ambiente seguro antes de usá-lo em sistemas de produção.

Font Management on macOS

Manage and deploy fonts across your MacFleet devices using advanced command-line tools and centralized distribution methods. This tutorial covers font installation, typography standardization, license compliance, and enterprise-grade font management with comprehensive monitoring and reporting capabilities.

Understanding macOS Font Management

macOS provides several locations and methods for font management:

  • ~/Library/Fonts/ - User-specific fonts (current user only)
  • /Library/Fonts/ - System-wide fonts (all users)
  • /Library/User Template/Non_localized/Library/Fonts/ - Template for new users
  • Font Book - macOS native font management application
  • Font formats: TTF (TrueType), OTF (OpenType), WOFF, and legacy formats

Enterprise font management requires careful consideration of licensing, standardization, and deployment strategies.

Basic Font Installation Commands

Install Font for Current User

#!/bin/bash

# Install font for the current user only
install_user_font() {
    local font_path="$1"
    local font_name="$2"
    
    if [[ -z "$font_path" || -z "$font_name" ]]; then
        echo "Usage: install_user_font <source_path> <font_name>"
        return 1
    fi
    
    # Copy font to user's font directory
    cp -R "$font_path/$font_name" ~/Library/Fonts/
    
    if [[ $? -eq 0 ]]; then
        echo "✅ Font '$font_name' installed for current user"
        return 0
    else
        echo "❌ Failed to install font '$font_name'"
        return 1
    fi
}

# Example usage
# install_user_font "/Users/user1/Downloads" "CROCHETPATTERN.ttf"

Install Font System-Wide

#!/bin/bash

# Install font for all users (requires admin privileges)
install_system_font() {
    local font_path="$1"
    local font_name="$2"
    
    if [[ -z "$font_path" || -z "$font_name" ]]; then
        echo "Usage: install_system_font <source_path> <font_name>"
        return 1
    fi
    
    # Verify admin privileges
    if [[ $EUID -ne 0 ]]; then
        echo "❌ Admin privileges required for system-wide font installation"
        return 1
    fi
    
    # Copy font to system font directory
    cp -R "$font_path/$font_name" /Library/Fonts/
    
    if [[ $? -eq 0 ]]; then
        echo "✅ Font '$font_name' installed system-wide"
        
        # Clear font cache to ensure immediate availability
        atsutil databases -remove
        atsutil server -shutdown
        atsutil server -ping
        
        return 0
    else
        echo "❌ Failed to install font '$font_name' system-wide"
        return 1
    fi
}

# Example usage (run with sudo)
# install_system_font "/Users/user1/Downloads" "CROCHETPATTERN.ttf"

Install Font for New User Template

#!/bin/bash

# Install font in user template (affects new users only)
install_template_font() {
    local font_path="$1"
    local font_name="$2"
    
    if [[ -z "$font_path" || -z "$font_name" ]]; then
        echo "Usage: install_template_font <source_path> <font_name>"
        return 1
    fi
    
    # Verify admin privileges
    if [[ $EUID -ne 0 ]]; then
        echo "❌ Admin privileges required for user template modification"
        return 1
    fi
    
    # Create template font directory if it doesn't exist
    mkdir -p "/Library/User Template/Non_localized/Library/Fonts"
    
    # Copy font to user template
    cp -R "$font_path/$font_name" "/Library/User Template/Non_localized/Library/Fonts/"
    
    if [[ $? -eq 0 ]]; then
        echo "✅ Font '$font_name' added to user template"
        return 0
    else
        echo "❌ Failed to add font '$font_name' to user template"
        return 1
    fi
}

# Example usage (run with sudo)
# install_template_font "/Users/user1/Downloads" "CROCHETPATTERN.ttf"

Advanced Font Management

Font Validation and Information

#!/bin/bash

# Validate and extract font information
validate_font() {
    local font_file="$1"
    
    if [[ ! -f "$font_file" ]]; then
        echo "❌ Font file not found: $font_file"
        return 1
    fi
    
    echo "=== Font Validation Report ==="
    echo "Font File: $font_file"
    echo "File Size: $(ls -lh "$font_file" | awk '{print $5}')"
    echo "File Type: $(file "$font_file")"
    echo ""
    
    # Check if it's a valid font file
    local file_type
    file_type=$(file -b "$font_file")
    
    if echo "$file_type" | grep -qi "font\|truetype\|opentype"; then
        echo "✅ Valid font file detected"
        
        # Extract font information using fc-query if available
        if command -v fc-query >/dev/null 2>&1; then
            echo ""
            echo "Font Details:"
            fc-query "$font_file" | grep -E "(family|style|weight|slant)" | head -10
        fi
        
        # Check for potential issues
        local file_size
        file_size=$(stat -f%z "$font_file" 2>/dev/null || stat -c%s "$font_file" 2>/dev/null)
        
        if [[ "$file_size" -gt 10485760 ]]; then  # 10MB
            echo "⚠️  Warning: Large font file (>10MB) - may impact system performance"
        fi
        
        if [[ "$file_size" -lt 1024 ]]; then  # 1KB
            echo "⚠️  Warning: Very small font file (<1KB) - may be corrupted"
        fi
        
        return 0
    else
        echo "❌ Invalid font file format"
        return 1
    fi
}

# Example usage
# validate_font "/Users/user1/Downloads/CROCHETPATTERN.ttf"

Font Discovery and Inventory

#!/bin/bash

# Discover and inventory installed fonts
discover_fonts() {
    echo "=== Font Inventory Report ==="
    echo "Generated: $(date)"
    echo "Hostname: $(hostname)"
    echo "=============================="
    echo ""
    
    # System fonts
    echo "1. SYSTEM FONTS (/Library/Fonts/):"
    echo "-----------------------------------"
    if [[ -d "/Library/Fonts" ]]; then
        local sys_count
        sys_count=$(ls -1 /Library/Fonts/ 2>/dev/null | wc -l | tr -d ' ')
        echo "Total system fonts: $sys_count"
        echo ""
        ls -la /Library/Fonts/ | head -10
        if [[ "$sys_count" -gt 10 ]]; then
            echo "... and $((sys_count - 10)) more fonts"
        fi
    else
        echo "System fonts directory not found"
    fi
    echo ""
    
    # User fonts (current user)
    echo "2. USER FONTS (~/Library/Fonts/):"
    echo "---------------------------------"
    if [[ -d "$HOME/Library/Fonts" ]]; then
        local user_count
        user_count=$(ls -1 ~/Library/Fonts/ 2>/dev/null | wc -l | tr -d ' ')
        echo "Total user fonts: $user_count"
        echo ""
        if [[ "$user_count" -gt 0 ]]; then
            ls -la ~/Library/Fonts/ | head -10
            if [[ "$user_count" -gt 10 ]]; then
                echo "... and $((user_count - 10)) more fonts"
            fi
        else
            echo "No user-specific fonts installed"
        fi
    else
        echo "User fonts directory not found"
    fi
    echo ""
    
    # Font formats analysis
    echo "3. FONT FORMAT ANALYSIS:"
    echo "------------------------"
    local ttf_count otf_count other_count
    ttf_count=$(find /Library/Fonts ~/Library/Fonts -name "*.ttf" 2>/dev/null | wc -l | tr -d ' ')
    otf_count=$(find /Library/Fonts ~/Library/Fonts -name "*.otf" 2>/dev/null | wc -l | tr -d ' ')
    other_count=$(find /Library/Fonts ~/Library/Fonts -type f ! -name "*.ttf" ! -name "*.otf" 2>/dev/null | wc -l | tr -d ' ')
    
    echo "TrueType fonts (.ttf): $ttf_count"
    echo "OpenType fonts (.otf): $otf_count"
    echo "Other formats: $other_count"
}

# Execute font discovery
discover_fonts

Enterprise Font Management System

#!/bin/bash

# MacFleet Enterprise Font Management System
# Comprehensive font deployment, management, and compliance monitoring

# Configuration
LOG_FILE="/var/log/macfleet_font_management.log"
FONT_REPO_DIR="/var/lib/macfleet/fonts"
CONFIG_FILE="/etc/macfleet/font_config.conf"
BACKUP_DIR="/var/backups/macfleet/fonts"
STAGING_DIR="/tmp/macfleet_fonts"

# Create directory structure
setup_directories() {
    mkdir -p "$(dirname "$LOG_FILE")" "$FONT_REPO_DIR" "$BACKUP_DIR" "$STAGING_DIR" "$(dirname "$CONFIG_FILE")"
    touch "$LOG_FILE"
    
    # Set appropriate permissions
    chmod 755 "$FONT_REPO_DIR" "$BACKUP_DIR" "$STAGING_DIR"
}

# Logging function
log_action() {
    echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOG_FILE"
}

# Download and validate font from URL
download_font() {
    local font_url="$1"
    local font_name="$2"
    local license_info="$3"
    
    if [[ -z "$font_url" || -z "$font_name" ]]; then
        log_action "ERROR: Font URL and name required"
        return 1
    fi
    
    log_action "Downloading font: $font_name from $font_url"
    
    # Download to staging directory
    local download_path="$STAGING_DIR/$font_name"
    
    if command -v curl >/dev/null 2>&1; then
        curl -L -o "$download_path" "$font_url"
    elif command -v wget >/dev/null 2>&1; then
        wget -O "$download_path" "$font_url"
    else
        log_action "ERROR: No download tool available (curl or wget required)"
        return 1
    fi
    
    if [[ ! -f "$download_path" ]]; then
        log_action "ERROR: Download failed for $font_name"
        return 1
    fi
    
    # Validate downloaded font
    if validate_font "$download_path" >/dev/null; then
        # Move to font repository
        mv "$download_path" "$FONT_REPO_DIR/"
        
        # Create metadata file
        cat > "$FONT_REPO_DIR/${font_name}.meta" <<EOF
{
    "font_name": "$font_name",
    "download_url": "$font_url",
    "download_date": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
    "license_info": "$license_info",
    "file_size": $(stat -f%z "$FONT_REPO_DIR/$font_name" 2>/dev/null || stat -c%s "$FONT_REPO_DIR/$font_name"),
    "checksum": "$(md5 -q "$FONT_REPO_DIR/$font_name" 2>/dev/null || md5sum "$FONT_REPO_DIR/$font_name" | cut -d' ' -f1)"
}
EOF
        
        log_action "✅ Font downloaded and validated: $font_name"
        return 0
    else
        log_action "❌ Font validation failed: $font_name"
        rm -f "$download_path"
        return 1
    fi
}

# Deploy font across fleet with options
deploy_font() {
    local font_name="$1"
    local deployment_scope="${2:-system}"  # user, system, template
    local force_install="${3:-false}"
    
    if [[ ! -f "$FONT_REPO_DIR/$font_name" ]]; then
        log_action "ERROR: Font not found in repository: $font_name"
        return 1
    fi
    
    log_action "Deploying font: $font_name (scope: $deployment_scope)"
    
    # Create backup of existing fonts
    backup_fonts
    
    case "$deployment_scope" in
        "user")
            # Install for current user
            mkdir -p ~/Library/Fonts
            cp -R "$FONT_REPO_DIR/$font_name" ~/Library/Fonts/
            local result=$?
            ;;
        "system")
            # Install system-wide (requires admin)
            if [[ $EUID -ne 0 ]]; then
                log_action "ERROR: Admin privileges required for system deployment"
                return 1
            fi
            cp -R "$FONT_REPO_DIR/$font_name" /Library/Fonts/
            local result=$?
            ;;
        "template")
            # Install in user template
            if [[ $EUID -ne 0 ]]; then
                log_action "ERROR: Admin privileges required for template deployment"
                return 1
            fi
            mkdir -p "/Library/User Template/Non_localized/Library/Fonts"
            cp -R "$FONT_REPO_DIR/$font_name" "/Library/User Template/Non_localized/Library/Fonts/"
            local result=$?
            ;;
        *)
            log_action "ERROR: Invalid deployment scope: $deployment_scope"
            return 1
            ;;
    esac
    
    if [[ $result -eq 0 ]]; then
        # Clear font cache
        refresh_font_cache
        
        # Verify installation
        verify_font_installation "$font_name" "$deployment_scope"
        
        log_action "✅ Font deployed successfully: $font_name"
        return 0
    else
        log_action "❌ Font deployment failed: $font_name"
        return 1
    fi
}

# Refresh font cache
refresh_font_cache() {
    log_action "Refreshing system font cache..."
    
    # Clear macOS font cache
    atsutil databases -remove 2>/dev/null
    atsutil server -shutdown 2>/dev/null
    sleep 2
    atsutil server -ping 2>/dev/null
    
    # Clear user font cache if fontconfig is available
    if command -v fc-cache >/dev/null 2>&1; then
        fc-cache -f -v 2>/dev/null
    fi
    
    log_action "Font cache refreshed"
}

# Verify font installation
verify_font_installation() {
    local font_name="$1"
    local scope="$2"
    
    local installed=false
    
    case "$scope" in
        "user")
            if [[ -f "$HOME/Library/Fonts/$font_name" ]]; then
                installed=true
            fi
            ;;
        "system")
            if [[ -f "/Library/Fonts/$font_name" ]]; then
                installed=true
            fi
            ;;
        "template")
            if [[ -f "/Library/User Template/Non_localized/Library/Fonts/$font_name" ]]; then
                installed=true
            fi
            ;;
    esac
    
    if [[ "$installed" == "true" ]]; then
        log_action "✅ Font installation verified: $font_name ($scope)"
        return 0
    else
        log_action "❌ Font installation verification failed: $font_name ($scope)"
        return 1
    fi
}

# Backup existing fonts
backup_fonts() {
    local backup_timestamp="$(date +%Y%m%d_%H%M%S)"
    local backup_path="$BACKUP_DIR/fonts_backup_$backup_timestamp"
    
    log_action "Creating font backup: $backup_path"
    
    mkdir -p "$backup_path"
    
    # Backup system fonts
    if [[ -d "/Library/Fonts" ]]; then
        cp -R /Library/Fonts "$backup_path/system_fonts" 2>/dev/null
    fi
    
    # Backup user fonts
    if [[ -d "$HOME/Library/Fonts" ]]; then
        cp -R "$HOME/Library/Fonts" "$backup_path/user_fonts" 2>/dev/null
    fi
    
    # Create backup manifest
    {
        echo "Font Backup Manifest"
        echo "==================="
        echo "Backup Date: $(date)"
        echo "Hostname: $(hostname)"
        echo "User: $(whoami)"
        echo ""
        echo "System Fonts:"
        ls -la "$backup_path/system_fonts/" 2>/dev/null || echo "None"
        echo ""
        echo "User Fonts:"
        ls -la "$backup_path/user_fonts/" 2>/dev/null || echo "None"
    } > "$backup_path/manifest.txt"
    
    log_action "Font backup completed: $backup_path"
}

# Font compliance and licensing audit
audit_font_compliance() {
    local audit_file="$BACKUP_DIR/font_compliance_audit_$(date +%Y%m%d_%H%M%S).txt"
    
    log_action "Performing font compliance audit: $audit_file"
    
    {
        echo "MacFleet Font Compliance Audit"
        echo "==============================="
        echo "Generated: $(date)"
        echo "Hostname: $(hostname)"
        echo "Auditor: $(whoami)"
        echo ""
        
        echo "FONT REPOSITORY INVENTORY:"
        echo "-------------------------"
        if [[ -d "$FONT_REPO_DIR" ]]; then
            ls -la "$FONT_REPO_DIR" | grep -v "\.meta$"
            echo ""
            
            echo "FONT METADATA REVIEW:"
            echo "--------------------"
            for meta_file in "$FONT_REPO_DIR"/*.meta; do
                if [[ -f "$meta_file" ]]; then
                    echo "Font: $(basename "$meta_file" .meta)"
                    cat "$meta_file" | grep -E "(license_info|download_url)" || echo "No license info available"
                    echo ""
                fi
            done
        else
            echo "Font repository not found"
        fi
        
        echo "INSTALLED FONTS ANALYSIS:"
        echo "-------------------------"
        echo "System Fonts Location: /Library/Fonts/"
        ls -la /Library/Fonts/ | wc -l | awk '{print "Total system fonts: " $1-1}'
        echo ""
        
        echo "User Fonts Location: ~/Library/Fonts/"
        ls -la ~/Library/Fonts/ 2>/dev/null | wc -l | awk '{print "Total user fonts: " $1-1}' || echo "No user fonts directory"
        echo ""
        
        echo "COMPLIANCE RECOMMENDATIONS:"
        echo "--------------------------"
        echo "• Verify all fonts have proper licensing documentation"
        echo "• Remove any fonts without clear licensing terms"
        echo "• Document font usage for corporate compliance"
        echo "• Implement regular font audits"
        echo "• Maintain font deployment logs for tracking"
        
    } > "$audit_file"
    
    log_action "Font compliance audit completed: $audit_file"
    echo "$audit_file"
}

# Remove font
remove_font() {
    local font_name="$1"
    local scope="${2:-all}"  # user, system, template, all
    
    log_action "Removing font: $font_name (scope: $scope)"
    
    local removed=false
    
    case "$scope" in
        "user"|"all")
            if [[ -f "$HOME/Library/Fonts/$font_name" ]]; then
                rm -f "$HOME/Library/Fonts/$font_name"
                log_action "Removed user font: $font_name"
                removed=true
            fi
            ;;& # Continue to next case
        "system"|"all")
            if [[ -f "/Library/Fonts/$font_name" ]]; then
                if [[ $EUID -eq 0 ]]; then
                    rm -f "/Library/Fonts/$font_name"
                    log_action "Removed system font: $font_name"
                    removed=true
                else
                    log_action "WARNING: Admin privileges required to remove system font"
                fi
            fi
            ;;& # Continue to next case
        "template"|"all")
            if [[ -f "/Library/User Template/Non_localized/Library/Fonts/$font_name" ]]; then
                if [[ $EUID -eq 0 ]]; then
                    rm -f "/Library/User Template/Non_localized/Library/Fonts/$font_name"
                    log_action "Removed template font: $font_name"
                    removed=true
                else
                    log_action "WARNING: Admin privileges required to remove template font"
                fi
            fi
            ;;
    esac
    
    if [[ "$removed" == "true" ]]; then
        refresh_font_cache
        log_action "✅ Font removal completed: $font_name"
        return 0
    else
        log_action "❌ Font not found or removal failed: $font_name"
        return 1
    fi
}

# Generate font deployment report
generate_font_report() {
    local report_file="$BACKUP_DIR/font_deployment_report_$(date +%Y%m%d_%H%M%S).json"
    
    log_action "Generating font deployment report: $report_file"
    
    {
        echo "{"
        echo "  \"report_type\": \"font_deployment\","
        echo "  \"timestamp\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\","
        echo "  \"hostname\": \"$(hostname)\","
        echo "  \"system_info\": {"
        echo "    \"macos_version\": \"$(sw_vers -productVersion)\","
        echo "    \"user\": \"$(whoami)\""
        echo "  },"
        echo "  \"font_statistics\": {"
        
        # Count fonts
        local sys_fonts user_fonts repo_fonts
        sys_fonts=$(ls -1 /Library/Fonts/ 2>/dev/null | wc -l | tr -d ' ')
        user_fonts=$(ls -1 ~/Library/Fonts/ 2>/dev/null | wc -l | tr -d ' ')
        repo_fonts=$(ls -1 "$FONT_REPO_DIR"/*.ttf "$FONT_REPO_DIR"/*.otf 2>/dev/null | wc -l | tr -d ' ')
        
        echo "    \"system_fonts\": $sys_fonts,"
        echo "    \"user_fonts\": $user_fonts,"
        echo "    \"repository_fonts\": $repo_fonts"
        echo "  },"
        
        echo "  \"repository_fonts\": ["
        local first_font=true
        for font_file in "$FONT_REPO_DIR"/*.ttf "$FONT_REPO_DIR"/*.otf; do
            if [[ -f "$font_file" ]]; then
                if [[ "$first_font" == "false" ]]; then
                    echo ","
                fi
                first_font=false
                
                local font_name
                font_name=$(basename "$font_file")
                local file_size
                file_size=$(stat -f%z "$font_file" 2>/dev/null || stat -c%s "$font_file")
                
                echo "    {"
                echo "      \"name\": \"$font_name\","
                echo "      \"size\": $file_size,"
                echo "      \"path\": \"$font_file\""
                echo -n "    }"
            fi
        done
        echo ""
        echo "  ]"
        echo "}"
    } > "$report_file"
    
    log_action "Font deployment report generated: $report_file"
    echo "$report_file"
}

# Main management function
main() {
    local action="${1:-status}"
    local parameter1="$2"
    local parameter2="$3"
    local parameter3="$4"
    
    setup_directories
    log_action "MacFleet Font Management started with action: $action"
    
    case "$action" in
        "download")
            download_font "$parameter1" "$parameter2" "$parameter3"
            ;;
        "deploy")
            deploy_font "$parameter1" "$parameter2" "$parameter3"
            ;;
        "remove")
            remove_font "$parameter1" "$parameter2"
            ;;
        "validate")
            validate_font "$parameter1"
            ;;
        "discover")
            discover_fonts
            ;;
        "audit")
            audit_font_compliance
            ;;
        "backup")
            backup_fonts
            ;;
        "cache")
            refresh_font_cache
            ;;
        "report")
            generate_font_report
            ;;
        "status"|*)
            discover_fonts
            ;;
    esac
    
    log_action "MacFleet Font Management completed with action: $action"
}

# Execute main function with all arguments
main "$@"

Font Management Templates

Corporate Font Package Configuration

# /etc/macfleet/font_config.conf
# MacFleet Font Management Configuration

# Corporate font packages
CORPORATE_FONTS=(
    "Arial-Bold.ttf"
    "Helvetica-Light.otf"
    "TimesNewRoman.ttf"
    "Calibri-Regular.ttf"
    "CompanyLogo-Font.otf"
)

# Font repository settings
FONT_REPO_URL="https://fonts.company.com/repository"
AUTO_UPDATE_FONTS="true"
UPDATE_INTERVAL_HOURS="24"

# Deployment settings
DEFAULT_DEPLOYMENT_SCOPE="system"
REQUIRE_LICENSE_VALIDATION="true"
BACKUP_BEFORE_DEPLOYMENT="true"

# Compliance settings
FONT_AUDIT_ENABLED="true"
LICENSE_TRACKING="mandatory"
USAGE_ANALYTICS="enabled"

Font Deployment Script

#!/bin/bash

# Automated font deployment for corporate standards
deploy_corporate_fonts() {
    local font_package_url="$1"
    local deployment_scope="${2:-system}"
    
    echo "🎨 Deploying Corporate Font Package"
    echo "==================================="
    
    # Download font package
    local package_file="/tmp/corporate_fonts.zip"
    echo "Downloading font package..."
    
    if curl -L -o "$package_file" "$font_package_url"; then
        echo "✅ Package downloaded successfully"
    else
        echo "❌ Package download failed"
        return 1
    fi
    
    # Extract and validate fonts
    local extract_dir="/tmp/corporate_fonts"
    mkdir -p "$extract_dir"
    
    if command -v unzip >/dev/null 2>&1; then
        unzip -q "$package_file" -d "$extract_dir"
    else
        echo "❌ unzip command not available"
        return 1
    fi
    
    # Install each font
    local installed_count=0
    local failed_count=0
    
    for font_file in "$extract_dir"/*.ttf "$extract_dir"/*.otf; do
        if [[ -f "$font_file" ]]; then
            local font_name
            font_name=$(basename "$font_file")
            
            echo "Installing: $font_name"
            
            if validate_font "$font_file" >/dev/null 2>&1; then
                case "$deployment_scope" in
                    "system")
                        sudo cp "$font_file" /Library/Fonts/
                        ;;
                    "user")
                        cp "$font_file" ~/Library/Fonts/
                        ;;
                    "template")
                        sudo cp "$font_file" "/Library/User Template/Non_localized/Library/Fonts/"
                        ;;
                esac
                
                if [[ $? -eq 0 ]]; then
                    echo "  ✅ $font_name installed"
                    ((installed_count++))
                else
                    echo "  ❌ $font_name installation failed"
                    ((failed_count++))
                fi
            else
                echo "  ⚠️  $font_name validation failed - skipped"
                ((failed_count++))
            fi
        fi
    done
    
    # Cleanup
    rm -rf "$extract_dir" "$package_file"
    
    # Refresh font cache
    echo "Refreshing font cache..."
    refresh_font_cache
    
    echo ""
    echo "📊 Deployment Summary:"
    echo "  Successfully installed: $installed_count fonts"
    echo "  Failed installations: $failed_count fonts"
    echo "  Deployment scope: $deployment_scope"
    
    if [[ $failed_count -eq 0 ]]; then
        return 0
    else
        return 1
    fi
}

# Example usage
# deploy_corporate_fonts "https://fonts.company.com/corporate-package.zip" "system"

Security and Compliance Functions

Font License Validation

#!/bin/bash

# Validate font licenses and compliance
validate_font_licenses() {
    echo "🔍 Font License Validation"
    echo "=========================="
    echo ""
    
    local compliance_issues=()
    
    # Check repository fonts
    if [[ -d "$FONT_REPO_DIR" ]]; then
        echo "Repository Font License Status:"
        echo "------------------------------"
        
        for font_file in "$FONT_REPO_DIR"/*.ttf "$FONT_REPO_DIR"/*.otf; do
            if [[ -f "$font_file" ]]; then
                local font_name
                font_name=$(basename "$font_file")
                local meta_file="$FONT_REPO_DIR/${font_name}.meta"
                
                if [[ -f "$meta_file" ]]; then
                    local license_info
                    license_info=$(grep "license_info" "$meta_file" | cut -d'"' -f4)
                    
                    if [[ -n "$license_info" && "$license_info" != "null" ]]; then
                        echo "  ✅ $font_name: $license_info"
                    else
                        echo "  ⚠️  $font_name: No license information"
                        compliance_issues+=("$font_name: Missing license information")
                    fi
                else
                    echo "  ❌ $font_name: No metadata file"
                    compliance_issues+=("$font_name: Missing metadata")
                fi
            fi
        done
    fi
    
    echo ""
    
    # Check for commonly problematic fonts
    echo "Problematic Font Detection:"
    echo "--------------------------"
    
    local problematic_fonts=(
        "Arial.ttf"
        "TimesNewRoman.ttf"
        "Helvetica.otf"
        "Calibri.ttf"
    )
    
    for problem_font in "${problematic_fonts[@]}"; do
        if [[ -f "/Library/Fonts/$problem_font" ]] || [[ -f "~/Library/Fonts/$problem_font" ]]; then
            echo "  ⚠️  Found potentially licensed font: $problem_font"
            compliance_issues+=("$problem_font: Requires license verification")
        fi
    done
    
    echo ""
    
    # Generate compliance report
    if [[ ${#compliance_issues[@]} -eq 0 ]]; then
        echo "✅ Font license compliance check passed"
        return 0
    else
        echo "❌ Font license compliance issues found:"
        for issue in "${compliance_issues[@]}"; do
            echo "  - $issue"
        done
        return 1
    fi
}

validate_font_licenses

Font Usage Analytics

#!/bin/bash

# Generate font usage analytics
analyze_font_usage() {
    echo "📊 Font Usage Analytics"
    echo "======================"
    echo ""
    
    # Font count by format
    echo "Font Format Distribution:"
    echo "------------------------"
    local ttf_count otf_count woff_count other_count
    
    ttf_count=$(find /Library/Fonts ~/Library/Fonts -name "*.ttf" 2>/dev/null | wc -l | tr -d ' ')
    otf_count=$(find /Library/Fonts ~/Library/Fonts -name "*.otf" 2>/dev/null | wc -l | tr -d ' ')
    woff_count=$(find /Library/Fonts ~/Library/Fonts -name "*.woff*" 2>/dev/null | wc -l | tr -d ' ')
    other_count=$(find /Library/Fonts ~/Library/Fonts -type f ! -name "*.ttf" ! -name "*.otf" ! -name "*.woff*" 2>/dev/null | wc -l | tr -d ' ')
    
    echo "  TrueType (.ttf): $ttf_count"
    echo "  OpenType (.otf): $otf_count" 
    echo "  Web Fonts (.woff): $woff_count"
    echo "  Other formats: $other_count"
    echo ""
    
    # Font size analysis
    echo "Font Size Analysis:"
    echo "-------------------"
    local total_size large_fonts
    total_size=0
    large_fonts=0
    
    while IFS= read -r font_file; do
        if [[ -f "$font_file" ]]; then
            local size
            size=$(stat -f%z "$font_file" 2>/dev/null || stat -c%s "$font_file" 2>/dev/null || echo "0")
            total_size=$((total_size + size))
            
            if [[ "$size" -gt 1048576 ]]; then  # 1MB
                ((large_fonts++))
            fi
        fi
    done < <(find /Library/Fonts ~/Library/Fonts -type f 2>/dev/null)
    
    echo "  Total font storage: $(( total_size / 1024 / 1024 )) MB"
    echo "  Large fonts (>1MB): $large_fonts"
    echo ""
    
    # System impact assessment
    echo "System Impact Assessment:"
    echo "------------------------"
    local total_fonts
    total_fonts=$(find /Library/Fonts ~/Library/Fonts -type f 2>/dev/null | wc -l | tr -d ' ')
    
    if [[ "$total_fonts" -gt 200 ]]; then
        echo "  ⚠️  High font count ($total_fonts) - may impact system performance"
    elif [[ "$total_fonts" -gt 100 ]]; then
        echo "  ⚠️  Moderate font count ($total_fonts) - monitor performance"
    else
        echo "  ✅ Reasonable font count ($total_fonts)"
    fi
    
    if [[ "$total_size" -gt 104857600 ]]; then  # 100MB
        echo "  ⚠️  High font storage usage - consider cleanup"
    else
        echo "  ✅ Reasonable font storage usage"
    fi
}

analyze_font_usage

Important Technical Notes

Font Installation Locations

  • /Library/Fonts/: System-wide fonts (all users, requires admin)
  • ~/Library/Fonts/: User-specific fonts (current user only)
  • /Library/User Template/Non_localized/Library/Fonts/: New user template

Font Formats Supported

  • TTF (TrueType): Standard format, good compatibility
  • OTF (OpenType): Advanced format with better typography features
  • WOFF/WOFF2: Web fonts (limited desktop support)
  • Legacy formats: Type 1, bitmap fonts (deprecated)

Security Considerations

  1. Full Disk Access: Required for system-wide font installation
  2. Font Validation: Always validate fonts before installation
  3. License Compliance: Ensure proper licensing for commercial fonts
  4. Source Verification: Only install fonts from trusted sources

Best Practices

  1. Standardization: Maintain consistent font libraries across fleet
  2. License Management: Track and validate all font licenses
  3. Performance Impact: Monitor system performance with large font libraries
  4. Version Control: Maintain font versions and update procedures
  5. Backup Strategy: Regular backups before font changes
  6. User Training: Educate users about proper font usage
  7. Compliance Auditing: Regular license and usage audits
  8. Fleet Deployment: Test font deployments on small groups first

Remember to validate all scripts on test devices before deploying across your MacFleet environment, and ensure compliance with font licensing agreements when implementing enterprise font management systems.

Tutorial

Novas atualizações e melhorias para a Macfleet.

Configurando um Runner do GitHub Actions em um Mac Mini (Apple Silicon)

Runner do GitHub Actions

GitHub Actions é uma plataforma poderosa de CI/CD que permite automatizar seus fluxos de trabalho de desenvolvimento de software. Embora o GitHub ofereça runners hospedados, runners auto-hospedados fornecem maior controle e personalização para sua configuração de CI/CD. Este tutorial o guia através da configuração e conexão de um runner auto-hospedado em um Mac mini para executar pipelines do macOS.

Pré-requisitos

Antes de começar, certifique-se de ter:

  • Um Mac mini (registre-se no Macfleet)
  • Um repositório GitHub com direitos de administrador
  • Um gerenciador de pacotes instalado (preferencialmente Homebrew)
  • Git instalado em seu sistema

Passo 1: Criar uma Conta de Usuário Dedicada

Primeiro, crie uma conta de usuário dedicada para o runner do GitHub Actions:

# Criar a conta de usuário 'gh-runner'
sudo dscl . -create /Users/gh-runner
sudo dscl . -create /Users/gh-runner UserShell /bin/bash
sudo dscl . -create /Users/gh-runner RealName "GitHub runner"
sudo dscl . -create /Users/gh-runner UniqueID "1001"
sudo dscl . -create /Users/gh-runner PrimaryGroupID 20
sudo dscl . -create /Users/gh-runner NFSHomeDirectory /Users/gh-runner

# Definir a senha para o usuário
sudo dscl . -passwd /Users/gh-runner sua_senha

# Adicionar 'gh-runner' ao grupo 'admin'
sudo dscl . -append /Groups/admin GroupMembership gh-runner

Mude para a nova conta de usuário:

su gh-runner

Passo 2: Instalar Software Necessário

Instale Git e Rosetta 2 (se estiver usando Apple Silicon):

# Instalar Git se ainda não estiver instalado
brew install git

# Instalar Rosetta 2 para Macs Apple Silicon
softwareupdate --install-rosetta

Passo 3: Configurar o Runner do GitHub Actions

  1. Vá para seu repositório GitHub
  2. Navegue para Configurações > Actions > Runners

Runner do GitHub Actions

  1. Clique em "New self-hosted runner" (https://github.com/<username>/<repository>/settings/actions/runners/new)
  2. Selecione macOS como imagem do runner e ARM64 como arquitetura
  3. Siga os comandos fornecidos para baixar e configurar o runner

Runner do GitHub Actions

Crie um arquivo .env no diretório _work do runner:

# arquivo _work/.env
ImageOS=macos15
XCODE_15_DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
  1. Execute o script run.sh em seu diretório do runner para completar a configuração.
  2. Verifique se o runner está ativo e ouvindo por trabalhos no terminal e verifique as configurações do repositório GitHub para a associação do runner e status Idle.

Runner do GitHub Actions

Passo 4: Configurar Sudoers (Opcional)

Se suas ações requerem privilégios de root, configure o arquivo sudoers:

sudo visudo

Adicione a seguinte linha:

gh-runner ALL=(ALL) NOPASSWD: ALL

Passo 5: Usar o Runner em Fluxos de Trabalho

Configure seu fluxo de trabalho do GitHub Actions para usar o runner auto-hospedado:

name: Fluxo de trabalho de exemplo

on:
  workflow_dispatch:

jobs:
  build:
    runs-on: [self-hosted, macOS, ARM64]
    steps:
      - name: Instalar NodeJS
        run: brew install node

O runner está autenticado em seu repositório e rotulado com self-hosted, macOS, e ARM64. Use-o em seus fluxos de trabalho especificando estes rótulos no campo runs-on:

runs-on: [self-hosted, macOS, ARM64]

Melhores Práticas

  • Mantenha seu software do runner atualizado
  • Monitore regularmente os logs do runner para problemas
  • Use rótulos específicos para diferentes tipos de runners
  • Implemente medidas de segurança adequadas
  • Considere usar múltiplos runners para balanceamento de carga

Solução de Problemas

Problemas comuns e soluções:

  1. Runner não conectando:

    • Verifique conectividade de rede
    • Verifique validade do token GitHub
    • Certifique-se de permissões adequadas
  2. Falhas de build:

    • Verifique instalação do Xcode
    • Verifique dependências necessárias
    • Revise logs do fluxo de trabalho
  3. Problemas de permissão:

    • Verifique permissões do usuário
    • Verifique configuração sudoers
    • Revise permissões do sistema de arquivos

Conclusão

Agora você tem um runner auto-hospedado do GitHub Actions configurado em seu Mac mini. Esta configuração fornece mais controle sobre seu ambiente CI/CD e permite executar fluxos de trabalho específicos do macOS de forma eficiente.

Lembre-se de manter regularmente seu runner e mantê-lo atualizado com os patches de segurança e versões de software mais recentes.

Aplicativo Nativo

Aplicativo nativo do Macfleet

Guia de Instalação do Macfleet

Macfleet é uma solução poderosa de gerenciamento de frota projetada especificamente para ambientes Mac Mini hospedados na nuvem. Como provedor de hospedagem na nuvem Mac Mini, você pode usar o Macfleet para monitorar, gerenciar e otimizar toda sua frota de instâncias Mac virtualizadas.

Este guia de instalação o conduzirá através da configuração do monitoramento do Macfleet em sistemas macOS, Windows e Linux para garantir supervisão abrangente de sua infraestrutura na nuvem.

🍎 macOS

  • Baixe o arquivo .dmg para Mac aqui
  • Clique duas vezes no arquivo .dmg baixado
  • Arraste o aplicativo Macfleet para a pasta Aplicativos
  • Ejete o arquivo .dmg
  • Abra Preferências do Sistema > Segurança e Privacidade
    • Aba Privacidade > Acessibilidade
    • Marque Macfleet para permitir monitoramento
  • Inicie o Macfleet a partir de Aplicativos
  • O rastreamento inicia automaticamente

🪟 Windows

  • Baixe o arquivo .exe para Windows aqui
  • Clique com o botão direito no arquivo .exe > "Executar como administrador"
  • Siga o assistente de instalação
  • Aceite os termos e condições
  • Permita no Windows Defender se solicitado
  • Conceda permissões de monitoramento de aplicativo
  • Inicie o Macfleet a partir do Menu Iniciar
  • O aplicativo começa o rastreamento automaticamente

🐧 Linux

  • Baixe o pacote .deb (Ubuntu/Debian) ou .rpm (CentOS/RHEL) aqui
  • Instale usando seu gerenciador de pacotes
    • Ubuntu/Debian: sudo dpkg -i Macfleet-linux.deb
    • CentOS/RHEL: sudo rpm -ivh Macfleet-linux.rpm
  • Permita permissões de acesso X11 se solicitado
  • Adicione o usuário aos grupos apropriados se necessário
  • Inicie o Macfleet a partir do menu Aplicativos
  • O aplicativo começa o rastreamento automaticamente

Nota: Após a instalação em todos os sistemas, faça login com suas credenciais do Macfleet para sincronizar dados com seu painel de controle.