install.sh 5.6 KB

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