shinobi-install.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/usr/bin/env bash
  2. # Copyright (c) 2021-2023 tteck
  3. # Author: tteck (tteckster)
  4. # License: MIT
  5. # https://github.com/tteck/Proxmox/raw/main/LICENSE
  6. source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
  7. color
  8. verb_ip6
  9. catch_errors
  10. setting_up_container
  11. network_check
  12. update_os
  13. msg_info "Installing Dependencies"
  14. $STD apt-get install -y curl sudo git mc
  15. $STD apt-get install -y make zip net-tools
  16. $STD apt-get install -y gcc g++ cmake
  17. $STD apt-get install -y ca-certificates
  18. $STD apt-get install -y gnupg
  19. msg_ok "Installed Dependencies"
  20. msg_info "Setting up Node.js Repository"
  21. mkdir -p /etc/apt/keyrings
  22. curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
  23. echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
  24. msg_ok "Set up Node.js Repository"
  25. msg_info "Installing Node.js"
  26. $STD apt-get update
  27. $STD apt-get install -y nodejs
  28. msg_ok "Installed Node.js"
  29. msg_info "Installing FFMPEG"
  30. $STD apt-get install -y ffmpeg
  31. msg_ok "Installed FFMPEG"
  32. msg_info "Clonning Shinobi"
  33. cd /opt
  34. $STD git clone https://gitlab.com/Shinobi-Systems/Shinobi.git -b master Shinobi
  35. cd Shinobi
  36. gitVersionNumber=$(git rev-parse HEAD)
  37. theDateRightNow=$(date)
  38. touch version.json
  39. chmod 777 version.json
  40. echo '{"Product" : "'"Shinobi"'" , "Branch" : "'"master"'" , "Version" : "'"$gitVersionNumber"'" , "Date" : "'"$theDateRightNow"'" , "Repository" : "'"https://gitlab.com/Shinobi-Systems/Shinobi.git"'"}' > version.json
  41. msg_ok "Cloned Shinobi"
  42. msg_info "Installing Database"
  43. sqluser="root"
  44. sqlpass="root"
  45. echo "mariadb-server mariadb-server/root_password password $sqlpass" | debconf-set-selections
  46. echo "mariadb-server mariadb-server/root_password_again password $sqlpass" | debconf-set-selections
  47. $STD apt-get install -y mariadb-server
  48. service mysql start
  49. mysql -u "$sqluser" -p"$sqlpass" -e "source sql/user.sql" || true
  50. msg_ok "Installed Database"
  51. msg_info "Installing Shinobi"
  52. cp conf.sample.json conf.json
  53. cronKey=$(head -c 1024 < /dev/urandom | sha256sum | awk '{print substr($1,1,29)}')
  54. sed -i -e 's/Shinobi/'"$cronKey"'/g' conf.json
  55. cp super.sample.json super.json
  56. $STD npm i npm -g
  57. $STD npm install --unsafe-perm
  58. $STD npm install pm2@latest -g
  59. chmod -R 755 .
  60. touch INSTALL/installed.txt
  61. ln -s /opt/Shinobi/INSTALL/shinobi /usr/bin/shinobi
  62. node /opt/Shinobi/tools/modifyConfiguration.js addToConfig="{\"cron\":{\"key\":\"$(head -c 64 < /dev/urandom | sha256sum | awk '{print substr($1,1,60)}')\"}}" &>/dev/null
  63. $STD pm2 start camera.js
  64. $STD pm2 start cron.js
  65. $STD pm2 startup
  66. $STD pm2 save
  67. $STD pm2 list
  68. msg_ok "Installed Shinobi"
  69. motd_ssh
  70. customize
  71. msg_info "Cleaning up"
  72. $STD apt-get autoremove
  73. $STD apt-get autoclean
  74. msg_ok "Cleaned"