2
* Copyright 2009 Google Inc.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS-IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
18
import("stringutils.md5");
19
import("sqlbase.persistent_vars");
21
import("etherpad.licensing");
23
jimport("java.lang.System.out.println");
24
jimport("java.lang.System");
28
if (appjet.cache.fakePNE || appjet.config['etherpad.fakePNE']) {
31
if (getVersionString()) {
38
* Versioning scheme: we basically just use the apache scheme of MAJOR.MINOR.PATCH:
40
* Versions are denoted using a standard triplet of integers: MAJOR.MINOR.PATCH. The
41
* basic intent is that MAJOR versions are incompatible, large-scale upgrades of the API.
42
* MINOR versions retain source and binary compatibility with older minor versions, and
43
* changes in the PATCH level are perfectly compatible, forwards and backwards.
46
function getVersionString() {
47
return appjet.config['etherpad.pneVersion'];
50
function parseVersionString(x) {
51
var parts = x.split('.');
53
major: Number(parts[0] || 0),
54
minor: Number(parts[1] || 0),
55
patch: Number(parts[2] || 0)
59
/* returns {major: int, minor: int, patch: int} */
60
function getVersionNumbers() {
61
return parseVersionString(getVersionString());
64
function checkDbVersionUpgrade() {
65
var dbVersionString = persistent_vars.get("db_pne_version");
66
var runningVersionString = getVersionString();
68
if (!dbVersionString) {
69
println("Upgrading to Private Network Edition, version: "+runningVersionString);
73
var dbVersion = parseVersionString(dbVersionString);
74
var runningVersion = getVersionNumbers();
75
var trueRegex = /\s*true\s*/i;
76
var force = trueRegex.test(appjet.config['etherpad.forceDbUpgrade']);
78
if (!force && (runningVersion.major != dbVersion.major)) {
79
println("Error: you are attempting to update an EtherPad["+dbVersionString+
80
"] database to version ["+runningVersionString+"]. This is not possible.");
81
println("Exiting...");
84
if (!force && (runningVersion.minor < dbVersion.minor)) {
85
println("Error: your etherpad database is at a newer version ["+dbVersionString+"] than"+
86
" the current running etherpad ["+runningVersionString+"]. Please upgrade to the "+
88
println("Exiting...");
91
if (!force && (runningVersion.minor > (dbVersion.minor + 1))) {
92
println("\n\nWARNING: you are attempting to upgrade from version "+dbVersionString+" to version "+
93
runningVersionString+". It is recommended that you upgrade one minor version at a time."+
94
" (The \"minor\" version number is the second number separated by dots. For example,"+
95
" if you are running version 1.2, it is recommended that you upgrade to 1.3 and then 1.4 "+
96
" instead of going directly from 1.2 to 1.4.");
97
println("\n\nIf you really want to do this, you can force us to attempt the upgrade with "+
98
" the --etherpad.forceDbUpgrade=true flag.");
99
println("\n\nExiting...");
102
if (runningVersion.minor > dbVersion.minor) {
103
println("Upgrading database to version "+runningVersionString);
107
function saveDbVersion() {
108
var dbVersionString = persistent_vars.get("db_pne_version");
109
if (getVersionString() != dbVersionString) {
110
persistent_vars.put('db_pne_version', getVersionString());
111
println("Upgraded Private Network Edition version to ["+getVersionString()+"]");
115
// These are a list of some of the config vars documented in the PNE manual. They are here
116
// temporarily, until we move them to the PNE config UI.
118
var _eepneAllowedConfigVars = [
122
'etherpad.SQL_JDBC_DRIVER',
123
'etherpad.SQL_JDBC_URL',
124
'etherpad.SQL_PASSWORD',
125
'etherpad.SQL_USERNAME',
126
'etherpad.adminPass',
127
'etherpad.licenseKey',
137
function isServerLicensed() {
141
function enableTrackingAgain() {
144
function pneTrackerHtml() {
145
appjet.cache.noMorePneTracking = true;