install_latest_jenkins.sh 3.4 KB

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