Skip to content

Instantly share code, notes, and snippets.

@andrepearce
Forked from Superbil/chromium_update.sh
Last active April 2, 2024 09:21
Show Gist options
  • Save andrepearce/12b0f73752012c4e815ee4fe05311fce to your computer and use it in GitHub Desktop.
Save andrepearce/12b0f73752012c4e815ee4fe05311fce to your computer and use it in GitHub Desktop.
Auto Update Chromium on OSX
#!/bin/sh -ex
# Chromium update script
# - forked from Superbil/chromium_update.sh
# - Updated by andrepearce
OS=mac
DL_URL=https://download-chromium.appspot.com/dl/${OS}?type=snapshots
INSTALL_DIR=/Applications
TMP_DIR="/tmp/update-chrome-$RANDOM"
TMP_File=chromium.zip
(
mkdir $TMP_DIR ; cd $TMP_DIR
echo Download...
/usr/local/bin/wget -q -O ${TMP_File} ${DL_URL}
if [ $? -ne 0 ] ; then
echo Cannot update.
exit 1
fi
echo Unzip...
unzip -qq ${TMP_File}
echo Copying...
rm -rf "${INSTALL_DIR}/Chromium.app"
mv chrome-$OS/Chromium.app "$INSTALL_DIR"
)
rm -rf $TMP_DIR
echo Done...
echo Writing API Keys...
mv ${INSTALL_DIR}/Chromium.app/Contents/MacOS/Chromium ${INSTALL_DIR}/Chromium.app/Contents/MacOS/Chromium_bin
cat > ${INSTALL_DIR}/Chromium.app/Contents/MacOS/Chromium << EOF
#!/bin/bash
export GOOGLE_API_KEY="" # Enter Google API Key
export GOOGLE_DEFAULT_CLIENT_ID="" # Enter Google Client ID
export GOOGLE_DEFAULT_CLIENT_SECRET="" # Enter Google Client Secret
${INSTALL_DIR}/Chromium.app/Contents/MacOS/Chromium_bin
EOF
chmod +x ${INSTALL_DIR}/Chromium.app/Contents/MacOS/Chromium
echo API Keys Written...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.chromiumupdater</string>
<key>Program</key>
<string>/Users/Shared/mbin/chromium_update.sh</string>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>12</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/var/log/chromium_update.err</string>
<key>StandardOutPath</key>
<string>/var/log/chromium_update.out</string>
</dict>
</plist>
@vgrsec
Copy link

vgrsec commented Jul 10, 2023

wget isn't included with MacOS 13 by default. Replacing line 15 with curl -L ${DL_URL} > ${TMP_File} ensures this code works on MacOS 13 without additional tooling installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment