File size: 4,693 Bytes
9fbdbf7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/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!"