install_latest_jenkins.sh 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. # Automatic install script for ArozOS - by tobychui
  3. # For internal use only, All Right Reserved
  4. server="https://jenkins.alanyeung.co"
  5. echo "[ArozOS Installer]"
  6. echo "Jenkins Server: "
  7. echo $server
  8. echo "You are downloading: "
  9. curl -slient $server/job/arozos/lastBuild/api/json | grep -iEo '"fullDisplayName":"([^"]*)"' | awk -F ":" '{gsub(/"/, "", $2);print $2}'
  10. echo "With build timestamp: "
  11. time=$(curl -slient $server/job/arozos/lastBuild/api/json | grep -iEo '"timestamp":([0-9]*)' | awk -F ":" '{gsub(/"/, "", $2);print $2}')
  12. echo $time
  13. timeHuman=$(date -d "@$(($time/1000))")
  14. echo "$timeHuman"
  15. sleep 3
  16. echo "Installing necessary packages..."
  17. if [ -f /etc/os-release ]; then
  18. # freedesktop.org and systemd
  19. . /etc/os-release
  20. OS=$NAME
  21. elif type lsb_release >/dev/null 2>&1; then
  22. # linuxbase.org
  23. OS=$(lsb_release -si)
  24. elif [ -f /etc/lsb-release ]; then
  25. # For some versions of Debian/Ubuntu without lsb_release command
  26. . /etc/lsb-release
  27. OS=$DISTRIB_ID
  28. elif [ -f /etc/debian_version ]; then
  29. # Older Debian/Ubuntu/etc.
  30. OS=Debian
  31. else
  32. # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
  33. OS=$(uname -s)
  34. fi
  35. if [[ $OS == "Amazon Linux" ]]; then
  36. echo "YUM Package Manager"
  37. sudo yum update
  38. sudo yum install ffmpeg samba git net-tools unzip -y
  39. else
  40. #elif [[ $OS == "Debian" ]]; then
  41. echo "APT Package Manager"
  42. sudo apt upgrade -y
  43. sudo apt-get update -y
  44. sudo apt-get install ffmpeg samba git net-tools unzip -y
  45. fi
  46. echo "Installing Web components from Jenkins..."
  47. wget $server/job/arozos/lastSuccessfulBuild/artifact/arozos_web_components.zip
  48. unzip arozos_web_components.zip
  49. echo "Creating ArozOS structure..."
  50. cd arozos
  51. sudo chmod 777 -R ./
  52. echo "Installing Core binary from Jenkins...."
  53. arch=$(uname -i)
  54. sysname=$(uname | tr '[:upper:]' '[:lower:]')
  55. echo "Your system is $sysname"
  56. if [[ $arch == "x86_64" ]]; then
  57. arch="i386"
  58. fi
  59. if [[ $arch == "unknown" ]]; then
  60. echo "Unknown CPU arch. Please enter CPU architecture manually (arm/arm64/amd64/i386/armv7/misple)"
  61. read -p "Architecture: " arch
  62. wget $server/job/arozos/lastSuccessfulBuild/artifact/arozos_$sysname\_$arch
  63. else
  64. wget $server/job/arozos/lastSuccessfulBuild/artifact/arozos_$sysname\_$arch
  65. fi
  66. mv arozos_$sysname\_$arch arozos
  67. printf "#%c/bin/bash\nsudo ./arozos -port 8080 -tls=true -tls_port 8443" ! | sudo tee -a ./start.sh
  68. echo "Setting up system services"
  69. sudo systemctl enable systemd-networkd.service systemd-networkd-wait-online.service
  70. cd /etc/systemd/system/
  71. username=$USER
  72. printf "[Unit]\nDescription=ArozOS Cloud Service\nAfter=systemd-networkd-wait-online.service\nWants=systemd-networkd-wait-online.service\n\n[Service]\nType=simple\nExecStartPre=/bin/sleep 10\nWorkingDirectory=/home/$username/arozos/\nExecStart=/bin/bash /home/$username/arozos/start.sh\n\nRestart=always\nRestartSec=10\n\n[Install]\nWantedBy=multi-user.target" | sudo tee -a ./arozos.service
  73. echo "Reloading daemon"
  74. sudo systemctl daemon-reload
  75. echo "Registering systemctl service"
  76. sudo systemctl start arozos.service
  77. echo "Starting arozos"
  78. sudo systemctl enable arozos.service
  79. thisip=$(hostname -I | cut -d' ' -f1)
  80. echo "Installation completed. Visit ArozOS web UI with http://$thisip:8080"