|
1 | 1 | #!/bin/sh |
2 | 2 |
|
3 | | -# script to add apt.postgresql.org to sources.list |
4 | | - |
5 | | -# from command like |
6 | | -CODENAME="$1" |
7 | | -# lsb_release is the best interface, but not always available |
8 | | -if [-z"$CODENAME" ];then |
9 | | - CODENAME=$(lsb_release -cs2>/dev/null) |
10 | | -fi |
11 | | -# parse os-release (unreliable, does not work on Ubuntu) |
12 | | -if [-z"$CODENAME"-a-f /etc/os-release ];then |
13 | | -. /etc/os-release |
14 | | -# Debian: VERSION="7.0 (wheezy)" |
15 | | -# Ubuntu: VERSION="13.04, Raring Ringtail" |
16 | | - CODENAME=$(echo$VERSION| sed -ne's/.*(\(.*\)).*/\1/') |
17 | | -fi |
18 | | -# guess from sources.list |
19 | | -if [-z"$CODENAME" ];then |
20 | | - CODENAME=$(grep'^deb' /etc/apt/sources.list| head -n1| awk'{ print $3 }') |
21 | | -fi |
22 | | -# complain if no result yet |
23 | | -if [-z"$CODENAME" ];then |
24 | | - cat<<EOF |
25 | | -Could not determine the distribution codename. Please report this as a bug to |
26 | | -pgsql-pkg-debian@postgresql.org. As a workaround, you can call this script with |
27 | | -the proper codename as parameter, e.g. "$0 squeeze". |
28 | | -EOF |
29 | | -exit 1 |
30 | | -fi |
31 | | - |
32 | | -# errors are non-fatal above |
33 | | -set -e |
34 | | - |
35 | | -cat<<EOF |
36 | | -This script will enable the PostgreSQL APT repository on apt.postgresql.org on |
37 | | -your system. The distribution codename used will be$CODENAME-pgdg. |
38 | | -
|
39 | | -EOF |
40 | | - |
41 | | -case$CODENAMEin |
42 | | -# known distributions |
43 | | - sid|wheezy|squeeze|lenny|etch) ;; |
44 | | - precise|lucid) ;; |
45 | | -*)# unknown distribution, verify on the web |
46 | | -DISTURL="http://apt.postgresql.org/pub/repos/apt/dists/" |
47 | | -if [-x /usr/bin/curl ];then |
48 | | - DISTHTML=$(curl -s$DISTURL) |
49 | | -elif [-x /usr/bin/wget ];then |
50 | | - DISTHTML=$(wget --quiet -O -$DISTURL) |
51 | | -fi |
52 | | -if ["$DISTHTML" ];then |
53 | | -if!echo"$DISTHTML"| grep -q"$CODENAME-pgdg";then |
54 | | -cat<<EOF |
55 | | -Your system is using the distribution codename$CODENAME, but$CODENAME-pgdg |
56 | | -does not seem to be a valid distribution on |
57 | | -$DISTURL |
58 | | -
|
59 | | -We abort the installation here. Please ask on the mailing list for assistance. |
60 | | -
|
61 | | -pgsql-pkg-debian@postgresql.org |
62 | | -EOF |
63 | | -exit 1 |
64 | | -fi |
65 | | -fi |
66 | | -;; |
67 | | -esac |
68 | | - |
69 | | -#echo -n "Press Enter to continue, or Ctrl-C to abort." |
70 | | -# |
71 | | -#read enter |
| 3 | +# OS version |
| 4 | +CODENAME=trusty |
72 | 5 |
|
73 | 6 | echo"Writing /etc/apt/sources.list.d/pgdg.list ..." |
74 | 7 | cat> /etc/apt/sources.list.d/pgdg.list<<EOF |
75 | | -deb http://apt.postgresql.org/pub/repos/apt/$CODENAME-pgdg main |
76 | | -#deb-src http://apt.postgresql.org/pub/repos/apt/$CODENAME-pgdg main |
| 8 | +deb http://apt.postgresql.org/pub/repos/apt/$CODENAME-pgdg main$PGVERSION |
77 | 9 | EOF |
78 | 10 |
|
79 | 11 | echo"Importing repository signing key ..." |
|
126 | 58 |
|
127 | 59 | echo"Running apt-get update ..." |
128 | 60 | apt-get update |
129 | | - |
130 | | -cat<<EOF |
131 | | -
|
132 | | -You can now start installing packages from apt.postgresql.org. |
133 | | -
|
134 | | -Have a look at https://wiki.postgresql.org/wiki/Apt for more information; |
135 | | -most notably the FAQ at https://wiki.postgresql.org/wiki/Apt/FAQ |
136 | | -EOF |