Skip to content

Instantly share code, notes, and snippets.

@KristofferBerg
Created February 25, 2025 13:08
Show Gist options
  • Select an option

  • Save KristofferBerg/037b3d6caa733f9f555af9694fa1284c to your computer and use it in GitHub Desktop.

Select an option

Save KristofferBerg/037b3d6caa733f9f555af9694fa1284c to your computer and use it in GitHub Desktop.
Ubuntu 20.04 -> Install chrome and CloudCast extension and start it
#!/bin/bash
# Exit on any error
set -e
echo "Starting Chrome installation and extension setup..."
# Check if Chrome is already installed
if ! command -v google-chrome &> /dev/null; then
echo "Chrome not found. Installing Chrome..."
# Download and install Chrome
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list
sudo apt update
sudo apt install -y google-chrome-stable
echo "Chrome installed successfully!"
else
echo "Chrome is already installed."
fi
# Extension ID to check and install if missing
EXTENSION_ID="lokonoedfjkdohceegojgcphlolliggd"
# Define Chrome user profile path
CHROME_PROFILE_PATH="$HOME/.config/google-chrome/Default/Preferences"
# Check if the extension is already installed
if [ -f "$CHROME_PROFILE_PATH" ] && grep -q "$EXTENSION_ID" "$CHROME_PROFILE_PATH"; then
echo "Chrome extension is already installed. Skipping installation."
else
echo "Setting up Chrome to install extension via policy..."
# Create policy directory if it doesn't exist
sudo mkdir -p /etc/opt/chrome/policies/managed
# Create policy file to force install extension
sudo tee /etc/opt/chrome/policies/managed/extension_policy.json > /dev/null << EOF
{
"ExtensionInstallForcelist": ["$EXTENSION_ID;https://clients2.google.com/service/update2/crx"]
}
EOF
echo "Chrome policy set to install extension on next launch."
echo "Starting Chrome with extension installation..."
google-chrome --no-first-run --password-store=basic "https://chrome.google.com/webstore/detail/$EXTENSION_ID" &
echo "Done! Chrome should be running and attempting to install your extension."
echo "You may need to confirm the installation in Chrome's interface."
fi
# Start Chrome normally without keyring prompts
echo "Launching Chrome..."
google-chrome --no-first-run --password-store=basic &
echo "Script finished."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment