NoPaste

Google Earth postinst

von willy4711

Dein Code:
  1. #!/bin/sh
  2. #
  3. # Copyright (c) 2009 The Chromium Authors. All rights reserved.
  4. # Use of this source code is governed by a BSD-style license that can be
  5. # found in the LICENSE file.
  6.  
  7. if [ "xpro" != "xplugin" ]; then
  8.  
  9.   # Add icons to the system icons
  10.   XDG_ICON_RESOURCE="`which xdg-icon-resource 2> /dev/null`"
  11.   if [ ! -x "$XDG_ICON_RESOURCE" ]; then
  12.     echo "Error: Could not find xdg-icon-resource" >&2
  13.     exit 1
  14.   fi
  15.   for icon in "/opt/google/earth/pro/product_logo_"*.png; do
  16.     size="${icon##*/product_logo_}"
  17.     "$XDG_ICON_RESOURCE" install --size "${size%.png}" "$icon" "google-earth-pro"
  18.   done
  19.  
  20.   # Add an entry to the system menu
  21.   XDG_DESKTOP_MENU="`which xdg-desktop-menu 2> /dev/null`"
  22.   UPDATE_MENUS="`which update-menus 2> /dev/null`"
  23.   if [ ! -x "$XDG_DESKTOP_MENU" ]; then
  24.     echo "Error: Could not find xdg-desktop-menu" >&2
  25.     exit 1
  26.   fi
  27.   "$XDG_DESKTOP_MENU" install /opt/google/earth/pro/google-earth-pro.desktop
  28.  
  29.   if [ -x "$UPDATE_MENUS" ]; then
  30.     update-menus
  31.   fi
  32.  
  33.   # This function uses sed to insert the contents of one file into another file,
  34.   # after the first line matching a given regular expression. If there is no
  35.   # matching line, then the file is unchanged.
  36.   insert_after_first_match() {
  37.     # $1: file to update
  38.     # $2: regular expression
  39.     # $3: file to insert
  40.     sed -i -e "1,/$2/ {
  41.       /$2/ r $3
  42.       }" "$1"
  43.   }
  44.  
  45. else
  46.   echo "Installing Google Earth plugin to /usr/lib/mozilla/plugins."
  47.   install -m 755 -d /usr/lib/mozilla/plugins
  48.   ln -sf /opt/google/earth/pro/libnpgeplugin.so /usr/lib/mozilla/plugins
  49. fi
  50.  
  51.  
  52. # System-wide package configuration.
  53. DEFAULTS_FILE="/etc/default/google-earth-pro"
  54.  
  55. # sources.list setting for google-earth-pro updates.
  56. REPOCONFIG="deb [arch=amd64] http://dl.google.com/linux/earth/deb/ stable main"
  57.  
  58. APT_GET="`which apt-get 2> /dev/null`"
  59. APT_CONFIG="`which apt-config 2> /dev/null`"
  60.  
  61. SOURCES_PREAMBLE="### THIS FILE IS AUTOMATICALLY CONFIGURED ###
  62. # You may comment out this entry, but any other modifications may be lost.\n"
  63.  
  64. # Parse apt configuration and return requested variable value.
  65. apt_config_val() {
  66.   APTVAR="$1"
  67.   if [ -x "$APT_CONFIG" ]; then
  68.     "$APT_CONFIG" dump | sed -e "/^$APTVAR /"'!d' -e "s/^$APTVAR \"\(.*\)\".*/\1/"
  69.   fi
  70. }
  71.  
  72. # Install the repository signing key (see also:
  73. # http://www.google.com/linuxrepositories/aboutkey.html)
  74. install_key() {
  75.   APT_KEY="`which apt-key 2> /dev/null`"
  76.   if [ -x "$APT_KEY" ]; then
  77.     "$APT_KEY" add - >/dev/null 2>&1 <<KEYDATA
  78. -----BEGIN PGP PUBLIC KEY BLOCK-----
  79. Version: GnuPG v1.4.2.2 (GNU/Linux)
  80.  
  81. mQGiBEXwb0YRBADQva2NLpYXxgjNkbuP0LnPoEXruGmvi3XMIxjEUFuGNCP4Rj/a
  82. kv2E5VixBP1vcQFDRJ+p1puh8NU0XERlhpyZrVMzzS/RdWdyXf7E5S8oqNXsoD1z
  83. fvmI+i9b2EhHAA19Kgw7ifV8vMa4tkwslEmcTiwiw8lyUl28Wh4Et8SxzwCggDcA
  84. feGqtn3PP5YAdD0km4S4XeMEAJjlrqPoPv2Gf//tfznY2UyS9PUqFCPLHgFLe80u
  85. QhI2U5jt6jUKN4fHauvR6z3seSAsh1YyzyZCKxJFEKXCCqnrFSoh4WSJsbFNc4PN
  86. b0V0SqiTCkWADZyLT5wll8sWuQ5ylTf3z1ENoHf+G3um3/wk/+xmEHvj9HCTBEXP
  87. 78X0A/0Tqlhc2RBnEf+AqxWvM8sk8LzJI/XGjwBvKfXe+l3rnSR2kEAvGzj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TIyaObMrWu/LvJ3e9I87HseSJStfw6fki
  104. 5og9qFEkMrIrBCp3QGuQWBq/rTdMuwNFiEkEGBECAAkFAkXwb0sCGwwACgkQoECD
  105. D3+sWZF/WACfeNAu1/1hwZtUo1bR+MWiCjpvHtwAnA1R3IHqFLQ2X3xJ40XPuAyY
  106. /FJG
  107. =Quqp
  108. -----END PGP PUBLIC KEY BLOCK-----
  109. -----BEGIN PGP PUBLIC KEY BLOCK-----
  110. Version: GnuPG v1
  111.  
  112. mQINBFcMjNMBEAC6Wr5QuLIFgz1V1EFPlg8ty2TsjQEl4VWftUAqWlMevJFWvYEx
  113. BOsOZ6kNFfBfjAxgJNWTkxZrHzDl74R7KW/nUx6X57bpFjUyRaB8F3/NpWKSeIGS
  114. pJT+0m2SgUNhLAn1WY/iNJGNaMl7lgUnaP+/ZsSNT9hyTBiH3Ev5VvAtMGhVI/u8
  115. P0EtTjXp4o2U+VqFTBGmZ6PJVhCFjZUeRByloHw8dGOshfXKgriebpioHvU8iQ2U
  116. GV3WNIirB2Rq1wkKxXJ/9Iw+4l5m4GmXMs7n3XaYQoBj28H86YA1cYWSm5LR5iU2
  117. TneI1fJ3vwF2vpSXVBUUDk67PZhg6ZwGRT7GFWskC0z8PsWd5jwK20mA8EVKq0vN
  118. BFmMK6i4fJU+ux17Rgvnc9tDSCzFZ1/4f43EZ41uTmmNXIDsaPCqwjvSS5ICadt2
  119. xeqTWDlzONUpOs5yBjF1cfJSdVxsfshvln2JXUwgIdKl4DLbZybuNFXnPffNLb2v
  120. PtRJHO48O2UbeXS8n27PcuMoLRd7+r7TsqG2vBH4t/cB/1vsvWMbqnQlaJ5VsjeW
  121. Tp8Gv9FJiKuU8PKiWsF4EGR/kAFyCB8QbJeQ6HrOT0CXLOaYHRu2TvJ4taY9doXn
  122. 98TgU03XTLcYoSp49cdkkis4K+9hd2dUqARVCG7UVd9PY60VVCKi47BVKQARAQAB
  123. tFRHb29nbGUgSW5jLiAoTGludXggUGFja2FnZXMgU2lnbmluZyBBdXRob3JpdHkp
  124. IDxsaW51eC1wYWNrYWdlcy1rZXltYXN0ZXJAZ29vZ2xlLmNvbT6JAjgEEwECACIF
  125. AlcMjNMCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEHch9jvTi0eW5CAP
  126. /RELE/OAoA4o1cMBxJsljWgCgDig2Ge91bFCN0vExLcP0iByra7qPWJowXDJ5sCj
  127. UBnCkrxGo5D15U7cW5FC0+qWU73q0AuG3OjKDQ49ecdRkYHwcvwWQvT5Lz3DwOGW
  128. 4armfEuzWXcUDeShR7AgfcTq+Pfoo3dHqdB8TmtNySu/AdJFmVH/xTiWYWrOSibh
  129. yLuaSW/0cTkHW0GDk06MlDkcdkTzhO5GMDO7PUxBgCysTXFR0T9TVWDo9VwvuMww
  130. 2pE5foleA0X6PD/6GQpy3aX2xry8rhFvYplEa5zwXhqsscdKXlp1ZPZ4PMvvwe49
  131. 5mY9n/1Rx1TmMvIcLHKP61sURMOve97Gipk/iD6oaeeT8I0khexHCQy7JMROoPMr
  132. z5onVOt2rAGZScIZsm5FYGSt9eDKBWI6qpJ/5QoVhkRWjOXOchZlJHo+kLdg6jq2
  133. vOnIlFnXo0p6Rqf/IEq5PMh70vVZpk4tNYNy4zRx03ZTA9qXRLW+ftxSQIYMY5eC
  134. Z31lqSH4EjqgtUG+zn2A6juKayb1nkt2O3F1wWOm6oTzNsAP5LdReJRlw151Jp4U
  135. 4ftGtw7ygq+nvokXL7YLuu8sbFqfFXcTPrAZa5M9gnC7GCnIQyF/WvqUnrcaC1jp
  136. qBc+pkSJhROhN12QY8Po8AT8/UaUh/dPIiW5A4o8pOPEiEYEEBECAAYFAlcNtn8A
  137. CgkQoECDD3+sWZGy3wCfWTMZWsipX+yG/VB4Q1FunIfEVHYAnimEXCjZ3IVyy5F1
  138. yU36PihDCjWqiEYEEBECAAYFAlcNtvEACgkQMUcsOzG36APnRwCeJ/bfGf8FBa4q
  139. 5TMw8p1GS1jWT5EAn2sc02481HHdTmZiW/CGWXmgE+OPuQINBFcMjcgBEACrL9gH
  140. hdr6gQX4ZMA5slp628xOrHCsdLO54WNdPRKeFHXJqSSJi3fs8FxBWI4FnejeKUGb
  141. F+MrOlFpKqELxaMje7bwZyap3izztZHszP3YmOoTBJvREGKdCkL82cLsChYD/Prg
  142. E8crvkhSnq9evcsKAnziMxg/wDCChUL3Evqo29BeoB81f+E9wkrUTMCT/kVxt3pG
  143. RalKX0UhrtKrpm8yRfjufJfwjkdwgvinkRGZ2GrWHj4LzMbi9/udYaJZ66Yw0hEU
  144. 4USxUB9vNtmSFrb4EB91T2rhc68dgQ4jYBI7K4Ebb8XaWAxb+IAq31l1UkiEA32F
  145. 4qUMoL6rChB4y6nHxOnTvs+XEb5TBwXVogjLRKTQs5U/HV9l7j+HAchk5y3im2N2
  146. UKmMxHqotvPZZUZPdaCRxUedQf9gR0yLZV+U9BcDuwjzL/zjrthNZYlEGJ6HZ/TL
  147. STp4dDH+uXuLqMVWy5iquKtnbrnNTQtv5twD+Ajpgy60YLOJ9YaiJ4GjifOpzSk8
  148. 3e1rJ3p/pX6B5NWQinVLZJzxyeOoh3iMjdmCDSnEXLrCmYv5g6jyV/Wbd4GYFuMK
  149. 8TT7+PQdWLcbZ/Lxc5w0s+c7+f5OfmKXO5KPHnnUsrF5DBaKRPjScpwePQitxeIg
  150. lUgEMDkNruBhu1PzCxd3BtXgu++K3WdoH3VcgwARAQABiQREBBgBAgAPBQJXDI3I
  151. AhsCBQkFo5qAAikJEHch9jvTi0eWwV0gBBkBAgAGBQJXDI3IAAoJEBOXvFNkDbVR
  152. QSYP/0Ewr3T7e0soTz8g4QJLLVqZDZdX8Iez04idNHuvAu0AwdZ2wl0C+tMkD7l4
  153. R2aI6BKe/9wPndk/NJe+ZYcD/uzyiKIJQD48PrifNnwvHu9A80rE4BppQnplENeh
  154. ibbWaGNJQONGFJx7QTYlFjS5LNlG1AX6mQjxvb423zOWSOmEamYXYBmYyMG6vkr/
  155. XTPzsldky8XFuPrJUZslL/Wlx31XQ1IrtkHHOYqWwr0hTc50/2O8H0ewl/dBZLq3
  156. EminZZ+tsTugof0j4SbxYhplw99nGwbN1uXy4L8/dWOUXnY5OgaTKZPF15zRMxXN
  157. 9FeylBVYpp5kzre/rRI6mQ2lafYHdbjvd7ryHF5JvYToSDXd0mzF2nLzm6jwsO84
  158. 7ZNd5GdTD6/vcef1IJta1nSwA/hhLtgtlz6/tNncp3lEdCjAMx29jYPDX+Lqs9JA
  159. xcJHufr82o6wM9TF24Q8ra8NbvB63odVidCfiHoOsIFDUrazH8XuaQzyZkI0bbzL
  160. mgMAvMO6u1zPfe/TK6LdJg7AeAKScOJS38D5mmwaD1bABr67ebA/X5HdaomSDKVd
  161. UYaewfTGBIsrWmCmKpdb+WfX4odFpNzXW/qskiBp5WSesKvN1QUkLJZDZD1kz2++
  162. Xul5B97s5LxLTLRwvgLoNaUFr3lnejzNLgdBpf6FnkA59syRUuIP/jiAZ2uJzXVK
  163. PeRJqMGL+Ue2HiVEe8ima3SQIceqW8jKS7c7Nic6dMWxgnDpk5tJmVjrgfc0a9c1
  164. FY4GomUBbZFj+j73+WRk3EaVKIsty+xz48+rlJjdYFVCJo0Jp67jjjXOt6EOHTni
  165. OA/ANtzRIzDMnWrwJZ7AxCGJ4YjLShkcRM9S30X0iuAkxNILX++SNOd8aqc2bFof
  166. yTCkcbk6CIc1W00vffv1QGTNjstNpVSl9+bRmlJDqJWnDGk5Nl4Ncqd8X51V0tYE
  167. g6WEK4OM83wx5Ew/TdTRq5jJkbCu2GYNaNNNgXW7bXSvT5VINbuP6dmbi1/8s0jK
  168. JQOEBI3RxxoB+01Dgx9YdNfjsCM3hvQvykaWMALeZIpzbXxV118Y9QQUIRe2L+4X
  169. ZACEAhWjj2K1wP7ODGTQrrM4q4sIw1l3l7yO9aXXN7likAAddT4WEpGV0CiorReO
  170. J1y/sKJRJSI/npN1UK7wMazZ+yzhxN0qzG8sqREKJQnNuuGQQ/qIGb/oe4dPO0Fi
  171. hAUGkWoa0bgtGVijN5fQSbMbV50kZYqaa9GnNQRnchmZb+pK2xLcK85hD1np37/A
  172. m5o2ggoONj3qI3JaRHsZaOs1qPQcyd46OyIFUpHJIfk4nezDCoQYd93bWUGqDwxI
  173. /n/CsdO0365yqDO/ADscehlVqdAupVv2uQINBFiGv8wBEACtrmK7c12DfxkPAJSD
  174. 12VanxLLvvjYW0KEWKxN6TMRQCawLhGwFf7FLNpab829DFMhBcNVgJ8aU0YIIu9f
  175. HroIaGi+bkBkDkSWEhSTlYa6ISfBn6Zk9AGBWB/SIelOncuAcI/Ik6BdDzIXnDN7
  176. cXsMgV1ql7jIbdbsdX63wZEFwqbaiL1GWd4BUKhj0H46ZTEVBLl0MfHNlYl+X3ib
  177. 9WpRS6iBAGOWs8Kqw5xVE7oJm9DDXXWOdPUE8/FVti+bmOz+ICwQETY9I2EmyNXy
  178. UG3iaKs07VAf7SPHhgyBEkMngt5ZGcH4gs1m2l/HFQ0StNFNhXuzlHvQhDzd9M1n
  179. qpstEe+f8AZMgyNnM+uGHJq9VVtaNnwtMDastvNkUOs+auMXbNwsl5y/O6ZPX5I5
  180. IvJmUhbSh0UOguGPJKUu/bl65theahz4HGBA0Q5nzgNLXVmU6aic143iixxMk+/q
  181. A59I6KelgWGj9QBPAHU68//J4dPFtlsRKZ7vI0vD14wnMvaJFv6tyTSgNdWsQOCW
  182. i+n16rGfMx1LNZTO1bO6TE6+ZLuvOchGJTYP4LbCeWLL8qDbdfz3oSKHUpyalELJ
  183. ljzin6r3qoA3TqvoGK5OWrFozuhWrWt3tIto53oJ34vJCsRZ0qvKDn9PQX9r3o56
  184. hKhn8G9z/X5tNlfrzeSYikWQcQARAQABiQREBBgBAgAPBQJYhr/MAhsCBQkFo5qA
  185. AikJEHch9jvTi0eWwV0gBBkBAgAGBQJYhr/MAAoJEGSUxtaZfCFeW4kP/iZq+blR
  186. DzgRzOw16x80vyBjfPOUKd++dSUkcr4Khi5vjBygNdVSWcKZaBKVkdB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6TeyQgFWf/FOLw6OtwOquGmMeGSqj2Uzxyb
  203. ygtsvUZz0BxYymoWFd4F8sp43oL2TXU6Wp7QIpBaFgkSf/UQxfR6wcQ3ivafeS1l
  204. g8vUFuMfuMLto6T0JiZw8uKSuDWltSReF+FXVnhawz72BZMy8RIoshGdpWHn/YbN
  205. 6L+JOuxZnvkMAZvSLT3c0H4XCDYtEfK2mJMqD2ynX5tGR8Fy3GAaEjhx36TvzTjC
  206. XRmJ+FnlSW1p77x+UjFUFcpY8skv+f0Gip30iynAb1hoAdibIDab612OWi/4vX0D
  207. aM6t68Uq8rsabeJYsZG4
  208. =lzV/
  209. -----END PGP PUBLIC KEY BLOCK-----
  210. KEYDATA
  211.   fi
  212. }
  213.  
  214. # Set variables for the locations of the apt sources lists.
  215. find_apt_sources() {
  216.   APTDIR=$(apt_config_val Dir)
  217.   APTETC=$(apt_config_val 'Dir::Etc')
  218.   APT_SOURCES="$APTDIR$APTETC/$(apt_config_val 'Dir::Etc::sourcelist')"
  219.   APT_SOURCESDIR="$APTDIR$APTETC/$(apt_config_val 'Dir::Etc::sourceparts')"
  220. }
  221.  
  222. # Update the Google repository if it's not set correctly.
  223. # Note: this doesn't necessarily enable the repository, it just makes sure the
  224. # correct settings are available in the sources list.
  225. # Returns:
  226. # 0 - no update necessary
  227. # 2 - error
  228. update_bad_sources() {
  229.   if [ ! "$REPOCONFIG" ]; then
  230.     return 0
  231.   fi
  232.  
  233.   find_apt_sources
  234.  
  235.   SOURCELIST="$APT_SOURCESDIR/google-earth-pro.list"
  236.   # Don't do anything if the file isn't there, since that probably means the
  237.   # user disabled it.
  238.   if [ ! -r "$SOURCELIST" ]; then
  239.     return 0
  240.   fi
  241.  
  242.   # Basic check for active configurations (non-blank, non-comment lines).
  243.   ACTIVECONFIGS=$(grep -v "^[[:space:]]*\(#.*\)\?$" "$SOURCELIST" 2>/dev/null)
  244.  
  245.   # Check if the correct repository configuration is in there.
  246.   REPOMATCH=$(grep -E "^[[:space:]#]*\b$REPOCONFIGREGEX\b" "$SOURCELIST" \
  247.     2>/dev/null)
  248.  
  249.   # Check if the correct repository is disabled.
  250.   MATCH_DISABLED=$(echo "$REPOMATCH" | grep "^[[:space:]]*#" 2>/dev/null)
  251.  
  252.   # Now figure out if we need to fix things.
  253.   BADCONFIG=1
  254.   if [ "$REPOMATCH" ]; then
  255.     # If it's there and active, that's ideal, so nothing to do.
  256.     if [ ! "$MATCH_DISABLED" ]; then
  257.       BADCONFIG=0
  258.     else
  259.       # If it's not active, but neither is anything else, that's fine too.
  260.       if [ ! "$ACTIVECONFIGS" ]; then
  261.         BADCONFIG=0
  262.       fi
  263.     fi
  264.   fi
  265.  
  266.   if [ $BADCONFIG -eq 0 ]; then
  267.     return 0
  268.   fi
  269.  
  270.   # At this point, either the correct configuration is completely missing, or
  271.   # the wrong configuration is active. In that case, just abandon the mess and
  272.   # recreate the file with the correct configuration. If there were no active
  273.   # configurations before, create the new configuration disabled.
  274.   DISABLE=""
  275.   if [ ! "$ACTIVECONFIGS" ]; then
  276.     DISABLE="#"
  277.   fi
  278.   printf "$SOURCES_PREAMBLE" > "$SOURCELIST"
  279.   printf "$DISABLE$REPOCONFIG\n" >> "$SOURCELIST"
  280.   if [ $? -eq 0 ]; then
  281.     return 0
  282.   fi
  283.   return 2
  284. }
  285.  
  286. # Add the Google repository to the apt sources.
  287. # Returns:
  288. # 0 - sources list was created
  289. # 2 - error
  290. create_sources_lists() {
  291.   if [ ! "$REPOCONFIG" ]; then
  292.     return 0
  293.   fi
  294.  
  295.   find_apt_sources
  296.  
  297.   SOURCELIST="$APT_SOURCESDIR/google-earth-pro.list"
  298.   if [ -d "$APT_SOURCESDIR" ]; then
  299.     printf "$SOURCES_PREAMBLE" > "$SOURCELIST"
  300.     printf "$REPOCONFIG\n" >> "$SOURCELIST"
  301.     if [ $? -eq 0 ]; then
  302.       return 0
  303.     fi
  304.   fi
  305.   return 2
  306. }
  307.  
  308. # Remove our custom sources list file.
  309. # Returns:
  310. # 0 - successfully removed, or not configured
  311. # !0 - failed to remove
  312. clean_sources_lists() {
  313.   if [ ! "$REPOCONFIG" ]; then
  314.     return 0
  315.   fi
  316.  
  317.   find_apt_sources
  318.  
  319.   rm -f "$APT_SOURCESDIR/google-earth-pro.list" \
  320.         "$APT_SOURCESDIR/google-earth-pro-stable.list"
  321. }
  322.  
  323. # Detect if the repo config was disabled by distro upgrade and enable if
  324. # necessary.
  325. handle_distro_upgrade() {
  326.   if [ ! "$REPOCONFIG" ]; then
  327.     return 0
  328.   fi
  329.  
  330.   find_apt_sources
  331.   SOURCELIST="$APT_SOURCESDIR/google-earth-pro.list"
  332.   if [ -r "$SOURCELIST" ]; then
  333.     REPOLINE=$(grep -E "^[[:space:]]*#[[:space:]]*$REPOCONFIGREGEX[[:space:]]*# disabled on upgrade to .*" "$SOURCELIST")
  334.     if [ $? -eq 0 ]; then
  335.       sed -i -e "s,^[[:space:]]*#[[:space:]]*\(.*\)[[:space:]]*# disabled on upgrade to .*,\1," \
  336.         "$SOURCELIST"
  337.       LOGGER=$(which logger 2> /dev/null)
  338.       if [ "$LOGGER" ]; then
  339.         "$LOGGER" -t "$0" "Reverted repository modification: $REPOLINE."
  340.       fi
  341.     fi
  342.   fi
  343. }
  344.  
  345.  
  346.  
  347. ## MAIN ##
  348. if [ ! -e "$DEFAULTS_FILE" ]; then
  349.   echo 'repo_add_once="true"' > "$DEFAULTS_FILE"
  350.   echo 'repo_reenable_on_distupgrade="true"' >> "$DEFAULTS_FILE"
  351. fi
  352.  
  353. # Run the cron job immediately to perform repository configuration.
  354. nohup sh /etc/cron.daily/google-earth-pro > /dev/null 2>&1 &

Quellcode

Hier kannst du den Code kopieren und ihn in deinen bevorzugten Editor einfügen. Alternativ kannst du den gesamten Eintrag auch als Datei herunterladen.