Backup old domain.

This commit is contained in:
Atlante45 2016-09-28 19:17:24 -07:00
parent f73cd1d65e
commit 4830b5c2a0
4 changed files with 134 additions and 23 deletions

View file

@ -0,0 +1,62 @@
@font-face {
font-family: 'Raleway';
src: url('vendor/Raleway/Raleway-Regular.ttf');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Raleway';
src: url('vendor/Raleway/Raleway-ExtraLight.ttf');
font-weight: 200;
font-style: normal;
}
@font-face {
font-family: 'Raleway';
src: url('vendor/Raleway/Raleway-SemiBold.ttf');
font-weight: bold;
font-style: normal;
}
* {
font-family: "Raleway", "Open Sans", Arial, Helvetica, sans-serif;
line-height: 130%;
}
body {
margin: 0;
padding: 0;
color: #808785;
margin: 0 auto;
text-align: center;
font-size: 13.5pt;
-webkit-touch-callout: none; -webkit-user-select: none;
cursor: default;
overflow: hidden;
font-variant-numeric: lining-nums;
-moz-font-feature-settings: "lnum";
-webkit-font-feature-settings: "lnum";
font-feature-settings: "lnum";
}
.selectable {
-webkit-touch-callout: text;
-webkit-user-select: text;
cursor: text;
}
h1 {
font-size: 29pt;
font-weight: normal;
}
a:link,
a:visited,
a:hover,
a:active {
color: #B4B4B4;
}
a:hover {
color: #2D88A4;
}

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>Server Backup</title>
<script src="content-update.js"></script>
<link rel="stylesheet" type="text/css" href="content-update.css"></link>
</head>
<body onload="ready()">
<div>
<h3>We backed up your old server just in case.</br>If you wish to restore it, do the following:</h3>
<p>
1) Stop your server.</br>
2) Go to the backup directory bellow.</br>
3) Move the content in the parent directory.</br>
4) Restart your server.</br>
</br>
Backup Directory:</br>
<span id=directory></span>
</p>
</div>
</body>
</html>

View file

@ -0,0 +1,12 @@
function ready() {
console.log("Ready");
const electron = require('electron');
window.$ = require('./vendor/jquery/jquery-2.1.4.min.js');
electron.ipcRenderer.on('update', function(event, message) {
$('#directory').html(message);
});
electron.ipcRenderer.send('ready');
}

View file

@ -488,27 +488,51 @@ function updateTrayMenu(serverState) {
const httpStatusPort = 60332;
function deleteResourceDirectories() {
const dsResourceDirectory = getDomainServerClientResourcesDirectory();
function backupResourceDirectories(folder) {
try {
fs.removeSync(dsResourceDirectory);
console.log("Deleted directory " + dsResourceDirectory);
} catch (e) {
console.log(e);
}
const acResourceDirectory = getAssignmentClientResourcesDirectory();
try {
fs.removeSync(acResourceDirectory);
console.log("Deleted directory " + acResourceDirectory);
fs.mkdirSync(folder);
console.log("Created directory " + folder);
var dsBackup = path.join(folder, '/domain-server');
fs.renameSync(getDomainServerClientResourcesDirectory(), dsBackup);
console.log("Moved directory " + getDomainServerClientResourcesDirectory());
console.log("to " + dsBackup);
var acBackup = path.join(folder, '/assignment-client');
fs.renameSync(getAssignmentClientResourcesDirectory(), acBackup);
console.log("Moved directory " + getDomainServerClientResourcesDirectory());
console.log("to " + acBackup);
} catch (e) {
console.log(e);
}
}
function deleteResourceDirectoriesAndRestart() {
function backupResourceDirectoriesAndRestart() {
homeServer.stop();
deleteResourceDirectories();
var date = new Date();
var folder = getRootHifiDataDirectory() + "/Server Backup - " + date;
backupResourceDirectories(folder);
maybeInstallDefaultContentSet(onContentLoaded);
// Explain user how to restore server
var window = new BrowserWindow({
icon: appIcon,
width: 500,
height: 350,
});
window.loadURL('file://' + __dirname + '/content-update.html');
if (!debug) {
window.setMenu(null);
}
window.show();
electron.ipcMain.on('ready', function() {
console.log("got ready");
window.webContents.send('update', folder);
});
}
function checkNewContent() {
@ -537,16 +561,7 @@ function checkNewContent() {
message: 'A newer version of the home content set is available.\nDo you wish to update?'
}, function(idx) {
if (idx === 0) {
dialog.showMessageBox({
type: 'question',
buttons: ['Yes', 'No'],
title: 'Are you sure?',
message: 'This action will delete your current sandbox content.\nDo you wish to continue?'
}, function(idx) {
if (idx === 0 && homeServer) {
deleteResourceDirectoriesAndRestart();
}
});
backupResourceDirectoriesAndRestart();
} else {
// They don't want to update, mark content set as current
userConfig.set('homeContentLastModified', new Date());