shinobi-install.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. ubuntuversion=$(lsb_release -r | awk '{print $2}' | cut -d . -f1)
  14. if [ "$ubuntuversion" = "18" ] || [ "$ubuntuversion" -le "18" ]; then
  15. apt install sudo wget -y
  16. sudo apt install -y software-properties-common
  17. sudo add-apt-repository universe -y
  18. apt update -y
  19. apt update --fix-missing -y
  20. fi
  21. msg_info "Installing Dependencies"
  22. $STD apt-get install -y curl sudo git mc
  23. $STD apt-get install -y make zip net-tools
  24. $STD apt-get install -y gcc g++ cmake
  25. msg_ok "Installed Dependencies"
  26. msg_info "Setting up Node.js Repository"
  27. $STD bash <(curl -fsSL https://deb.nodesource.com/setup_18.x)
  28. msg_ok "Set up Node.js Repository"
  29. msg_info "Installing Node.js"
  30. $STD apt-get install -y nodejs
  31. msg_ok "Installed Node.js"
  32. msg_info "Installing FFMPEG"
  33. $STD apt-get install -y ffmpeg
  34. msg_ok "Installed FFMPEG"
  35. msg_info "Clonning Shinobi"
  36. cd /opt
  37. $STD git clone https://gitlab.com/Shinobi-Systems/Shinobi.git -b master Shinobi
  38. cd Shinobi
  39. gitVersionNumber=$(git rev-parse HEAD)
  40. theDateRightNow=$(date)
  41. touch version.json
  42. chmod 777 version.json
  43. echo '{"Product" : "'"Shinobi"'" , "Branch" : "'"master"'" , "Version" : "'"$gitVersionNumber"'" , "Date" : "'"$theDateRightNow"'" , "Repository" : "'"https://gitlab.com/Shinobi-Systems/Shinobi.git"'"}' > version.json
  44. msg_ok "Cloned Shinobi"
  45. msg_info "Installing Database"
  46. sqlpass=""
  47. echo "mariadb-server mariadb-server/root_password password $sqlpass" | debconf-set-selections
  48. echo "mariadb-server mariadb-server/root_password_again password $sqlpass" | debconf-set-selections
  49. $STD apt-get install -y mariadb-server
  50. service mysql start
  51. sqluser="root"
  52. mysql -e "source sql/user.sql" || true
  53. mysql -e "source sql/framework.sql" || true
  54. msg_ok "Installed Database"
  55. cp conf.sample.json conf.json
  56. cronKey=$(head -c 1024 < /dev/urandom | sha256sum | awk '{print substr($1,1,29)}')
  57. sed -i -e 's/Shinobi/'"$cronKey"'/g' conf.json
  58. cp super.sample.json super.json
  59. msg_info "Installing Shinobi"
  60. $STD npm i npm -g
  61. $STD npm install --unsafe-perm
  62. $STD npm install pm2@latest -g
  63. chmod -R 755 .
  64. touch INSTALL/installed.txt
  65. ln -s /opt/Shinobi/INSTALL/shinobi /usr/bin/shinobi
  66. node /opt/Shinobi/tools/modifyConfiguration.js addToConfig="{\"cron\":{\"key\":\"$(head -c 64 < /dev/urandom | sha256sum | awk '{print substr($1,1,60)}')\"}}" &>/dev/null
  67. $STD pm2 start camera.js
  68. $STD pm2 start cron.js
  69. $STD pm2 startup
  70. $STD pm2 save
  71. $STD pm2 list
  72. msg_ok "Installed Shinobi"
  73. motd_ssh
  74. customize
  75. msg_info "Cleaning up"
  76. $STD apt-get autoremove
  77. $STD apt-get autoclean
  78. msg_ok "Cleaned"