From d4b45af139fb5848c3cb81bf72c07e0d87257d8a Mon Sep 17 00:00:00 2001 From: Jake Jones Date: Fri, 4 Sep 2020 11:17:33 +1000 Subject: [PATCH] Simple plugin to set file permissions Plugin used to set file permission, using chown nobody:users for unraid. --- ...O0dCTlb_Set_File_Permissions_For_UnRaid.js | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Community/Tdarr_Plugin_O8O0dCTlb_Set_File_Permissions_For_UnRaid.js diff --git a/Community/Tdarr_Plugin_O8O0dCTlb_Set_File_Permissions_For_UnRaid.js b/Community/Tdarr_Plugin_O8O0dCTlb_Set_File_Permissions_For_UnRaid.js new file mode 100644 index 0000000..7db2092 --- /dev/null +++ b/Community/Tdarr_Plugin_O8O0dCTlb_Set_File_Permissions_For_UnRaid.js @@ -0,0 +1,57 @@ + + + var fs = require('fs'); + var path = require('path'); + if (fs.existsSync(path.join(process.cwd() , '/npm'))) { + var rootModules = path.join(process.cwd() , '/npm/node_modules/') + } else{ + var rootModules = '' + } + + const importFresh = require(rootModules+'import-fresh'); + const library = importFresh('../methods/library.js') + + module.exports.details = function details() { + return { + id: "Tdarr_Plugin_O8O0dCTlb_Set_File_Permissions_For_UnRaid", + Name: "Set file permissions for UnRaid", + Type: "Video", + Operation: "Transcode", + Description: "Sets file permissions using chown nobody:users to prevent lock from root. Use at end of stack. ", + Version: "", + Link: "", + Tags: "post-processing" + } + } + + module.exports.plugin = function plugin(file) { + + //Must return this object at some point + var response = { + processFile : false, + preset : '', + container : '.mkv', + handBrakeMode : false, + FFmpegMode : true, + reQueueAfter : true, + infoLog : '', + + } + + response.infoLog += "" + + if((true) || file.forceProcessing === true){ + + require("child_process").execSync(`chown nobody:users "${file._id}"`) + response.preset = '' + response.container = '.mkv' + response.handBrakeMode = false + response.FFmpegMode = true + response.reQueueAfter = true; + response.processFile = false + response.infoLog += "File permissions set \n" + return response + } + } + + \ No newline at end of file