Advertisement
barjac

get-ge

Jun 23rd, 2011
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.90 KB | None | 0 0
  1. #!/bin/bash
  2. # get-ge
  3. # Installer for Google Earth
  4. ############################
  5. # Description:
  6. # This script downloads and installs Google Earth from Google.com.
  7. # It also installs some needed dependencies, and creates a
  8. # needed symlink if required.
  9. ############################
  10. # Instructions:
  11. # Save this file in your home folder as get-ge
  12. # then
  13. # $ chmod +x get-ge
  14. # Then, in a terminal:-
  15. # $ su
  16. # # ./get-ge
  17. #
  18. # To uninstall use:-
  19. # $ su
  20. # # ./get-ge uninstall
  21. ############################
  22. # Changelog:
  23. # Sunday   07 Aug 2011  Moved download to after dependency check to save time and bandwidth  
  24. #                       in case a dependency install fails.
  25. # Sunday   26 Jun 2011  Added re-trys and timeout.
  26. # Saturday 25 Jun 2011  Changed download into safe temp dir.
  27. #                       Added uninstall option, improved some error trapping.
  28. # Thursday 23 Jun 2011  Added check for existing install and corrected typo.
  29. # Thursday 23 Jun 2011  First pasted
  30. #
  31. ############################
  32. # Note: If the Google Earth version changes then these checksums will need to be edited
  33. arch=$(uname -m)
  34. if [[ $arch = x86_64 ]]; then
  35. # md5sum for x86_64 version
  36.      md5=037ef3ab6595064f9100a449439f2f3e
  37. else
  38.      arch=i386
  39. # md5sum for i386 version
  40.      md5=38d591fdc22fadad41d4e29427da7dca
  41. fi
  42. uninst()
  43. {
  44. if echo $1 | grep -q uninstall; then
  45. urpme google-earth-stable
  46. exit $?
  47. fi
  48. }
  49. chksu()
  50. {
  51. if [[ $UID != 0 ]] || [[ $USER = "root" ]]; then
  52.    echo "Sorry, you must run this as root. (Use su NOT su -)"
  53.    exit 1
  54. fi
  55. }
  56. chkdeps_ge()
  57. {
  58. echo "Checking dependencies for Google Earth"
  59. deps=(fontconfig libX11-common lsb-lib libxrender1 libxext6 libsm6)
  60. for dp in ${deps[@]}; do
  61.       urpmi $dp || exit 1
  62. done
  63. }
  64. gedown()
  65. {
  66. tmp_dir=$(mktemp -d)
  67. [[ -d $tmp_dir ]] || { echo "Failed to create temporary directory"; exit 1; }
  68. cd $tmp_dir || { echo "Error changing to temporary directory"; exit 1; }
  69. wget --timeout=20 --tries=3 "https://dl-ssl.google.com/linux/direct/google-earth-stable_current_$arch.rpm"
  70. [[ -f google-earth-stable_current_$arch.rpm ]] || { echo "Download failed"; rm -rf $tmp_dir; exit 1; }
  71. md5chk=$(md5sum google-earth-stable_current_$arch.rpm | cut -d' ' -f1)
  72. cd .. || { echo "Error changing directory"; exit 1; }
  73. [[ $md5 = $md5chk ]] || { echo "Checksum Failed"; rm -rf $tmp_dir; exit 1; }
  74. }
  75. geinst()
  76. {
  77. [[ -f $tmp_dir/google-earth-stable_current_$arch.rpm ]] || exit 1
  78. rpm -Uvh $tmp_dir/google-earth-stable_current_$arch.rpm 2> /dev/null
  79. [[ $? = 0 ]] || { echo "There was an error during install"; rm -rf $tmp_dir; exit 1; }
  80. }
  81. chkinst()
  82. {
  83. if rpm -qa | grep -q google-earth; then
  84. echo "Google Earth seems to be already installed - uninstall it before running this again"
  85. exit 1
  86. fi
  87. }
  88. chksu
  89. uninst $1
  90. chkinst
  91. chkdeps_ge
  92. gedown
  93. geinst
  94. [[ -h /lib/ld-lsb.so.3 ]] || ln -s /lib/ld-linux.so.2 /lib/ld-lsb.so.3
  95. rm -rf $tmp_dir
  96. echo "Google Earth was successfully installed"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement