Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # get-ge
- # Installer for Google Earth
- ############################
- # Description:
- # This script downloads and installs Google Earth from Google.com.
- # It also installs some needed dependencies, and creates a
- # needed symlink if required.
- ############################
- # Instructions:
- # Save this file in your home folder as get-ge
- # then
- # $ chmod +x get-ge
- # Then, in a terminal:-
- # $ su
- # # ./get-ge
- #
- # To uninstall use:-
- # $ su
- # # ./get-ge uninstall
- ############################
- # Changelog:
- # Sunday 07 Aug 2011 Moved download to after dependency check to save time and bandwidth
- # in case a dependency install fails.
- # Sunday 26 Jun 2011 Added re-trys and timeout.
- # Saturday 25 Jun 2011 Changed download into safe temp dir.
- # Added uninstall option, improved some error trapping.
- # Thursday 23 Jun 2011 Added check for existing install and corrected typo.
- # Thursday 23 Jun 2011 First pasted
- #
- ############################
- # Note: If the Google Earth version changes then these checksums will need to be edited
- arch=$(uname -m)
- if [[ $arch = x86_64 ]]; then
- # md5sum for x86_64 version
- md5=037ef3ab6595064f9100a449439f2f3e
- else
- arch=i386
- # md5sum for i386 version
- md5=38d591fdc22fadad41d4e29427da7dca
- fi
- uninst()
- {
- if echo $1 | grep -q uninstall; then
- urpme google-earth-stable
- exit $?
- fi
- }
- chksu()
- {
- if [[ $UID != 0 ]] || [[ $USER = "root" ]]; then
- echo "Sorry, you must run this as root. (Use su NOT su -)"
- exit 1
- fi
- }
- chkdeps_ge()
- {
- echo "Checking dependencies for Google Earth"
- deps=(fontconfig libX11-common lsb-lib libxrender1 libxext6 libsm6)
- for dp in ${deps[@]}; do
- urpmi $dp || exit 1
- done
- }
- gedown()
- {
- tmp_dir=$(mktemp -d)
- [[ -d $tmp_dir ]] || { echo "Failed to create temporary directory"; exit 1; }
- cd $tmp_dir || { echo "Error changing to temporary directory"; exit 1; }
- wget --timeout=20 --tries=3 "https://dl-ssl.google.com/linux/direct/google-earth-stable_current_$arch.rpm"
- [[ -f google-earth-stable_current_$arch.rpm ]] || { echo "Download failed"; rm -rf $tmp_dir; exit 1; }
- md5chk=$(md5sum google-earth-stable_current_$arch.rpm | cut -d' ' -f1)
- cd .. || { echo "Error changing directory"; exit 1; }
- [[ $md5 = $md5chk ]] || { echo "Checksum Failed"; rm -rf $tmp_dir; exit 1; }
- }
- geinst()
- {
- [[ -f $tmp_dir/google-earth-stable_current_$arch.rpm ]] || exit 1
- rpm -Uvh $tmp_dir/google-earth-stable_current_$arch.rpm 2> /dev/null
- [[ $? = 0 ]] || { echo "There was an error during install"; rm -rf $tmp_dir; exit 1; }
- }
- chkinst()
- {
- if rpm -qa | grep -q google-earth; then
- echo "Google Earth seems to be already installed - uninstall it before running this again"
- exit 1
- fi
- }
- chksu
- uninst $1
- chkinst
- chkdeps_ge
- gedown
- geinst
- [[ -h /lib/ld-lsb.so.3 ]] || ln -s /lib/ld-linux.so.2 /lib/ld-lsb.so.3
- rm -rf $tmp_dir
- echo "Google Earth was successfully installed"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement