Posted By

pmeinhardt on 06/29/11


Tagged

browser script update chromium chromatic


Versions (?)

chromatic-sh


 / Published in: Bash
 

a chromium browser update script – install the latest snapshot build with a single command.

  1. #!/bin/bash
  2.  
  3.  
  4. # config.
  5. TMP_DIR="/tmp/chromium-latest"
  6. DIST_URI="http://build.chromium.org/f/chromium/snapshots/Mac"
  7.  
  8.  
  9. # output formatting.
  10. STD='\033[0m'
  11. BOLD='\033[01m'
  12. BLUE='\033[34m'
  13. RED='\033[31m'
  14.  
  15.  
  16. # usage (currently takes no args).
  17. if test $# -gt 0; then
  18. echo "Usage: ./chromatic.sh"
  19. exit 0
  20. fi
  21.  
  22.  
  23. # create update dir.
  24. if test -d $TMP_DIR; then
  25. echo -e "${RED}Update directory ${TMP_DIR} already exists.${STD}"
  26. echo -en "Continue anyway? [Y/n] "
  27. read -n 1 CONTINUE
  28. echo
  29. test $CONTINUE = 'Y' || exit -1
  30. fi
  31.  
  32. mkdir -p $TMP_DIR && cd $TMP_DIR
  33.  
  34. # fetch latest revision number.
  35. curl $DIST_URI/LATEST -o $TMP_DIR/LATEST --silent && LATEST=`cat ${TMP_DIR}/LATEST`
  36. if ! test $LATEST; then
  37. echo -e "${RED}Could not connect to server.${STD}"
  38. exit -1
  39. fi
  40.  
  41. echo -e "Latest build version: ${BLUE}${LATEST}${STD}."
  42.  
  43. # check installed version.
  44. PLIST_FILE="/Applications/Chromium.app/Contents/Info.plist"
  45. if test -f $PLIST_FILE; then
  46. INSTALLED=`/usr/libexec/PlistBuddy -c "Print SVNRevision" ${PLIST_FILE}`
  47. if test $INSTALLED && test $LATEST = $INSTALLED; then
  48. echo "You're up to date."
  49. exit 0
  50. fi
  51. fi
  52.  
  53. # load, unpack and install.
  54. echo "Downloading..."
  55. curl $DIST_URI/$LATEST/chrome-mac.zip -o $TMP_DIR/chrome-mac.zip --silent
  56.  
  57. echo "Unzipping..."
  58. if ! test -f $TMP_DIR/chrome-mac.zip; then
  59. echo -e "${RED}Download failed.${STD}"
  60. exit -1
  61. fi
  62. unzip -qq $TMP_DIR/chrome-mac.zip
  63. test -d /Applications/Chromium.app && mv /Applications/Chromium.app ~/.Trash
  64. cp -R $TMP_DIR/chrome-mac/Chromium.app /Applications
  65.  
  66.  
  67. echo "Cleanup..."
  68. rm -rf $TMP_DIR
  69.  
  70.  
  71. # restart?
  72. echo -en "Restart? [Y/n] "
  73. read -n 1 RESTART
  74. echo
  75. if test $RESTART = 'Y'; then
  76. if ps -ax | grep -v grep | grep Chromium > /dev/null; then
  77. killall TERM Chromium
  78. fi
  79. while ps -ax | grep -v grep | grep Chromium > /dev/null; do
  80. : # wait
  81. done
  82. open /Applications/Chromium.app
  83. fi

Report this snippet  

You need to login to post a comment.