From e055e489be2e4f32ee7abe6906404e243f103d47 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 17 Mar 2022 20:50:30 +0100 Subject: [PATCH] packages/shinobi: init MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit flake.lock: Update Flake lock file updates: • Added input 'shinobi': 'gitlab:Shinobi-Systems/Shinobi/a2faa40ab0e9952ff6a7fcf682534171614180c1' (2021-11-30) --- flake.lock | 19 +- flake.nix | 2 + .../dream2nix/overrides/nodejs/default.nix | 24 + .../shinobi/0001-packageDirectory.patch | 28 + ...2-use-packageDirectory-for-languages.patch | 25 + .../0003-use-s.location.languages.patch | 25 + ...004-use-packageDirectory-for-folders.patch | 43 + ...use-packageDirectory-for-definitions.patch | 25 + ...ackageDirectory-for-web-server-paths.patch | 61 + .../0007-remove-terminalCommands.patch | 37 + .../shinobi/0008-use-__dirname-in-ejs.patch | 23 + .../0009-disable-subscription-bullshit.patch | 48 + .../shinobi/plugins/openalpr/dream-lock.json | 5583 +++++++++++++++++ .../plugins/tensorflow-coral/dream-lock.json | 5583 +++++++++++++++++ .../plugins/tensorflow/dream-lock.json | 5583 +++++++++++++++++ .../shinobi/plugins/yolo/dream-lock.json | 5583 +++++++++++++++++ packages/packages.nix | 6 + 17 files changed, 22697 insertions(+), 1 deletion(-) create mode 100644 packages/dream2nix/overrides/nodejs/default.nix create mode 100644 packages/dream2nix/overrides/nodejs/shinobi/0001-packageDirectory.patch create mode 100644 packages/dream2nix/overrides/nodejs/shinobi/0002-use-packageDirectory-for-languages.patch create mode 100644 packages/dream2nix/overrides/nodejs/shinobi/0003-use-s.location.languages.patch create mode 100644 packages/dream2nix/overrides/nodejs/shinobi/0004-use-packageDirectory-for-folders.patch create mode 100644 packages/dream2nix/overrides/nodejs/shinobi/0005-use-packageDirectory-for-definitions.patch create mode 100644 packages/dream2nix/overrides/nodejs/shinobi/0006-use-packageDirectory-for-web-server-paths.patch create mode 100644 packages/dream2nix/overrides/nodejs/shinobi/0007-remove-terminalCommands.patch create mode 100644 packages/dream2nix/overrides/nodejs/shinobi/0008-use-__dirname-in-ejs.patch create mode 100644 packages/dream2nix/overrides/nodejs/shinobi/0009-disable-subscription-bullshit.patch create mode 100644 packages/dream2nix/packages/shinobi/plugins/openalpr/dream-lock.json create mode 100644 packages/dream2nix/packages/shinobi/plugins/tensorflow-coral/dream-lock.json create mode 100644 packages/dream2nix/packages/shinobi/plugins/tensorflow/dream-lock.json create mode 100644 packages/dream2nix/packages/shinobi/plugins/yolo/dream-lock.json diff --git a/flake.lock b/flake.lock index b0a910e..d51b901 100644 --- a/flake.lock +++ b/flake.lock @@ -678,7 +678,8 @@ "nix-super": "nix-super", "nix-vsx": "nix-vsx", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "shinobi": "shinobi" } }, "rust-overlay": { @@ -703,6 +704,22 @@ "type": "github" } }, + "shinobi": { + "flake": false, + "locked": { + "lastModified": 1638289465, + "narHash": "sha256-e1x0MmLtSgatug6sva1L/Ti601Ua4KWwLb6umPEtbEU=", + "owner": "Shinobi-Systems", + "repo": "Shinobi", + "rev": "a2faa40ab0e9952ff6a7fcf682534171614180c1", + "type": "gitlab" + }, + "original": { + "owner": "Shinobi-Systems", + "repo": "Shinobi", + "type": "gitlab" + } + }, "utils": { "locked": { "lastModified": 1642700792, diff --git a/flake.nix b/flake.nix index 6037fd1..29baa31 100644 --- a/flake.nix +++ b/flake.nix @@ -39,6 +39,8 @@ dream2nix.url = "github:nix-community/dream2nix"; dream2nix.inputs.nixpkgs.follows = "nixpkgs"; + + shinobi = { url = "gitlab:Shinobi-Systems/Shinobi"; flake = false; }; }; outputs = { self, nixpkgs, home-manager, nixos-hardware, ... }@inputs: let diff --git a/packages/dream2nix/overrides/nodejs/default.nix b/packages/dream2nix/overrides/nodejs/default.nix new file mode 100644 index 0000000..155f81b --- /dev/null +++ b/packages/dream2nix/overrides/nodejs/default.nix @@ -0,0 +1,24 @@ +{ + lib, + pkgs, + + # dream2nix + satisfiesSemver, + ... +}: + +{ + shinobi.directory-patches = { + patches = [ + ./shinobi/0001-packageDirectory.patch + ./shinobi/0002-use-packageDirectory-for-languages.patch + ./shinobi/0003-use-s.location.languages.patch + ./shinobi/0004-use-packageDirectory-for-folders.patch + ./shinobi/0005-use-packageDirectory-for-definitions.patch + ./shinobi/0006-use-packageDirectory-for-web-server-paths.patch + ./shinobi/0007-remove-terminalCommands.patch + ./shinobi/0008-use-__dirname-in-ejs.patch + ./shinobi/0009-disable-subscription-bullshit.patch + ]; + }; +} \ No newline at end of file diff --git a/packages/dream2nix/overrides/nodejs/shinobi/0001-packageDirectory.patch b/packages/dream2nix/overrides/nodejs/shinobi/0001-packageDirectory.patch new file mode 100644 index 0000000..e1ea141 --- /dev/null +++ b/packages/dream2nix/overrides/nodejs/shinobi/0001-packageDirectory.patch @@ -0,0 +1,28 @@ +From e30bec29ad5d960d8fe0e6d3427601d49d0746ea Mon Sep 17 00:00:00 2001 +From: Max +Date: Tue, 15 Mar 2022 18:15:23 +0100 +Subject: [PATCH 1/9] packageDirectory + +--- + libs/process.js | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/libs/process.js b/libs/process.js +index 9f3852e..b19384a 100644 +--- a/libs/process.js ++++ b/libs/process.js +@@ -30,8 +30,10 @@ module.exports = function(process,__dirname){ + isWin : (process.platform === 'win32' || process.platform === 'win64'), + //UTC Offset + utcOffset : require('moment')().utcOffset(), +- //directory path for this file ++ //directory path for cwd + mainDirectory : process.cwd(), ++ //directory path for this file ++ packageDirectory : require('path').resolve(__dirname), + //time start + timeStarted : new Date() + +-- +2.35.1 + diff --git a/packages/dream2nix/overrides/nodejs/shinobi/0002-use-packageDirectory-for-languages.patch b/packages/dream2nix/overrides/nodejs/shinobi/0002-use-packageDirectory-for-languages.patch new file mode 100644 index 0000000..ad27aee --- /dev/null +++ b/packages/dream2nix/overrides/nodejs/shinobi/0002-use-packageDirectory-for-languages.patch @@ -0,0 +1,25 @@ +From 28e6412cc76855bacc63a92e019fb2cb35cba259 Mon Sep 17 00:00:00 2001 +From: Max +Date: Tue, 15 Mar 2022 18:19:58 +0100 +Subject: [PATCH 2/9] use packageDirectory for languages + +--- + libs/config.js | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libs/config.js b/libs/config.js +index 65ed5ff..d20c05b 100644 +--- a/libs/config.js ++++ b/libs/config.js +@@ -2,7 +2,7 @@ module.exports = function(s){ + s.location = { + super : s.mainDirectory+'/super.json', + config : s.mainDirectory+'/conf.json', +- languages : s.mainDirectory+'/languages' ++ languages : s.packageDirectory+'/languages' + } + try{ + var config = require(s.location.config) +-- +2.35.1 + diff --git a/packages/dream2nix/overrides/nodejs/shinobi/0003-use-s.location.languages.patch b/packages/dream2nix/overrides/nodejs/shinobi/0003-use-s.location.languages.patch new file mode 100644 index 0000000..1fc093b --- /dev/null +++ b/packages/dream2nix/overrides/nodejs/shinobi/0003-use-s.location.languages.patch @@ -0,0 +1,25 @@ +From 5de02cbd463bcc936907ed9af9dc13e4bd3e4f26 Mon Sep 17 00:00:00 2001 +From: Max +Date: Tue, 15 Mar 2022 18:26:44 +0100 +Subject: [PATCH 3/9] use s.location.languages + +--- + libs/language.js | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libs/language.js b/libs/language.js +index ced395a..593321e 100644 +--- a/libs/language.js ++++ b/libs/language.js +@@ -16,7 +16,7 @@ module.exports = function(s,config){ + return Object.assign(lang,{}) + } + s.listOfPossibleLanguages = [] +- fs.readdirSync(s.mainDirectory + '/languages').forEach(function(filename){ ++ fs.readdirSync(s.location.languages).forEach(function(filename){ + var name = filename.replace('.json','') + s.listOfPossibleLanguages.push({ + "name": name, +-- +2.35.1 + diff --git a/packages/dream2nix/overrides/nodejs/shinobi/0004-use-packageDirectory-for-folders.patch b/packages/dream2nix/overrides/nodejs/shinobi/0004-use-packageDirectory-for-folders.patch new file mode 100644 index 0000000..a0f53c1 --- /dev/null +++ b/packages/dream2nix/overrides/nodejs/shinobi/0004-use-packageDirectory-for-folders.patch @@ -0,0 +1,43 @@ +From b7f4ce7fc6ee30499a26a74c25a7a580a5ba4368 Mon Sep 17 00:00:00 2001 +From: Max +Date: Tue, 15 Mar 2022 18:28:48 +0100 +Subject: [PATCH 4/9] use packageDirectory for folders + +--- + libs/folders.js | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/libs/folders.js b/libs/folders.js +index 54f9acc..d35d337 100644 +--- a/libs/folders.js ++++ b/libs/folders.js +@@ -3,7 +3,7 @@ module.exports = function(s,config,lang){ + //directories + s.group = {} + if(!config.windowsTempDir&&s.isWin===true){config.windowsTempDir='C:/Windows/Temp'} +- if(!config.defaultMjpeg){config.defaultMjpeg=s.mainDirectory+'/web/libs/img/bg.jpg'} ++ if(!config.defaultMjpeg){config.defaultMjpeg=s.packageDirectory+'/web/libs/img/bg.jpg'} + //default stream folder check + if(!config.streamDir){ + if(s.isWin === false){ +@@ -62,7 +62,7 @@ module.exports = function(s,config,lang){ + value:"" + } + ] +- fs.readdirSync(s.mainDirectory + '/web/libs/audio').forEach(function(file){ ++ fs.readdirSync(s.packageDirectory + '/web/libs/audio').forEach(function(file){ + s.listOfAudioFiles.push({ + name: file, + value: file +@@ -75,7 +75,7 @@ module.exports = function(s,config,lang){ + value:"" + } + ] +- fs.readdirSync(s.mainDirectory + '/web/libs/themes').forEach(function(folder){ ++ fs.readdirSync(s.packageDirectory + '/web/libs/themes').forEach(function(folder){ + s.listOfThemes.push({ + name: folder, + value: folder +-- +2.35.1 + diff --git a/packages/dream2nix/overrides/nodejs/shinobi/0005-use-packageDirectory-for-definitions.patch b/packages/dream2nix/overrides/nodejs/shinobi/0005-use-packageDirectory-for-definitions.patch new file mode 100644 index 0000000..ec5dc03 --- /dev/null +++ b/packages/dream2nix/overrides/nodejs/shinobi/0005-use-packageDirectory-for-definitions.patch @@ -0,0 +1,25 @@ +From 77d75251a0e1e3a39d0131ef0b353f36bdf4e7b2 Mon Sep 17 00:00:00 2001 +From: Max +Date: Tue, 15 Mar 2022 18:35:04 +0100 +Subject: [PATCH 5/9] use packageDirectory for definitions + +--- + libs/definitions.js | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libs/definitions.js b/libs/definitions.js +index a58a6e2..d60cad9 100644 +--- a/libs/definitions.js ++++ b/libs/definitions.js +@@ -1,7 +1,7 @@ + var fs = require('fs') + var express = require('express') + module.exports = function(s,config,lang,app,io){ +- s.location.definitions = s.mainDirectory+'/definitions' ++ s.location.definitions = s.packageDirectory+'/definitions' + try{ + var definitions = require(s.location.definitions+'/'+config.language+'.js')(s,config,lang) + }catch(er){ +-- +2.35.1 + diff --git a/packages/dream2nix/overrides/nodejs/shinobi/0006-use-packageDirectory-for-web-server-paths.patch b/packages/dream2nix/overrides/nodejs/shinobi/0006-use-packageDirectory-for-web-server-paths.patch new file mode 100644 index 0000000..4bf113a --- /dev/null +++ b/packages/dream2nix/overrides/nodejs/shinobi/0006-use-packageDirectory-for-web-server-paths.patch @@ -0,0 +1,61 @@ +From fc54751d467c214c33178b04c128a13148c54ccb Mon Sep 17 00:00:00 2001 +From: Max +Date: Tue, 15 Mar 2022 18:48:34 +0100 +Subject: [PATCH 6/9] use packageDirectory for web server paths + +--- + libs/webServerPaths.js | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/libs/webServerPaths.js b/libs/webServerPaths.js +index 8e5b29e..56ef9f6 100644 +--- a/libs/webServerPaths.js ++++ b/libs/webServerPaths.js +@@ -73,21 +73,21 @@ module.exports = function(s,config,lang,app,io){ + ////Pages + app.enable('trust proxy'); + if(config.webPaths.home !== '/'){ +- app.use('/libs',express.static(s.mainDirectory + '/web/libs')) ++ app.use('/libs',express.static(s.packageDirectory + '/web/libs')) + } +- app.use(s.checkCorrectPathEnding(config.webPaths.home)+'libs',express.static(s.mainDirectory + '/web/libs')) +- app.use(s.checkCorrectPathEnding(config.webPaths.admin)+'libs',express.static(s.mainDirectory + '/web/libs')) +- app.use(s.checkCorrectPathEnding(config.webPaths.super)+'libs',express.static(s.mainDirectory + '/web/libs')) ++ app.use(s.checkCorrectPathEnding(config.webPaths.home)+'libs',express.static(s.packageDirectory + '/web/libs')) ++ app.use(s.checkCorrectPathEnding(config.webPaths.admin)+'libs',express.static(s.packageDirectory + '/web/libs')) ++ app.use(s.checkCorrectPathEnding(config.webPaths.super)+'libs',express.static(s.packageDirectory + '/web/libs')) + app.use(bodyParser.json()); + app.use(bodyParser.urlencoded({extended: true})); + app.use(function (req,res,next){ + res.header("Access-Control-Allow-Origin",'*'); + next() + }) +- app.set('views', s.mainDirectory + '/web'); ++ app.set('views', s.packageDirectory + '/web'); + app.set('view engine','ejs'); + //add template handler +- if(config.renderPaths.handler!==undefined){require(s.mainDirectory+'/web/'+config.renderPaths.handler+'.js').addHandlers(s,app,io,config)} ++ if(config.renderPaths.handler!==undefined){require(s.packageDirectory+'/web/'+config.renderPaths.handler+'.js').addHandlers(s,app,io,config)} + + /** + * API : Logout +@@ -328,7 +328,7 @@ module.exports = function(s,config,lang,app,io){ + define: s.getDefinitonFile(userInfo.details.lang), + addStorage: s.dir.addStorage, + fs: fs, +- __dirname: s.mainDirectory, ++ __dirname: s.packageDirectory, + customAutoLoad: s.customAutoLoadTree + }) + break; +@@ -1771,6 +1771,6 @@ module.exports = function(s,config,lang,app,io){ + res.on('finish',function(){ + res.end() + }) +- fs.createReadStream(s.mainDirectory + '/web/pages/robots.txt').pipe(res) ++ fs.createReadStream(s.packageDirectory + '/web/pages/robots.txt').pipe(res) + }) + } +-- +2.35.1 + diff --git a/packages/dream2nix/overrides/nodejs/shinobi/0007-remove-terminalCommands.patch b/packages/dream2nix/overrides/nodejs/shinobi/0007-remove-terminalCommands.patch new file mode 100644 index 0000000..c40318f --- /dev/null +++ b/packages/dream2nix/overrides/nodejs/shinobi/0007-remove-terminalCommands.patch @@ -0,0 +1,37 @@ +From 9ea5979b0c2731604c0b2d519a929b5b920f9eb4 Mon Sep 17 00:00:00 2001 +From: Max +Date: Tue, 15 Mar 2022 18:51:47 +0100 +Subject: [PATCH 7/9] remove terminalCommands + +--- + libs/startup.js | 14 +------------- + 1 file changed, 1 insertion(+), 13 deletions(-) + +diff --git a/libs/startup.js b/libs/startup.js +index 47d338b..b67ecb9 100644 +--- a/libs/startup.js ++++ b/libs/startup.js +@@ -29,19 +29,7 @@ module.exports = function(s,config,lang,io){ + var next = function(){ + if(callback)callback() + } +- if(!s.isWin && s.packageJson.mainDirectory !== '.'){ +- var etcPath = '/etc/shinobisystems/cctv.txt' +- fs.stat(etcPath,function(err,stat){ +- if(err || !stat){ +- exec('node '+ s.mainDirectory + '/INSTALL/terminalCommands.js',function(err){ +- if(err)console.log(err) +- }) +- } +- next() +- }) +- }else{ +- next() +- } ++ next() + } + var loadedAccounts = [] + var foundMonitors = [] +-- +2.35.1 + diff --git a/packages/dream2nix/overrides/nodejs/shinobi/0008-use-__dirname-in-ejs.patch b/packages/dream2nix/overrides/nodejs/shinobi/0008-use-__dirname-in-ejs.patch new file mode 100644 index 0000000..aff456e --- /dev/null +++ b/packages/dream2nix/overrides/nodejs/shinobi/0008-use-__dirname-in-ejs.patch @@ -0,0 +1,23 @@ +From 978dd533a08cc1155819be65598055f7232ad8c8 Mon Sep 17 00:00:00 2001 +From: Max +Date: Tue, 15 Mar 2022 19:18:02 +0100 +Subject: [PATCH 8/9] use __dirname in ejs + +--- + web/pages/blocks/settings.ejs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/web/pages/blocks/settings.ejs b/web/pages/blocks/settings.ejs +index 39d1b9b..7baed45 100644 +--- a/web/pages/blocks/settings.ejs ++++ b/web/pages/blocks/settings.ejs +@@ -1,5 +1,5 @@ + +-<% var audioFiles = fs.readdirSync('./web/libs/audio') %> ++<% var audioFiles = fs.readdirSync(__dirname + '/web/libs/audio') %> +