Skip to content

Commit 660266c

Browse files
committed
Vah Naboris
1 parent 14aae61 commit 660266c

36 files changed

+3370
-1907
lines changed

.dockerignore

-9
This file was deleted.

Dockerfile

-19
This file was deleted.

INSTALL/centos.sh

+116-75
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ echo "========================================================="
55
echo "To answer yes type the letter (y) in lowercase and press ENTER."
66
echo "Default is no (N). Skip any components you already have or don't need."
77
echo "============="
8+
if [ ! -e "./conf.json" ]; then
9+
cp conf.sample.json conf.json
10+
fi
11+
if [ ! -e "./super.json" ]; then
12+
echo "Default Superuser : [email protected]"
13+
echo "Default Password : admin"
14+
cp super.sample.json super.json
15+
fi
816
echo "Shinobi - Run yum update"
917
sudo yum update -y
1018
echo "Shinobi - Get dependencies"
@@ -17,64 +25,83 @@ sudo yum install ffmpeg ffmpeg-devel -y
1725
echo "Shinobi - Do you want to Install Node.js?"
1826
echo "(y)es or (N)o"
1927
read nodejsinstall
20-
if [ "$nodejsinstall" = "y" ]; then
28+
if [ "$nodejsinstall" = "y" ] || [ "$nodejsinstall" = "Y" ]; then
2129
sudo wget https://rpm.nodesource.com/setup_8.x
2230
sudo chmod +x setup_8.x
2331
./setup_8.x
2432
sudo yum install nodejs -y
2533
fi
2634
echo "============="
27-
echo "Shinobi - Do you want to Install MariaDB?"
28-
echo "(y)es or (N)o"
29-
read mysqlagree
30-
if [ "$mysqlagree" = "y" ]; then
31-
sudo yum install mariadb mariadb-server -y
32-
#Start mysql and enable on boot
33-
sudo systemctl start mariadb
34-
sudo systemctl enable mariadb
35-
#Run mysql install
36-
sudo mysql_secure_installation
37-
fi
38-
echo "============="
39-
echo "Shinobi - Database Installation"
40-
echo "(y)es or (N)o"
41-
read mysqlagreeData
42-
if [ "$mysqlagreeData" = "y" ]; then
43-
echo "What is your SQL Username?"
44-
read sqluser
45-
echo "What is your SQL Password?"
46-
read sqlpass
47-
sudo mysql -u $sqluser -p$sqlpass -e "source sql/user.sql" || true
48-
sudo mysql -u $sqluser -p$sqlpass -e "source sql/framework.sql" || true
49-
echo "Shinobi - Do you want to create a new user for viewing and managing cameras in Shinobi? You can do this later in the Superuser panel."
35+
echo "Shinobi - Do you want to use MariaDB or SQLite3?"
36+
echo "SQLite3 is better for small installs"
37+
echo "MariaDB (MySQL) is better for large installs"
38+
echo "(S)QLite3 or (M)ariaDB?"
39+
echo "Press [ENTER] for default (MariaDB)"
40+
read sqliteormariadb
41+
if [ "$sqliteormariadb" = "S" ] || [ "$sqliteormariadb" = "s" ]; then
42+
sudo npm install jsonfile
43+
sudo yum install -y sqlite sqlite-devel -y
44+
node ./tools/modifyConfiguration.js databaseType=sqlite3
45+
if [ ! -e "./shinobi.sqlite" ]; then
46+
echo "Creating shinobi.sqlite for SQLite3..."
47+
sudo cp sql/shinobi.sample.sqlite shinobi.sqlite
48+
else
49+
echo "shinobi.sqlite already exists. Continuing..."
50+
fi
51+
else
52+
echo "============="
53+
echo "Shinobi - Do you want to Install MariaDB?"
5054
echo "(y)es or (N)o"
51-
read mysqlDefaultData
52-
if [ "$mysqlDefaultData" = "y" ]; then
53-
escapeReplaceQuote='\\"'
54-
groupKey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n 1)
55-
userID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)
56-
userEmail=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)"@"$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)".com"
57-
userPasswordPlain=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)
58-
userPasswordMD5=$(echo -n "$userPasswordPlain" | md5sum | awk '{print $1}')
59-
userDetails='{"days":"10"}'
60-
userDetails=$(echo "$userDetails" | sed -e 's/"/'$escapeReplaceQuote'/g')
61-
echo $userDetailsNew
62-
apiIP='0.0.0.0'
63-
apiKey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
64-
apiDetails='{"auth_socket":"1","get_monitors":"1","control_monitors":"1","get_logs":"1","watch_stream":"1","watch_snapshot":"1","watch_videos":"1","delete_videos":"1"}'
65-
apiDetails=$(echo "$apiDetails" | sed -e 's/"/'$escapeReplaceQuote'/g')
66-
rm sql/default_user.sql || true
67-
echo "USE ccio;INSERT INTO Users (\`ke\`,\`uid\`,\`auth\`,\`mail\`,\`pass\`,\`details\`) VALUES (\"$groupKey\",\"$userID\",\"$apiKey\",\"$userEmail\",\"$userPasswordMD5\",\"$userDetails\");INSERT INTO API (\`code\`,\`ke\`,\`uid\`,\`ip\`,\`details\`) VALUES (\"$apiKey\",\"$groupKey\",\"$userID\",\"$apiIP\",\"$apiDetails\");" > "sql/default_user.sql"
68-
sudo mysql -u $sqluser -p$sqlpass --database ccio -e "source sql/default_user.sql" > "INSTALL/log.txt"
69-
echo "The following details will be shown again at the end of the installation."
70-
echo "====================================="
71-
echo "======= Login Credentials ======="
72-
echo "|| Username : $userEmail"
73-
echo "|| Password : $userPasswordPlain"
74-
echo "|| API Key : $apiKey"
75-
echo "====================================="
76-
echo "====================================="
77-
echo "** To change these settings login to either to the Superuser panel or login to the dashboard as the user that was just created and open the Settings window. **"
55+
read mysqlagree
56+
if [ "$mysqlagree" = "y" ] || [ "$mysqlagree" = "Y" ]; then
57+
sudo yum install mariadb mariadb-server -y
58+
#Start mysql and enable on boot
59+
sudo systemctl start mariadb
60+
sudo systemctl enable mariadb
61+
#Run mysql install
62+
sudo mysql_secure_installation
63+
fi
64+
echo "============="
65+
echo "Shinobi - Database Installation"
66+
echo "(y)es or (N)o"
67+
read mysqlagreeData
68+
if [ "$mysqlagreeData" = "y" ] || [ "$mysqlagreeData" = "Y" ]; then
69+
echo "What is your SQL Username?"
70+
read sqluser
71+
echo "What is your SQL Password?"
72+
read sqlpass
73+
sudo mysql -u $sqluser -p$sqlpass -e "source sql/user.sql" || true
74+
sudo mysql -u $sqluser -p$sqlpass -e "source sql/framework.sql" || true
75+
echo "Shinobi - Do you want to create a new user for viewing and managing cameras in Shinobi? You can do this later in the Superuser panel."
76+
echo "(y)es or (N)o"
77+
read mysqlDefaultData
78+
if [ "$mysqlDefaultData" = "y" ] || [ "$mysqlDefaultData" = "Y" ]; then
79+
escapeReplaceQuote='\\"'
80+
groupKey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n 1)
81+
userID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)
82+
userEmail=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)"@"$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)".com"
83+
userPasswordPlain=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)
84+
userPasswordMD5=$(echo -n "$userPasswordPlain" | md5sum | awk '{print $1}')
85+
userDetails='{"days":"10"}'
86+
userDetails=$(echo "$userDetails" | sed -e 's/"/'$escapeReplaceQuote'/g')
87+
echo $userDetailsNew
88+
apiIP='0.0.0.0'
89+
apiKey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
90+
apiDetails='{"auth_socket":"1","get_monitors":"1","control_monitors":"1","get_logs":"1","watch_stream":"1","watch_snapshot":"1","watch_videos":"1","delete_videos":"1"}'
91+
apiDetails=$(echo "$apiDetails" | sed -e 's/"/'$escapeReplaceQuote'/g')
92+
rm sql/default_user.sql || true
93+
echo "USE ccio;INSERT INTO Users (\`ke\`,\`uid\`,\`auth\`,\`mail\`,\`pass\`,\`details\`) VALUES (\"$groupKey\",\"$userID\",\"$apiKey\",\"$userEmail\",\"$userPasswordMD5\",\"$userDetails\");INSERT INTO API (\`code\`,\`ke\`,\`uid\`,\`ip\`,\`details\`) VALUES (\"$apiKey\",\"$groupKey\",\"$userID\",\"$apiIP\",\"$apiDetails\");" > "sql/default_user.sql"
94+
sudo mysql -u $sqluser -p$sqlpass --database ccio -e "source sql/default_user.sql" > "INSTALL/log.txt"
95+
echo "The following details will be shown again at the end of the installation."
96+
echo "====================================="
97+
echo "======= Login Credentials ======="
98+
echo "|| Username : $userEmail"
99+
echo "|| Password : $userPasswordPlain"
100+
echo "|| API Key : $apiKey"
101+
echo "====================================="
102+
echo "====================================="
103+
echo "** To change these settings login to either to the Superuser panel or login to the dashboard as the user that was just created and open the Settings window. **"
104+
fi
78105
fi
79106
fi
80107
echo "============="
@@ -83,39 +110,53 @@ sudo npm install
83110
echo "============="
84111
echo "Shinobi - Install PM2"
85112
sudo npm install pm2 -g
86-
if [ ! -e "./conf.json" ]; then
87-
cp conf.sample.json conf.json
88-
fi
89-
if [ ! -e "./super.json" ]; then
90-
echo "Default Superuser : [email protected]"
91-
echo "Default Password : admin"
92-
cp super.sample.json super.json
93-
fi
94113
echo "Shinobi - Finished"
95114
sudo chmod -R 755 .
96115
touch INSTALL/installed.txt
97-
echo "=====================================" > INSTALL/installed.txt
98-
echo "======= Login Credentials =======" >> INSTALL/installed.txt
99-
echo "|| Username : $userEmail" >> INSTALL/installed.txt
100-
echo "|| Password : $userPasswordPlain" >> INSTALL/installed.txt
101-
echo "|| API Key : $apiKey" >> INSTALL/installed.txt
102-
echo "=====================================" >> INSTALL/installed.txt
103-
echo "=====================================" >> INSTALL/installed.txt
116+
if [ "$mysqlDefaultData" = "y" ] || [ "$mysqlDefaultData" = "Y" ]; then
117+
echo "=====================================" > INSTALL/installed.txt
118+
echo "======= Login Credentials =======" >> INSTALL/installed.txt
119+
echo "|| Username : $userEmail" >> INSTALL/installed.txt
120+
echo "|| Password : $userPasswordPlain" >> INSTALL/installed.txt
121+
echo "|| API Key : $apiKey" >> INSTALL/installed.txt
122+
echo "=====================================" >> INSTALL/installed.txt
123+
echo "=====================================" >> INSTALL/installed.txt
124+
fi
104125
echo "Shinobi - Start Shinobi and set to start on boot?"
105126
echo "(y)es or (N)o"
106127
read startShinobi
107-
if [ "$startShinobi" = "y" ]; then
128+
if [ "$startShinobi" = "y" ] || [ "$startShinobi" = "Y" ]; then
108129
sudo pm2 start camera.js
109130
sudo pm2 start cron.js
110131
sudo pm2 startup
111132
sudo pm2 save
112133
sudo pm2 list
113134
fi
114-
echo "details written to INSTALL/installed.txt"
115-
echo "====================================="
116-
echo "======= Login Credentials ======="
117-
echo "|| Username : $userEmail"
118-
echo "|| Password : $userPasswordPlain"
119-
echo "|| API Key : $apiKey"
120-
echo "====================================="
121-
echo "====================================="
135+
if [ "$mysqlDefaultData" = "y" ] || [ "$mysqlDefaultData" = "Y" ]; then
136+
echo "details written to INSTALL/installed.txt"
137+
echo "====================================="
138+
echo "======= Login Credentials ======="
139+
echo "|| Username : $userEmail"
140+
echo "|| Password : $userPasswordPlain"
141+
echo "|| API Key : $apiKey"
142+
echo "====================================="
143+
echo "====================================="
144+
fi
145+
if [ ! "$sqliteormariadb" = "M" ] && [ ! "$sqliteormariadb" = "m" ]; then
146+
echo "====================================="
147+
echo "||===== Install Completed =====||"
148+
echo "====================================="
149+
echo "|| Login with the Superuser and create a new user!!"
150+
echo "||==================================="
151+
echo "|| Open http://$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'):8080/super in your web browser."
152+
echo "||==================================="
153+
echo "|| Default Superuser : [email protected]"
154+
echo "|| Default Password : admin"
155+
echo "====================================="
156+
echo "====================================="
157+
else
158+
echo "+=================================+"
159+
echo "||===== Install Completed =====||"
160+
echo "|| Access the main Shinobi panel at http://$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'):8080 in your web browser."
161+
echo "+=================================+"
162+
fi

INSTALL/cuda9-part1.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
sudo add-apt-repository ppa:graphics-drivers/ppa -y
2+
sudo apt update -y
3+
sudo apt install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev -y
4+
sudo apt install gcc-6 -y
5+
sudo apt install g++-6 -y
6+
wget https://cdn.shinobi.video/installers/cuda9-part2-after-reboot.sh -O cuda9-part2-after-reboot.sh
7+
sudo chmod +x ./cuda9-part2-after-reboot.sh
8+
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run -O cuda_9.run
9+
sudo chmod +x cuda_9.run
10+
sudo echo "blacklist amd76x_edac" >> /etc/modprobe.d/blacklist.conf
11+
sudo echo "blacklist vga16fb" >> /etc/modprobe.d/blacklist.conf
12+
sudo echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf
13+
sudo echo "blacklist rivafb" >> /etc/modprobe.d/blacklist.conf
14+
sudo echo "blacklist nvidiafb" >> /etc/modprobe.d/blacklist.conf
15+
sudo echo "blacklist rivatv" >> /etc/modprobe.d/blacklist.conf
16+
sudo update-initramfs -u
17+
echo "Now you need to reboot and run the next part."
18+
echo "Do after the reboot inside this directory : ./cuda9-part2-after-reboot.sh"

INSTALL/cuda9-part2-after-reboot.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
sudo service lightdm stop
2+
sudo init 3
3+
sudo ./cuda_9.run -- override
4+
sudo ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc
5+
sudo ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++
6+
nvidia-smi

INSTALL/installDatabase.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
var knex = require('knex');
2+
if(config.databaseType===undefined){config.databaseType='mysql'}
3+
4+
var databaseOptions = {
5+
client: config.databaseType,
6+
connection: config.db,
7+
}
8+
if(databaseOptions.client.indexOf('sqlite')>-1){
9+
databaseOptions.client = 'sqlite3';
10+
databaseOptions.useNullAsDefault = true;
11+
}
12+
if(databaseOptions.client === 'sqlite3' && databaseOptions.connection.filename === undefined){
13+
databaseOptions.connection.filename = __dirname+"/shinobi.sqlite"
14+
}
15+
s.databaseEngine = knex(databaseOptions)
16+
s.sqlQuery = function(query,values,onMoveOn,hideLog){
17+
if(!values){values=[]}
18+
if(typeof values === 'function'){
19+
var onMoveOn = values;
20+
var values = [];
21+
}
22+
if(!onMoveOn){onMoveOn=function(){}}
23+
return s.databaseEngine.raw(query,values)
24+
.asCallback(function(err,r){
25+
if(err&&config.databaseLogs){
26+
s.systemLog('s.sqlQuery QUERY',query)
27+
s.systemLog('s.sqlQuery ERROR',err)
28+
}
29+
if(onMoveOn)
30+
if(typeof onMoveOn === 'function'){
31+
if(!r)r=[]
32+
onMoveOn(err,r)
33+
}else{
34+
console.log(onMoveOn)
35+
}
36+
})
37+
}

0 commit comments

Comments
 (0)