2018-09-28 05:37:08 +00:00
|
|
|
var fs = require('fs');
|
2019-08-13 08:08:35 +00:00
|
|
|
module.exports = function(s,config,lang){
|
2018-09-28 05:37:08 +00:00
|
|
|
//directories
|
2018-11-02 23:44:53 +00:00
|
|
|
s.group = {}
|
2018-09-28 05:37:08 +00:00
|
|
|
if(!config.windowsTempDir&&s.isWin===true){config.windowsTempDir='C:/Windows/Temp'}
|
2018-09-29 02:02:53 +00:00
|
|
|
if(!config.defaultMjpeg){config.defaultMjpeg=s.mainDirectory+'/web/libs/img/bg.jpg'}
|
2018-09-28 05:37:08 +00:00
|
|
|
//default stream folder check
|
|
|
|
if(!config.streamDir){
|
2018-11-02 23:44:53 +00:00
|
|
|
if(s.isWin === false){
|
|
|
|
config.streamDir = '/dev/shm'
|
2018-09-28 05:37:08 +00:00
|
|
|
}else{
|
2018-11-02 23:44:53 +00:00
|
|
|
config.streamDir = config.windowsTempDir
|
2018-09-28 05:37:08 +00:00
|
|
|
}
|
2020-08-15 02:21:55 +00:00
|
|
|
config.shmDir = `${s.checkCorrectPathEnding(config.streamDir)}`
|
2018-09-28 05:37:08 +00:00
|
|
|
if(!fs.existsSync(config.streamDir)){
|
2018-11-02 23:44:53 +00:00
|
|
|
config.streamDir = s.mainDirectory+'/streams/'
|
2018-09-28 05:37:08 +00:00
|
|
|
}else{
|
2018-11-02 23:44:53 +00:00
|
|
|
config.streamDir += '/streams/'
|
2018-09-28 05:37:08 +00:00
|
|
|
}
|
|
|
|
}
|
2018-09-29 02:02:53 +00:00
|
|
|
if(!config.videosDir){config.videosDir=s.mainDirectory+'/videos/'}
|
|
|
|
if(!config.binDir){config.binDir=s.mainDirectory+'/fileBin/'}
|
2018-09-28 05:37:08 +00:00
|
|
|
if(!config.addStorage){config.addStorage=[]}
|
|
|
|
s.dir={
|
2018-11-02 23:44:53 +00:00
|
|
|
videos: s.checkCorrectPathEnding(config.videosDir),
|
|
|
|
streams: s.checkCorrectPathEnding(config.streamDir),
|
|
|
|
fileBin: s.checkCorrectPathEnding(config.binDir),
|
|
|
|
addStorage: config.addStorage,
|
|
|
|
languages: s.location.languages+'/'
|
2018-09-28 05:37:08 +00:00
|
|
|
};
|
|
|
|
//streams dir
|
|
|
|
if(!fs.existsSync(s.dir.streams)){
|
|
|
|
fs.mkdirSync(s.dir.streams);
|
|
|
|
}
|
|
|
|
//videos dir
|
|
|
|
if(!fs.existsSync(s.dir.videos)){
|
|
|
|
fs.mkdirSync(s.dir.videos);
|
|
|
|
}
|
|
|
|
//fileBin dir
|
|
|
|
if(!fs.existsSync(s.dir.fileBin)){
|
|
|
|
fs.mkdirSync(s.dir.fileBin);
|
|
|
|
}
|
|
|
|
//additional storage areas
|
2019-03-15 07:32:18 +00:00
|
|
|
s.listOfStorage = [{
|
2019-08-13 08:08:35 +00:00
|
|
|
name: lang['Default'],
|
2019-03-15 07:32:18 +00:00
|
|
|
value: ""
|
|
|
|
}]
|
2018-09-28 05:37:08 +00:00
|
|
|
s.dir.addStorage.forEach(function(v,n){
|
2018-11-02 23:44:53 +00:00
|
|
|
v.path = s.checkCorrectPathEnding(v.path)
|
2018-09-28 05:37:08 +00:00
|
|
|
if(!fs.existsSync(v.path)){
|
|
|
|
fs.mkdirSync(v.path);
|
|
|
|
}
|
2019-03-15 07:32:18 +00:00
|
|
|
s.listOfStorage.push({
|
|
|
|
name: v.name,
|
|
|
|
value: v.path
|
|
|
|
})
|
|
|
|
})
|
|
|
|
//get audio files list
|
|
|
|
s.listOfAudioFiles = [
|
|
|
|
{
|
2019-08-13 08:08:35 +00:00
|
|
|
name:lang['No Sound'],
|
2019-03-15 07:32:18 +00:00
|
|
|
value:""
|
|
|
|
}
|
|
|
|
]
|
|
|
|
fs.readdirSync(s.mainDirectory + '/web/libs/audio').forEach(function(file){
|
|
|
|
s.listOfAudioFiles.push({
|
|
|
|
name: file,
|
|
|
|
value: file
|
|
|
|
})
|
|
|
|
})
|
|
|
|
//get themes list
|
|
|
|
s.listOfThemes = [
|
|
|
|
{
|
2019-08-13 08:08:35 +00:00
|
|
|
name:lang['Default'],
|
2019-03-15 07:32:18 +00:00
|
|
|
value:""
|
|
|
|
}
|
|
|
|
]
|
|
|
|
fs.readdirSync(s.mainDirectory + '/web/libs/themes').forEach(function(folder){
|
|
|
|
s.listOfThemes.push({
|
|
|
|
name: folder,
|
|
|
|
value: folder
|
|
|
|
})
|
2018-09-28 05:37:08 +00:00
|
|
|
})
|
|
|
|
}
|