Update Installers and Terminal Commander
- add zip to ubuntu and centos installers. - add script to create terminal commander on shinobi start or manually by terminal - update terminal commander to use dynamic value for shinobi pathmerge-requests/49/head
parent
84a1311b2e
commit
a3646a6209
|
@ -27,7 +27,7 @@ if [ ! -e "./super.json" ]; then
|
||||||
fi
|
fi
|
||||||
echo "Shinobi - Run yum update"
|
echo "Shinobi - Run yum update"
|
||||||
sudo yum update -y
|
sudo yum update -y
|
||||||
sudo yum install make -y
|
sudo yum install make zip -y
|
||||||
echo "============="
|
echo "============="
|
||||||
echo "Shinobi - Do you want to Install FFMPEG?"
|
echo "Shinobi - Do you want to Install FFMPEG?"
|
||||||
echo "(y)es or (N)o"
|
echo "(y)es or (N)o"
|
||||||
|
|
|
@ -1,12 +1,22 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
installationDirectory="/home/Shinobi"
|
if [ ! -e "/etc/shinobisystems/path.txt" ]; then
|
||||||
if [ ! "$1" ]; then
|
installationDirectory="/home/Shinobi"
|
||||||
|
else
|
||||||
|
installationDirectory=$(cat /etc/shinobisystems/cctv.txt)
|
||||||
|
fi
|
||||||
|
if [[ $@ == *'help'* ]] || [ ! "$1" ]; then
|
||||||
echo "========================================================="
|
echo "========================================================="
|
||||||
echo "==!! Shinobi : The Open Source CCTV and NVR Solution !!=="
|
echo "==!! Shinobi : The Open Source CCTV and NVR Solution !!=="
|
||||||
echo "========================================================="
|
echo "========================================================="
|
||||||
|
if [ ! "$1" ]; then
|
||||||
echo "You are missing function parameters."
|
echo "You are missing function parameters."
|
||||||
echo "Example : shinobi [command] .."
|
echo "Example : shinobi [command] .."
|
||||||
echo "Example : shinobi flush restart logs"
|
echo "Example : shinobi flush restart logs"
|
||||||
|
else
|
||||||
|
echo "Hello there! if you need support come on over"
|
||||||
|
echo "to the Shinobi Community Chat! :)"
|
||||||
|
echo "https://discordapp.com/invite/mdhmvuH/"
|
||||||
|
fi
|
||||||
echo "========================================================="
|
echo "========================================================="
|
||||||
echo "Your available options for COMMAND are as follows"
|
echo "Your available options for COMMAND are as follows"
|
||||||
echo "========================================================="
|
echo "========================================================="
|
||||||
|
@ -19,12 +29,21 @@ if [ ! "$1" ]; then
|
||||||
echo "| stop, exit, or e :"
|
echo "| stop, exit, or e :"
|
||||||
echo "|--> Stop all processes running under the PM2 daemon."
|
echo "|--> Stop all processes running under the PM2 daemon."
|
||||||
echo "-"
|
echo "-"
|
||||||
|
echo "| version :"
|
||||||
|
echo "|--> get version of your current build by git."
|
||||||
|
echo "-"
|
||||||
echo "| logs :"
|
echo "| logs :"
|
||||||
echo "|--> Get PM2 log stream with last 100 lines."
|
echo "|--> Get PM2 log stream with last 100 lines."
|
||||||
echo "-"
|
echo "-"
|
||||||
echo "| clear, flush, or f :"
|
echo "| clear, flush, or f :"
|
||||||
echo "|--> Clear all PM2 logs."
|
echo "|--> Clear all PM2 logs."
|
||||||
echo "-"
|
echo "-"
|
||||||
|
echo "| startupEnable :"
|
||||||
|
echo "|--> Start Shinobi on OS reboot."
|
||||||
|
echo "-"
|
||||||
|
echo "| startupDisable :"
|
||||||
|
echo "|--> Disable starting Shinobi on OS reboot."
|
||||||
|
echo "-"
|
||||||
echo "| kill :"
|
echo "| kill :"
|
||||||
echo "|--> Stop the entire PM2 daemon."
|
echo "|--> Stop the entire PM2 daemon."
|
||||||
fi
|
fi
|
||||||
|
@ -34,7 +53,8 @@ fi
|
||||||
if [[ $@ == *'restart'* ]]; then
|
if [[ $@ == *'restart'* ]]; then
|
||||||
proccessAlive=$(pm2 list | grep camera)
|
proccessAlive=$(pm2 list | grep camera)
|
||||||
if [ "$proccessAlive" ]; then
|
if [ "$proccessAlive" ]; then
|
||||||
pm2 restart all
|
pm2 restart $installationDirectory/camera.js
|
||||||
|
pm2 restart $installationDirectory/cron.js
|
||||||
else
|
else
|
||||||
echo "Shinobi process is not running."
|
echo "Shinobi process is not running."
|
||||||
fi
|
fi
|
||||||
|
@ -58,11 +78,23 @@ fi
|
||||||
if [[ $@ == *'stop'* ]] || [[ $@ == *'exit'* ]]; then
|
if [[ $@ == *'stop'* ]] || [[ $@ == *'exit'* ]]; then
|
||||||
proccessAlive=$(pm2 list | grep camera)
|
proccessAlive=$(pm2 list | grep camera)
|
||||||
if [ "$proccessAlive" ]; then
|
if [ "$proccessAlive" ]; then
|
||||||
pm2 kill
|
pm2 stop $installationDirectory/camera.js
|
||||||
|
pm2 stop $installationDirectory/cron.js
|
||||||
else
|
else
|
||||||
echo "Shinobi process is not running."
|
echo "Shinobi process is not running."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
if [[ $@ == *'version'* ]]; then
|
||||||
|
git show --oneline -s
|
||||||
|
fi
|
||||||
|
if [[ $@ == *'startupEnable'* ]] || [[ $@ == *'startupenable'* ]]; then
|
||||||
|
pm2 startup
|
||||||
|
pm2 save
|
||||||
|
fi
|
||||||
|
if [[ $@ == *'startupDisable'* ]] || [[ $@ == *'startupdisable'* ]]; then
|
||||||
|
pm2 unstartup
|
||||||
|
pm2 save
|
||||||
|
fi
|
||||||
if [[ $@ == *'kill'* ]]; then
|
if [[ $@ == *'kill'* ]]; then
|
||||||
pm2 kill
|
pm2 kill
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
var fs = require('fs');
|
||||||
|
var moment = require('moment');
|
||||||
|
var exec = require('child_process').exec;
|
||||||
|
var execSync = require('child_process').execSync;
|
||||||
|
s = {
|
||||||
|
isWin: (process.platform === 'win32' || process.platform === 'win64'),
|
||||||
|
mainDirectory: __dirname.split('/INSTALL')[0]
|
||||||
|
}
|
||||||
|
var createTerminalCommands = function(callback){
|
||||||
|
var next = function(){
|
||||||
|
if(callback)callback()
|
||||||
|
}
|
||||||
|
if(!s.isWin){
|
||||||
|
var etcPath = '/etc/shinobisystems/'
|
||||||
|
console.log('Creating "' + etcPath + '"...')
|
||||||
|
var createPathFile = function(){
|
||||||
|
var pathTxt = etcPath + 'cctv.txt'
|
||||||
|
console.log('Creating "' + pathTxt + '"...')
|
||||||
|
fs.writeFile(pathTxt,s.mainDirectory,function(err){
|
||||||
|
if(err)console.log(err)
|
||||||
|
fs.chmod(pathTxt,0o777,function(err){
|
||||||
|
if(err)console.log(err)
|
||||||
|
console.log('Linking "' + s.mainDirectory + '/INSTALL/shinobi" to "/usr/bin/shinobi"...')
|
||||||
|
fs.symlink(s.mainDirectory + '/INSTALL/shinobi', '/usr/bin/shinobi', next)
|
||||||
|
console.log('You can now use `shinobi` in terminal.')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
fs.stat(etcPath,function(err,stat){
|
||||||
|
if(!err && stat){
|
||||||
|
createPathFile()
|
||||||
|
}else{
|
||||||
|
fs.mkdir(etcPath,createPathFile)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
//no commands for windows yet
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
createTerminalCommands()
|
|
@ -49,7 +49,7 @@ fi
|
||||||
if ! [ -x "$(command -v npm)" ]; then
|
if ! [ -x "$(command -v npm)" ]; then
|
||||||
sudo apt install npm -y
|
sudo apt install npm -y
|
||||||
fi
|
fi
|
||||||
sudo apt install make -y
|
sudo apt install make zip -y
|
||||||
if ! [ -x "$(command -v ffmpeg)" ]; then
|
if ! [ -x "$(command -v ffmpeg)" ]; then
|
||||||
if [ "$getubuntuversion" = "16" ] || [ "$getubuntuversion" < "16" ]; then
|
if [ "$getubuntuversion" = "16" ] || [ "$getubuntuversion" < "16" ]; then
|
||||||
echo "============="
|
echo "============="
|
||||||
|
|
|
@ -14,6 +14,24 @@ module.exports = function(s,config,lang,io,){
|
||||||
})
|
})
|
||||||
process.send('ready')
|
process.send('ready')
|
||||||
}
|
}
|
||||||
|
var checkForTerminalCommands = function(callback){
|
||||||
|
var next = function(){
|
||||||
|
if(callback)callback()
|
||||||
|
}
|
||||||
|
if(!s.isWin){
|
||||||
|
var etcPath = '/etc/shinobisystems/cctv.txt'
|
||||||
|
fs.stat(etcPath,function(err,stat){
|
||||||
|
if(err || !stat){
|
||||||
|
exec('node '+ s.mainDirectory + '/INSTALL/terminalCommands.js',function(err){
|
||||||
|
console.log(err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
next()
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
}
|
||||||
var loadedAccounts = []
|
var loadedAccounts = []
|
||||||
var loadMonitors = function(callback){
|
var loadMonitors = function(callback){
|
||||||
s.systemLog(lang.startUpText4)
|
s.systemLog(lang.startUpText4)
|
||||||
|
@ -157,6 +175,7 @@ module.exports = function(s,config,lang,io,){
|
||||||
//run prerequsite queries
|
//run prerequsite queries
|
||||||
s.preQueries()
|
s.preQueries()
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
|
checkForTerminalCommands(function(){
|
||||||
//load administrators (groups)
|
//load administrators (groups)
|
||||||
loadAdminUsers(function(){
|
loadAdminUsers(function(){
|
||||||
//load monitors (for groups)
|
//load monitors (for groups)
|
||||||
|
@ -164,6 +183,7 @@ module.exports = function(s,config,lang,io,){
|
||||||
s.processReady()
|
s.processReady()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
},1500)
|
},1500)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue