re-add Update button to Superuser panel (dedicated and git-only)
parent
915be87187
commit
fd4d228046
|
@ -414,6 +414,7 @@
|
|||
"API Key Added": "API Key Added",
|
||||
"APIKeyAddedText": "You may use this key now.",
|
||||
"Update": "Update",
|
||||
"updateNotice1": "Updating Shinobi means overwriting files. If you have modified any files yourself you should update Shinobi manually. Your configurations and video files will not be modified.",
|
||||
"Update to Master": "Update to Master",
|
||||
"Update to Development": "Update to Development",
|
||||
"Filters Updated": "Filters Updated",
|
||||
|
@ -755,6 +756,8 @@
|
|||
"Query": "Query",
|
||||
"Request": "Request",
|
||||
"System": "System",
|
||||
"restartRequired": "Restart of Shinobi Core is required for changes to take effect.",
|
||||
"Shinobi Ordered to Update": "Shinobi Update Completed",
|
||||
"Restart Core": "Restart Core",
|
||||
"Restart CRON": "Restart CRON",
|
||||
"Flush PM2 Logs": "Flush PM2 Logs",
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
const fs = require('fs');
|
||||
const spawn = require('child_process').spawn;
|
||||
module.exports = (config) => {
|
||||
var currentlyUpdating = false
|
||||
return {
|
||||
getConfiguration: () => {
|
||||
return new Promise((resolve,reject) => {
|
||||
|
@ -26,6 +28,30 @@ module.exports = (config) => {
|
|||
resolve(err)
|
||||
})
|
||||
})
|
||||
},
|
||||
updateSystem: () => {
|
||||
return new Promise((resolve,reject) => {
|
||||
if(!config.thisIsDocker){
|
||||
if(currentlyUpdating){
|
||||
resolve(true)
|
||||
return
|
||||
};
|
||||
currentlyUpdating = true
|
||||
const updateProcess = spawn('sh',[s.mainDirectory + '/UPDATE.sh'])
|
||||
updateProcess.stderr.on('data',(data) => {
|
||||
s.systemLog('UPDATE.sh',data.toString())
|
||||
})
|
||||
updateProcess.stdout.on('data',(data) => {
|
||||
s.systemLog('UPDATE.sh',data.toString())
|
||||
})
|
||||
updateProcess.on('exit',(data) => {
|
||||
resolve(true)
|
||||
currentlyUpdating = false
|
||||
})
|
||||
}else{
|
||||
resolve(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,10 @@ var exec = require('child_process').exec;
|
|||
var spawn = require('child_process').spawn;
|
||||
var execSync = require('child_process').execSync;
|
||||
module.exports = function(s,config,lang,app){
|
||||
const { modifyConfiguration } = require('./system/utils.js')(config)
|
||||
const {
|
||||
modifyConfiguration,
|
||||
updateSystem,
|
||||
} = require('./system/utils.js')(config)
|
||||
/**
|
||||
* API : Superuser : Get Logs
|
||||
*/
|
||||
|
@ -57,18 +60,15 @@ module.exports = function(s,config,lang,app){
|
|||
* API : Superuser : Update Shinobi
|
||||
*/
|
||||
app.all(config.webPaths.superApiPrefix+':auth/system/update', function (req,res){
|
||||
s.superAuth(req.params,function(resp){
|
||||
s.ffmpegKill()
|
||||
s.systemLog('Shinobi ordered to update',{
|
||||
s.superAuth(req.params,async (resp) => {
|
||||
s.systemLog(lang['Shinobi Ordered to Update'],{
|
||||
by: resp.$user.mail,
|
||||
ip: resp.ip
|
||||
})
|
||||
var updateProcess = spawn('sh',(s.mainDirectory+'/UPDATE.sh').split(' '),{detached: true})
|
||||
updateProcess.stderr.on('data',function(data){
|
||||
s.systemLog('Update Info',data.toString())
|
||||
})
|
||||
updateProcess.stdout.on('data',function(data){
|
||||
s.systemLog('Update Info',data.toString())
|
||||
const didUpdate = await updateSystem()
|
||||
s.systemLog(lang.restartRequired,{
|
||||
by: resp.$user.mail,
|
||||
ip: resp.ip
|
||||
})
|
||||
var endData = {
|
||||
ok : true
|
||||
|
|
|
@ -20,7 +20,7 @@ $(document).ready(function(){
|
|||
})
|
||||
break;
|
||||
case'update':
|
||||
var html = 'Updating Shinobi means overwriting files. If you have modified any files yourself you should update Shinobi manually.'
|
||||
var html = lang.updateNotice1
|
||||
$.confirm.create({
|
||||
title: `${lang.Update} Shinobi?`,
|
||||
body: html,
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<a href="#" class="btn btn-default" restart="system">
|
||||
<i class="fa fa-retweet"></i> <%- lang['Restart Core'] %>
|
||||
</a>
|
||||
<a href="#" class="btn btn-default" system="update">
|
||||
<i class="fa fa-retweet"></i> <%- lang['Update'] %>
|
||||
</a>
|
||||
<a href="#" class="btn btn-default" restart="cron">
|
||||
<i class="fa fa-retweet"></i> <%- lang['Restart CRON'] %>
|
||||
</a>
|
||||
|
|
Loading…
Reference in New Issue