| 
									
										
										
										
											2023-03-22 20:48:20 -04:00
										 |  |  | #!/usr/bin/env bash
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-01 12:13:05 -05:00
										 |  |  | # Copyright (c) 2021-2024 tteck | 
					
						
							| 
									
										
										
										
											2023-03-22 20:48:20 -04:00
										 |  |  | # Author: tteck (tteckster) | 
					
						
							|  |  |  | # License: MIT | 
					
						
							|  |  |  | # https://github.com/tteck/Proxmox/raw/main/LICENSE | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" | 
					
						
							|  |  |  | color | 
					
						
							|  |  |  | verb_ip6 | 
					
						
							|  |  |  | catch_errors | 
					
						
							|  |  |  | setting_up_container | 
					
						
							|  |  |  | network_check | 
					
						
							|  |  |  | update_os | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | msg_info "Installing Dependencies" | 
					
						
							|  |  |  | $STD apt-get install -y curl sudo git mc | 
					
						
							|  |  |  | $STD apt-get install -y make zip net-tools | 
					
						
							|  |  |  | $STD apt-get install -y gcc g++ cmake | 
					
						
							| 
									
										
										
										
											2023-09-01 07:19:05 -04:00
										 |  |  | $STD apt-get install -y ca-certificates | 
					
						
							|  |  |  | $STD apt-get install -y gnupg | 
					
						
							| 
									
										
										
										
											2023-03-22 20:48:20 -04:00
										 |  |  | msg_ok "Installed Dependencies" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | msg_info "Setting up Node.js Repository" | 
					
						
							| 
									
										
										
										
											2023-09-02 08:36:54 -04:00
										 |  |  | mkdir -p /etc/apt/keyrings | 
					
						
							| 
									
										
										
										
											2023-09-01 07:19:05 -04:00
										 |  |  | curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg | 
					
						
							| 
									
										
										
										
											2023-12-27 19:03:35 -05:00
										 |  |  | echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list | 
					
						
							| 
									
										
										
										
											2023-03-22 20:48:20 -04:00
										 |  |  | msg_ok "Set up Node.js Repository" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | msg_info "Installing Node.js" | 
					
						
							| 
									
										
										
										
											2023-09-01 07:19:05 -04:00
										 |  |  | $STD apt-get update | 
					
						
							| 
									
										
										
										
											2023-03-22 20:48:20 -04:00
										 |  |  | $STD apt-get install -y nodejs | 
					
						
							|  |  |  | msg_ok "Installed Node.js" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | msg_info "Installing FFMPEG" | 
					
						
							|  |  |  | $STD apt-get install -y ffmpeg | 
					
						
							|  |  |  | msg_ok "Installed FFMPEG" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-11 06:50:31 -05:00
										 |  |  | msg_info "Cloning Shinobi" | 
					
						
							| 
									
										
										
										
											2023-03-22 20:48:20 -04:00
										 |  |  | cd /opt | 
					
						
							|  |  |  | $STD git clone https://gitlab.com/Shinobi-Systems/Shinobi.git -b master Shinobi | 
					
						
							|  |  |  | cd Shinobi | 
					
						
							|  |  |  | gitVersionNumber=$(git rev-parse HEAD) | 
					
						
							|  |  |  | theDateRightNow=$(date) | 
					
						
							|  |  |  | touch version.json | 
					
						
							|  |  |  | chmod 777 version.json | 
					
						
							|  |  |  | echo '{"Product" : "'"Shinobi"'" , "Branch" : "'"master"'" , "Version" : "'"$gitVersionNumber"'" , "Date" : "'"$theDateRightNow"'" , "Repository" : "'"https://gitlab.com/Shinobi-Systems/Shinobi.git"'"}' > version.json | 
					
						
							|  |  |  | msg_ok "Cloned Shinobi" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | msg_info "Installing Database" | 
					
						
							| 
									
										
										
										
											2023-09-14 07:41:16 -04:00
										 |  |  | sqluser="root" | 
					
						
							|  |  |  | sqlpass="root" | 
					
						
							| 
									
										
										
										
											2023-03-22 20:48:20 -04:00
										 |  |  | echo "mariadb-server mariadb-server/root_password password $sqlpass" | debconf-set-selections | 
					
						
							|  |  |  | echo "mariadb-server mariadb-server/root_password_again password $sqlpass" | debconf-set-selections | 
					
						
							|  |  |  | $STD apt-get install -y mariadb-server | 
					
						
							|  |  |  | service mysql start | 
					
						
							| 
									
										
										
										
											2023-09-14 07:41:16 -04:00
										 |  |  | mysql -u "$sqluser" -p"$sqlpass" -e "source sql/user.sql" || true | 
					
						
							| 
									
										
										
										
											2023-03-22 20:48:20 -04:00
										 |  |  | msg_ok "Installed Database" | 
					
						
							| 
									
										
										
										
											2023-09-14 07:41:16 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | msg_info "Installing Shinobi" | 
					
						
							| 
									
										
										
										
											2023-03-22 20:48:20 -04:00
										 |  |  | cp conf.sample.json conf.json | 
					
						
							|  |  |  | cronKey=$(head -c 1024 < /dev/urandom | sha256sum | awk '{print substr($1,1,29)}') | 
					
						
							|  |  |  | sed -i -e 's/Shinobi/'"$cronKey"'/g' conf.json | 
					
						
							|  |  |  | cp super.sample.json super.json | 
					
						
							|  |  |  | $STD npm i npm -g | 
					
						
							|  |  |  | $STD npm install --unsafe-perm | 
					
						
							|  |  |  | $STD npm install pm2@latest -g | 
					
						
							|  |  |  | chmod -R 755 . | 
					
						
							|  |  |  | touch INSTALL/installed.txt | 
					
						
							|  |  |  | ln -s /opt/Shinobi/INSTALL/shinobi /usr/bin/shinobi | 
					
						
							|  |  |  | node /opt/Shinobi/tools/modifyConfiguration.js addToConfig="{\"cron\":{\"key\":\"$(head -c 64 < /dev/urandom | sha256sum | awk '{print substr($1,1,60)}')\"}}" &>/dev/null | 
					
						
							|  |  |  | $STD pm2 start camera.js | 
					
						
							|  |  |  | $STD pm2 start cron.js | 
					
						
							|  |  |  | $STD pm2 startup | 
					
						
							|  |  |  | $STD pm2 save | 
					
						
							|  |  |  | $STD pm2 list | 
					
						
							|  |  |  | msg_ok "Installed Shinobi" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | motd_ssh | 
					
						
							| 
									
										
										
										
											2023-05-15 07:39:30 -04:00
										 |  |  | customize | 
					
						
							| 
									
										
										
										
											2023-03-22 20:48:20 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | msg_info "Cleaning up" | 
					
						
							| 
									
										
										
										
											2024-05-02 13:26:16 -04:00
										 |  |  | $STD apt-get -y autoremove | 
					
						
							|  |  |  | $STD apt-get -y autoclean | 
					
						
							| 
									
										
										
										
											2023-03-22 20:48:20 -04:00
										 |  |  | msg_ok "Cleaned" |