install.sh 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #!/bin/bash
  2. cat << "EOF"
  3. _ ___ ___ ___ __
  4. /_\ _ _ ___ ___/ _ \/ __| |_ ) / \
  5. / _ \| '_/ _ \_ / (_) \__ \ / / | () |
  6. /_/ \_\_| \___/__|\___/|___/ /___(_)__/
  7. ----- ArozOS 2.0 Installer -----
  8. EOF
  9. echo ""
  10. # Prompt the user to agree to the GPLv3 license
  11. read -p "Do you agree to the terms of the GPLv3 license? (y/n) " agree
  12. if [[ $agree != "y" ]]; then
  13. echo "You must agree to the GPLv3 license to use ArozOS."
  14. exit 1
  15. fi
  16. # Create the required folder structure to hold the installation
  17. cd ~/ || exit
  18. mkdir arozos
  19. cd arozos || exit
  20. # Run apt-updates
  21. sudo apt-get update
  22. sudo apt-get install ffmpeg net-tools -y
  23. # Determine the CPU architecture of the host
  24. if [[ $(uname -m) == "x86_64" ]]; then
  25. arch="amd64"
  26. elif [[ $(uname -m) == "aarch64" ]]; then
  27. arch="arm64"
  28. elif [[ $(uname -m) == "armv"* ]]; then
  29. arch="arm"
  30. else
  31. read -p "Enter the target architecture (e.g. darwin_amd64, windows_amd64): " arch
  32. fi
  33. # Download the corresponding executable from Github
  34. if [[ $arch == "amd64" ]]; then
  35. download_url="https://github.com/tobychui/arozos/releases/latest/download/arozos_linux_amd64"
  36. elif [[ $arch == "arm64" ]]; then
  37. download_url="https://github.com/tobychui/arozos/releases/latest/download/arozos_linux_arm64"
  38. elif [[ $arch == "arm" ]]; then
  39. download_url="https://github.com/tobychui/arozos/releases/latest/download/arozos_linux_arm"
  40. elif [[ $arch == "windows_amd64" ]]; then
  41. download_url="https://github.com/tobychui/arozos/releases/latest/download/arozos_windows_amd64.exe"
  42. elif [[ $arch == "windows_arm64" ]]; then
  43. download_url="https://github.com/tobychui/arozos/releases/latest/download/arozos_windows_arm64.exe"
  44. else
  45. download_url="https://github.com/tobychui/arozos/releases/latest/download/arozos_${arch}"
  46. fi
  47. # Download the arozos binary
  48. echo "Downloading Arozos from ${download_url} ..."
  49. wget -O arozos "${download_url}"
  50. chmod +x arozos
  51. # Download the webpack
  52. wget -O web.tar.gz "https://github.com/tobychui/arozos/releases/latest/download/web.tar.gz"
  53. # Check if the platform is supported for the launcher
  54. if [[ "$arch" == "amd64" || "$arch" == "arm" || "$arch" == "arm64" ]]; then
  55. # Ask if the user wants to install the launcher
  56. read -p "Do you want to install the Arozos launcher for OTA updates? [Y/n] " answer
  57. case ${answer:0:1} in
  58. y|Y )
  59. # Download the appropriate binary
  60. echo "Downloading Arozos launcher from https://github.com/aroz-online/launcher/releases/latest/ ..."
  61. case "$arch" in
  62. amd64)
  63. launcher_url="https://github.com/aroz-online/launcher/releases/latest/download/launcher_linux_amd64"
  64. ;;
  65. arm)
  66. launcher_url="https://github.com/aroz-online/launcher/releases/latest/download/launcher_linux_arm"
  67. ;;
  68. arm64)
  69. launcher_url="https://github.com/aroz-online/launcher/releases/latest/download/launcher_linux_arm64"
  70. ;;
  71. *)
  72. echo "Unsupported architecture for Arozos launcher"
  73. ;;
  74. esac
  75. if [[ -n "$launcher_url" ]]; then
  76. wget -O launcher "${launcher_url}"
  77. chmod +x launcher
  78. echo "Arozos launcher has been installed successfully!"
  79. fi
  80. ;;
  81. * )
  82. echo "Arozos launcher installation skipped"
  83. ;;
  84. esac
  85. fi
  86. # Ask for setup name
  87. read -p "Enter setup name (default: aroz): " arozosname
  88. arozosname=${arozosname:-aroz}
  89. # Ask for preferred listening port
  90. read -p "Enter preferred listening port (default: 8080): " arozport
  91. arozport=${arozport:-8080}
  92. # Check if launcher exists
  93. if [[ -f "./launcher" ]]; then
  94. # Create start.sh with launcher command
  95. echo "#!/bin/bash" > start.sh
  96. echo "sudo ./launcher -port=$arozport -hostname=\"$arozosname\"" >> start.sh
  97. else
  98. # Create start.sh with arozos command
  99. echo "#!/bin/bash" > start.sh
  100. echo "sudo arozos -port=$arozport -hostname=\"$arozosname\"" >> start.sh
  101. fi
  102. # Make start.sh executable
  103. chmod +x start.sh
  104. echo "Setup name: $arozosname"
  105. echo "Preferred listening port: $arozport"
  106. echo "start.sh created successfully!"
  107. # Ask if user wants to install ArozOS to systemd
  108. if [[ $(uname) == "Linux" ]]; then
  109. read -p "Do you want to install ArozOS to systemd service? (y/n)" -n 1 -r
  110. echo
  111. if [[ $REPLY =~ ^[Yy]$ ]]; then
  112. # Get current user
  113. CURRENT_USER=$(whoami)
  114. sudo touch /etc/systemd/system/arozos.service
  115. sudo chmod 777 /etc/systemd/system/arozos.service
  116. # Create systemd service file
  117. cat <<EOF > /etc/systemd/system/arozos.service
  118. [Unit]
  119. Description=ArozOS Cloud Service
  120. After=systemd-networkd-wait-online.service
  121. Wants=systemd-networkd-wait-online.service
  122. [Service]
  123. Type=simple
  124. ExecStartPre=/bin/sleep 10
  125. WorkingDirectory=/home/${CURRENT_USER}/arozos/
  126. ExecStart=/bin/bash /home/${CURRENT_USER}/arozos/start.sh
  127. Restart=always
  128. RestartSec=10
  129. [Install]
  130. WantedBy=multi-user.target
  131. EOF
  132. sudo chmod 644 /etc/systemd/system/arozos.service
  133. # Reload systemd daemon and enable service
  134. sudo systemctl daemon-reload
  135. sudo systemctl enable arozos.service
  136. sudo systemctl start arozos.service
  137. echo "ArozOS installation completed!"
  138. ip_address=$(hostname -I | awk '{print $1}')
  139. echo "Please continue the system setup at http://$ip_address:$arozport/"
  140. fi
  141. else
  142. echo "ArozOS installation completed! Execute start.sh to startup your ArozOS system."
  143. fi