#!/bin/bash # Chrome configuration script for OSWorld # For ARM64 (Mac VM Fusion): Creates symlinks so snap Chromium works with evaluators # For x86_64: Installs Google Chrome PASSWORD="password" echo "=== Chrome Configuration Script ===" # Detect architecture ARCH=$(dpkg --print-architecture) echo "Architecture: $ARCH" if [ "$ARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then echo "" echo "=== ARM64 Detected (Mac VM Fusion) ===" SNAP_CONFIG="$HOME/snap/chromium/common/chromium" STANDARD_CONFIG="$HOME/.config/google-chrome" # Check if symlink already exists and points to correct location if [ -L "$STANDARD_CONFIG" ] && [ "$(readlink "$STANDARD_CONFIG")" = "$SNAP_CONFIG" ]; then echo "✓ Symlink already configured correctly" echo " $STANDARD_CONFIG -> $SNAP_CONFIG" # Verify Chromium works if /snap/bin/chromium --version 2>&1 | head -1; then echo "✓ Chromium is working" fi echo "" echo "=== No changes needed ===" echo "Everything is already correctly configured." else echo "Google Chrome is NOT available for ARM64 Linux." echo "Using snap Chromium with symlink workaround." echo "" # Create snap config directory if it doesn't exist (Chromium will populate it) mkdir -p "$SNAP_CONFIG/Default" # Remove existing standard config if it exists (might be a directory, not symlink) rm -rf "$STANDARD_CONFIG" 2>/dev/null || true # Create symlink: ~/.config/google-chrome -> ~/snap/chromium/common/chromium ln -sf "$SNAP_CONFIG" "$STANDARD_CONFIG" if [ -L "$STANDARD_CONFIG" ]; then echo "✓ Symlink created: $STANDARD_CONFIG -> $SNAP_CONFIG" else echo "✗ Failed to create symlink" exit 1 fi # Create symlink for google-chrome-stable command if it doesn't exist if [ ! -f /usr/bin/google-chrome-stable ]; then echo "$PASSWORD" | sudo -S ln -sf /snap/bin/chromium /usr/bin/google-chrome-stable 2>/dev/null || true echo "✓ Created symlink: /usr/bin/google-chrome-stable -> /snap/bin/chromium" fi # Verify Chromium works if /snap/bin/chromium --version 2>&1 | head -1; then echo "✓ Chromium is working" else echo "✗ Chromium not found or not working" fi echo "" echo "=== Configuration Complete ===" echo "Snap Chromium will be used." echo "Config location: $SNAP_CONFIG/Default/" echo "Symlinked to: $STANDARD_CONFIG/Default/" echo "" echo "Evaluators checking ~/.config/google-chrome/Default/ will find snap Chromium config." fi else echo "" echo "=== x86_64 Detected ===" # Check if Google Chrome is already installed and config exists if [ -f /usr/bin/google-chrome-stable ] && [ -d ~/.config/google-chrome/Default ]; then echo "✓ Google Chrome is already installed" echo "✓ Config directory exists: ~/.config/google-chrome/Default/" /usr/bin/google-chrome-stable --version 2>&1 | head -1 echo "" echo "=== No changes needed ===" echo "Everything is already correctly configured." else echo "Installing Google Chrome..." echo "" # Wait for apt lock while sudo fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1; do echo "Waiting for apt lock..." sleep 2 done # Setup Google Chrome repository echo "$PASSWORD" | sudo -S mkdir -p /usr/share/keyrings wget -qO- https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor | sudo tee /usr/share/keyrings/google-chrome.gpg > /dev/null echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list > /dev/null # Install Google Chrome echo "$PASSWORD" | sudo -S apt update echo "$PASSWORD" | sudo -S apt install -y google-chrome-stable # Create config directory mkdir -p ~/.config/google-chrome/Default echo "" echo "=== Installation Complete ===" echo "Google Chrome installed." echo "Config location: ~/.config/google-chrome/Default/" fi fi # Setup keyring to prevent password prompts mkdir -p ~/.local/share/keyrings touch ~/.local/share/keyrings/login.keyring echo "✓ Keyring configured" echo "" echo "Done!"