Skip to content

Commit 1dc0f56

Browse files
committed
Overhaul the Redhat, Ubuntu and Debian installation instructions.
* Merge all commands into a single text area for ease of copy/paste. * Add a Copy Script button to each text area to copy the script (without comments and blanks) to the clipboard. * Centralise the copy/paste code so it can be used elsewhere. * Always install the database server. Based on reviews/discussion with Magnus, Jonathan, Daniel and Sehrope.
1 parent 3330164 commit 1dc0f56

File tree

6 files changed

+122
-78
lines changed

6 files changed

+122
-78
lines changed

media/css/main.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,3 +1526,14 @@ table.sponsor-table tbody tr td:nth-child(3) {
15261526
font-size: 1.5rem;
15271527
}
15281528
}
1529+
1530+
/* Script copy buttons */
1531+
.pg-script-container {
1532+
position: relative;
1533+
}
1534+
1535+
.pg-script-copy-btn {
1536+
position: absolute;
1537+
top: 8px;
1538+
right: 8px;
1539+
}

media/js/main.js

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,58 @@ if (location.hash) shiftWindow();
1818
window.addEventListener("hashchange", shiftWindow);
1919

2020

21-
/*
22-
* Debian/Ubuntu download dropdowns
21+
/* Copy a script from an HTML element to the clipboard,
22+
* removing comments and blank lines.
23+
* Arguments:
24+
* trigger: The button calling the function, whose label will be updated
25+
* elem: The element containing the script to copy
2326
*/
24-
$(function() {
25-
$('select#debseries').change(function() {
26-
var deb = document.getElementById('series-deb');
27-
deb.innerHTML = $(this).val();
28-
});
29-
});
27+
28+
function copyScript(trigger, elem) {
29+
var raw = document.getElementById(elem).innerHTML;
30+
31+
// Create a scratch div to copy from
32+
var scratch = document.createElement("div");
33+
document.body.appendChild(scratch);
34+
35+
// Copy the contents of the script box into the scratch div, removing
36+
// comments and blank lines
37+
var lines = raw.split("\n");
38+
var output = '';
39+
for (var l = 0; l < lines.length; l++) {
40+
if (lines[l][0] != '#' && lines[l].trim() != '')
41+
output += lines[l] + '<br />';
42+
}
43+
scratch.innerHTML = output.trim();
44+
45+
// Perform the copy
46+
if(document.body.createTextRange) {
47+
// IE 11
48+
var range = document.body.createTextRange();
49+
range.moveToElementText(scratch);
50+
range.select();
51+
document.execCommand("Copy");
52+
document.getSelection().removeAllRanges()
53+
}
54+
else if(window.getSelection) {
55+
// Sane browsers
56+
var selection = window.getSelection();
57+
var range = document.createRange();
58+
range.selectNodeContents(scratch);
59+
selection.removeAllRanges();
60+
selection.addRange(range);
61+
document.execCommand("Copy");
62+
selection.removeAllRanges();
63+
}
64+
65+
// Remove the scratch div
66+
scratch.parentNode.removeChild(scratch);
67+
68+
// Indicate to the user that the script was copied
69+
var label = trigger.innerHTML;
70+
trigger.innerHTML = 'Copied!';
71+
72+
setTimeout(function() {
73+
trigger.innerHTML = label;
74+
}, 3000);
75+
}

templates/downloads/js/yum.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,11 @@ function archChanged() {
119119
var ver = document.getElementById('version').value;
120120
var plat = document.getElementById('platform').value;
121121
var arch = document.getElementById('arch').value;
122+
var scriptBox = document.getElementById('script-box')
122123

123124
if (!plat || plat == -1) {
124-
document.getElementById('reporpm').innerHTML = 'Select version and platform above';
125-
document.getElementById('clientpackage').innerHTML = 'Select version and platform above';
126-
document.getElementById('serverpackage').innerHTML = 'Select version and platform above';
127-
document.getElementById('initdb').innerHTML = 'Select version and platform above';
128-
document.getElementById('dnfmodule').style.display = 'none';
125+
document.getElementById('copy-btn').style.display = 'none';
126+
scriptBox.innerHTML = 'Select version and platform above';
129127
return;
130128
}
131129

@@ -135,21 +133,28 @@ function archChanged() {
135133
var url = 'https://download.postgresql.org/pub/repos/yum/reporpms/' + plat + '-' + arch + '/pgdg-' + get_rpm_prefix(plat) +'-repo-latest.noarch.rpm';
136134

137135
var installer = get_installer(plat);
138-
document.getElementById('reporpm').innerHTML = installer + ' install ' + url;
139-
document.getElementById('clientpackage').innerHTML = installer + ' install postgresql' + shortver;
140-
document.getElementById('serverpackage').innerHTML = installer + ' install postgresql' + shortver + '-server';
136+
scriptBox.innerHTML = '# Install the repository RPM:\n';
137+
scriptBox.innerHTML += installer + ' install ' + url + '\n\n';
141138

142-
document.getElementById('dnfmodule').style.display = disable_module_on(plat) ? 'list-item' : 'none';
139+
scriptBox.innerHTML += '# Install PostgreSQL:\n';
140+
scriptBox.innerHTML += installer + ' install postgresql' + shortver + '-server\n\n';
143141

142+
if (disable_module_on(plat)) {
143+
scriptBox.innerHTML += '# Disable the built-in PostgreSQL module:\n';
144+
scriptBox.innerHTML += 'dnf -qy module disable postgresql\n\n';
145+
}
146+
147+
scriptBox.innerHTML += '# Optionally initialize the database and enable automatic start:\n';
144148
if (uses_systemd(plat)) {
145149
var setupcmd = 'postgresql-' + shortver + '-setup';
146150
if (ver < 10) {
147-
setupcmd = 'postgresql' + shortver + '-setup';
151+
setupcmd = 'postgresql' + shortver + '-setup';
148152
}
149-
150-
document.getElementById('initdb').innerHTML = '/usr/pgsql-' + ver + '/bin/' + setupcmd + ' initdb<br/>systemctl enable postgresql-' + ver + '<br/>systemctl start postgresql-' + ver;
153+
scriptBox.innerHTML += '/usr/pgsql-' + ver + '/bin/' + setupcmd + ' initdb\nsystemctl enable postgresql-' + ver + '\nsystemctl start postgresql-' + ver;
151154
}
152155
else {
153-
document.getElementById('initdb').innerHTML = 'service postgresql-' + ver + ' initdb<br/>chkconfig postgresql-' + ver + ' on<br/>service postgresql-' + ver + ' start';
156+
scriptBox.innerHTML += 'service postgresql-' + ver + ' initdb\nchkconfig postgresql-' + ver + ' on\nservice postgresql-' + ver + ' start';
154157
}
158+
159+
document.getElementById('copy-btn').style.display = 'block';
155160
}

templates/pages/download/linux/debian.html

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,23 @@ <h2>PostgreSQL Apt Repository</h2>
4141
<p>
4242
To use the apt repository, follow these steps:
4343
</p>
44-
<ol>
45-
<li>
46-
<select id="debseries" name="field.series" class="custom-select">
47-
<option selected="selected" value="YOUR_DEBIAN_VERSION_HERE">Choose your Debian version</option>
48-
<option value="buster">Buster (10.x)</option>
49-
<option value="stretch">Stretch (9.x)</option>
50-
<option value="jessie">Jessie (8.x)</option>
51-
<option value="bullseye">Bullseye (11.x, testing)</option>
52-
<option value="sid">Sid (unstable)</option>
53-
</select>
54-
</li>
55-
<li>
56-
Create the file <var>/etc/apt/sources.list.d/pgdg.list</var>, and add a line
57-
for the repository:
58-
<pre class="code">
59-
deb http://apt.postgresql.org/pub/repos/apt/ <span id="series-deb">YOUR_DEBIAN_VERSION_HERE</span>-pgdg main</pre>
60-
</li>
61-
<li>
62-
Import the repository signing key, and update the package lists:
63-
<pre class="code">
64-
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
65-
sudo apt-get update</pre>
66-
</li>
67-
</ol>
44+
45+
<div class="pg-script-container">
46+
<pre id="script-box" class="code"># Create the file repository configuration:
47+
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
48+
49+
# Import the repository signing key:
50+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
51+
52+
# Update the package lists:
53+
sudo apt-get update
54+
55+
# Install the latest version of PostgreSQL.
56+
# If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
57+
sudo apt-get install postgresql</pre>
58+
<button class="pg-script-copy-btn" onclick="copyScript(this, 'script-box')">Copy Script</button>
59+
</div>
60+
6861
<p>
6962
For more information about the apt repository, including answers to frequent
7063
questions, please see the apt page on

templates/pages/download/linux/redhat.html

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,11 @@ <h2>PostgreSQL Yum Repository</h2>
5959
<li>Select version: <select id="version" class="custom-select" onChange="verChanged()"></select><br/></li>
6060
<li>Select platform: <select id="platform" class="custom-select" onChange="platChanged()"></select></li>
6161
<li>Select architecture: <select id="arch" class="custom-select" onChange="archChanged()"></select></li>
62-
<li>Install the repository RPM:
63-
<pre id="reporpm" class="code"></pre>
64-
</li>
65-
<li id="dnfmodule">Disable the built-in PostgreSQL module
66-
<pre class="code">dnf -qy module disable postgresql</pre>
67-
</li>
68-
<li>Install the client packages:
69-
<pre id="clientpackage" class="code"></pre>
70-
</li>
71-
<li>Optionally install the server packages:
72-
<pre id="serverpackage" class="code"></pre>
73-
</li>
74-
<li>Optionally initialize the database and enable automatic start:
75-
<pre id="initdb" class="code"></pre>
62+
<li>Copy, paste and run the relevant parts of the setup script:
63+
<div class="pg-script-container">
64+
<pre id="script-box" class="code"></pre>
65+
<button id="copy-btn" class="pg-script-copy-btn" onclick="copyScript(this, 'script-box')">Copy Script</button>
66+
</div>
7667
</li>
7768
</ol>
7869

templates/pages/download/linux/ubuntu.html

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,23 @@ <h2>PostgreSQL Apt Repository</h2>
4040
<p>
4141
To use the apt repository, follow these steps:
4242
</p>
43-
<ul>
44-
<li>
45-
<select id="debseries" name="field.series" class="custom-select">
46-
<option selected="selected" value="YOUR_UBUNTU_VERSION_HERE">Choose your Ubuntu version</option>
47-
<option value="focal">Focal (20.04)</option>
48-
<option value="bionic">Bionic (18.04)</option>
49-
<option value="xenial">Xenial (16.04)</option>
50-
</select>
51-
</li>
52-
<li>Create the file <code>/etc/apt/sources.list.d/pgdg.list</code> and add a line
53-
for the repository
54-
<pre class="code">deb http://apt.postgresql.org/pub/repos/apt/ <span id="series-deb">YOUR_UBUNTU_VERSION_HERE</span>-pgdg main</pre>
55-
</li>
56-
<li>
57-
Import the repository signing key, and update the package lists
58-
<pre class="code">wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
59-
sudo apt-get update</pre>
60-
</li>
61-
</ul>
43+
44+
<div class="pg-script-container">
45+
<pre id="script-box" class="code"># Create the file repository configuration:
46+
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
47+
48+
# Import the repository signing key:
49+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
50+
51+
# Update the package lists:
52+
sudo apt-get update
53+
54+
# Install the latest version of PostgreSQL.
55+
# If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
56+
sudo apt-get install postgresql</pre>
57+
<button class="pg-script-copy-btn" onclick="copyScript(this, 'script-box')">Copy Script</button>
58+
</div>
59+
6260
<p>
6361
For more information about the apt repository, including answers to frequent
6462
questions, please see the <a href="https://wiki.postgresql.org/wiki/Apt" target="_blank">PostgreSQL Apt Repository</a> page on

0 commit comments

Comments
 (0)