MohanGupta-turing commited on
Commit
9fbdbf7
·
verified ·
1 Parent(s): 1be5fc1

Upload install_chrome.sh

Browse files
Files changed (1) hide show
  1. install_chrome.sh +124 -0
install_chrome.sh ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Chrome configuration script for OSWorld
3
+ # For ARM64 (Mac VM Fusion): Creates symlinks so snap Chromium works with evaluators
4
+ # For x86_64: Installs Google Chrome
5
+
6
+ PASSWORD="password"
7
+
8
+ echo "=== Chrome Configuration Script ==="
9
+
10
+ # Detect architecture
11
+ ARCH=$(dpkg --print-architecture)
12
+ echo "Architecture: $ARCH"
13
+
14
+ if [ "$ARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then
15
+ echo ""
16
+ echo "=== ARM64 Detected (Mac VM Fusion) ==="
17
+
18
+ SNAP_CONFIG="$HOME/snap/chromium/common/chromium"
19
+ STANDARD_CONFIG="$HOME/.config/google-chrome"
20
+
21
+ # Check if symlink already exists and points to correct location
22
+ if [ -L "$STANDARD_CONFIG" ] && [ "$(readlink "$STANDARD_CONFIG")" = "$SNAP_CONFIG" ]; then
23
+ echo "✓ Symlink already configured correctly"
24
+ echo " $STANDARD_CONFIG -> $SNAP_CONFIG"
25
+
26
+ # Verify Chromium works
27
+ if /snap/bin/chromium --version 2>&1 | head -1; then
28
+ echo "✓ Chromium is working"
29
+ fi
30
+
31
+ echo ""
32
+ echo "=== No changes needed ==="
33
+ echo "Everything is already correctly configured."
34
+ else
35
+ echo "Google Chrome is NOT available for ARM64 Linux."
36
+ echo "Using snap Chromium with symlink workaround."
37
+ echo ""
38
+
39
+ # Create snap config directory if it doesn't exist (Chromium will populate it)
40
+ mkdir -p "$SNAP_CONFIG/Default"
41
+
42
+ # Remove existing standard config if it exists (might be a directory, not symlink)
43
+ rm -rf "$STANDARD_CONFIG" 2>/dev/null || true
44
+
45
+ # Create symlink: ~/.config/google-chrome -> ~/snap/chromium/common/chromium
46
+ ln -sf "$SNAP_CONFIG" "$STANDARD_CONFIG"
47
+
48
+ if [ -L "$STANDARD_CONFIG" ]; then
49
+ echo "✓ Symlink created: $STANDARD_CONFIG -> $SNAP_CONFIG"
50
+ else
51
+ echo "✗ Failed to create symlink"
52
+ exit 1
53
+ fi
54
+
55
+ # Create symlink for google-chrome-stable command if it doesn't exist
56
+ if [ ! -f /usr/bin/google-chrome-stable ]; then
57
+ echo "$PASSWORD" | sudo -S ln -sf /snap/bin/chromium /usr/bin/google-chrome-stable 2>/dev/null || true
58
+ echo "✓ Created symlink: /usr/bin/google-chrome-stable -> /snap/bin/chromium"
59
+ fi
60
+
61
+ # Verify Chromium works
62
+ if /snap/bin/chromium --version 2>&1 | head -1; then
63
+ echo "✓ Chromium is working"
64
+ else
65
+ echo "✗ Chromium not found or not working"
66
+ fi
67
+
68
+ echo ""
69
+ echo "=== Configuration Complete ==="
70
+ echo "Snap Chromium will be used."
71
+ echo "Config location: $SNAP_CONFIG/Default/"
72
+ echo "Symlinked to: $STANDARD_CONFIG/Default/"
73
+ echo ""
74
+ echo "Evaluators checking ~/.config/google-chrome/Default/ will find snap Chromium config."
75
+ fi
76
+
77
+ else
78
+ echo ""
79
+ echo "=== x86_64 Detected ==="
80
+
81
+ # Check if Google Chrome is already installed and config exists
82
+ if [ -f /usr/bin/google-chrome-stable ] && [ -d ~/.config/google-chrome/Default ]; then
83
+ echo "✓ Google Chrome is already installed"
84
+ echo "✓ Config directory exists: ~/.config/google-chrome/Default/"
85
+ /usr/bin/google-chrome-stable --version 2>&1 | head -1
86
+ echo ""
87
+ echo "=== No changes needed ==="
88
+ echo "Everything is already correctly configured."
89
+ else
90
+ echo "Installing Google Chrome..."
91
+ echo ""
92
+
93
+ # Wait for apt lock
94
+ while sudo fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1; do
95
+ echo "Waiting for apt lock..."
96
+ sleep 2
97
+ done
98
+
99
+ # Setup Google Chrome repository
100
+ echo "$PASSWORD" | sudo -S mkdir -p /usr/share/keyrings
101
+ wget -qO- https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor | sudo tee /usr/share/keyrings/google-chrome.gpg > /dev/null
102
+ 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
103
+
104
+ # Install Google Chrome
105
+ echo "$PASSWORD" | sudo -S apt update
106
+ echo "$PASSWORD" | sudo -S apt install -y google-chrome-stable
107
+
108
+ # Create config directory
109
+ mkdir -p ~/.config/google-chrome/Default
110
+
111
+ echo ""
112
+ echo "=== Installation Complete ==="
113
+ echo "Google Chrome installed."
114
+ echo "Config location: ~/.config/google-chrome/Default/"
115
+ fi
116
+ fi
117
+
118
+ # Setup keyring to prevent password prompts
119
+ mkdir -p ~/.local/share/keyrings
120
+ touch ~/.local/share/keyrings/login.keyring
121
+ echo "✓ Keyring configured"
122
+
123
+ echo ""
124
+ echo "Done!"