Facebook
From ss, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 141
  1. #!/bin/sh
  2.  
  3. #############################
  4. # Linux Installation #
  5. #############################
  6.  
  7. # Define the root directory to /home/runner.
  8. # We can only write in /home/runner and /tmp in the runner/RDP.
  9. ROOTFS_DIR=$(pwd)
  10.  
  11. export PATH=$PATH:~/.local/usr/bin
  12.  
  13.  
  14. max_retries=50
  15. timeout=1
  16.  
  17.  
  18. # Detect the machine architecture.
  19. ARCH=$(uname -m)
  20.  
  21. # Check machine architecture to make sure it is supported.
  22. # If not, we exit with a non-zero status code.
  23. if [ "$ARCH" = "x86_64" ]; then
  24.   ARCH_ALT=amd64
  25. elif [ "$ARCH" = "aarch64" ]; then
  26.   ARCH_ALT=arm64
  27. else
  28.   printf "Unsupported CPU architecture: ${ARCH}"
  29.   exit 1
  30. fi
  31.  
  32. # Download & decompress the Linux root file system if not already installed.
  33.  
  34. if [ ! -e $ROOTFS_DIR/.installed ]; then
  35. echo "#######################################################################################"
  36. echo "#"
  37. echo "#                                  Biralo Gaming"
  38. echo "#"
  39. echo "#                           Copyright (C) 2022 - 2023, VPSFREE.ES"
  40. echo "#"
  41. echo "#"
  42. echo "#######################################################################################"
  43. echo ""
  44. echo "* [0] Debian   - "
  45. echo "* [1] Ubuntu  - RDP Support"
  46. echo "* [2] Alpine    - "
  47.  
  48. read -p "Enter OS (0-3): " input
  49.  
  50. case $input in
  51.  
  52.     0)
  53.     wget --tries=$max_retries --timeout=$timeout --no-hsts -O /tmp/rootfs.tar.xz \
  54.     "https://github.com/termux/proot-distro/releases/download/v3.10.0/debian-${ARCH}-pd-v3.10.0.tar.xz"
  55.     apt download xz-utils
  56.     deb_file=$(find $ROOTFS_DIR -name "*.deb" -type f)
  57.     dpkg -x $deb_file ~/.local/
  58.     rm "$deb_file"
  59.  
  60.     tar -xJf /tmp/rootfs.tar.xz -C $ROOTFS_DIR;;
  61.  
  62.     1)
  63.     wget --tries=$max_retries --timeout=$timeout --no-hsts -O /tmp/rootfs.tar.gz \
  64.     "http://cdimage.ubuntu.com/ubuntu-base/releases/20.04/release/ubuntu-base-20.04.4-base-${ARCH_ALT}.tar.gz"
  65.  
  66.     tar -xf /tmp/rootfs.tar.gz -C $ROOTFS_DIR;;
  67.  
  68.     2)
  69.     wget --tries=$max_retries --timeout=$timeout --no-hsts -O /tmp/rootfs.tar.gz \
  70.     "https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-minirootfs-3.18.3-${ARCH}.tar.gz"
  71.  
  72.     tar -xf /tmp/rootfs.tar.gz -C $ROOTFS_DIR;;
  73.  
  74.  
  75. esac
  76.  
  77. fi
  78.  
  79. ################################
  80. # Package Installation & Setup #
  81. ################################
  82.  
  83. # Download static APK-Tools temporarily because minirootfs does not come with APK pre-installed.
  84. if [ ! -e $ROOTFS_DIR/.installed ]; then
  85.     # Download the packages from their sources
  86.     mkdir $ROOTFS_DIR/usr/local/bin -p
  87.  
  88.     wget --tries=$max_retries --timeout=$timeout --no-hsts -O $ROOTFS_DIR/usr/local/bin/proot "https://raw.githubusercontent.com/dxomg/vpsfreepterovm/main/proot-${ARCH}"
  89.  
  90.   while [ ! -s "$ROOTFS_DIR/usr/local/bin/proot" ]; do
  91.       rm $ROOTFS_DIR/usr/local/bin/proot -rf
  92.       wget --tries=$max_retries --timeout=$timeout --no-hsts -O $ROOTFS_DIR/usr/local/bin/proot "https://raw.githubusercontent.com/dxomg/vpsfreepterovm/main/proot-${ARCH}"
  93.  
  94.       if [ -s "$ROOTFS_DIR/usr/local/bin/proot" ]; then
  95.           # Make PRoot executable.
  96.           chmod 755 $ROOTFS_DIR/usr/local/bin/proot
  97.           break  # Exit the loop since the file is not empty
  98.       fi
  99.  
  100.       chmod 755 $ROOTFS_DIR/usr/local/bin/proot
  101.       sleep 1  # Add a delay before retrying to avoid hammering the server
  102.   done
  103.  
  104.   chmod 755 $ROOTFS_DIR/usr/local/bin/proot
  105.  
  106. fi
  107.  
  108. # Clean-up after installation complete & finish up.
  109. if [ ! -e $ROOTFS_DIR/.installed ]; then
  110.     # Add DNS Resolver nameservers to resolv.conf.
  111.     printf "nameserver 1.1.1.1\nnameserver 1.0.0.1" > ${ROOTFS_DIR}/etc/resolv.conf
  112.     # Wipe the files we downloaded into /tmp previously.
  113.     rm -rf /tmp/rootfs.tar.xz /tmp/sbin
  114.     # Create .installed to later check whether Alpine is installed.
  115.     touch $ROOTFS_DIR/.installed
  116. fi
  117.  
  118. # Print some useful information to the terminal before entering PRoot.
  119. # This is to introduce the user with the various Alpine Linux commands.
  120. # Define color variables
  121. BLACK='\\e[0;30m'
  122. BOLD_BLACK='\\e[1;30m'
  123. RED='\\e[0;31m'
  124. BOLD_RED='\\e[1;31m'
  125. GREEN='\\e[0;32m'
  126. BOLD_GREEN='\\e[1;32m'
  127. YELLOW='\\e[0;33m'
  128. BOLD_YELLOW='\\e[1;33m'
  129. BLUE='\\e[0;34m'
  130. BOLD_BLUE='\\e[1;34m'
  131. MAGENTA='\\e[0;35m'
  132. BOLD_MAGENTA='\\e[1;35m'
  133. CYAN='\\e[0;36m'
  134. BOLD_CYAN='\\e[1;36m'
  135. WHITE='\\e[0;37m'
  136. BOLD_WHITE='\\e[1;37m'
  137.  
  138. # Reset text color
  139. RESET_COLOR='\\e[0m'
  140.  
  141.  
  142. # Function to display the header
  143. display_header() {
  144.     echo -e "${BOLD_MAGENTA}            Biralo Gaming"
  145.     echo -e "${BOLD_MAGENTA}               Sub"
  146.     echo -e "${BOLD_MAGENTA}___________________________________________________"
  147.     echo -e "           ${YELLOW}-----&gt; System Resources <----${RESET_COLOR}"
  148.     echo -e ""
  149. }
  150.  
  151. # Function to display system resources
  152. display_resources() {
  153.     echo -e " INSTALLER OS -> ${RED} $(cat /etc/os-release | grep "PRETTY_NAME" | cut -d'"' -f2) ${RESET_COLOR}"
  154.     echo -e ""
  155.     echo -e " CPU -> ${YELLOW} $(lscpu | grep 'Model name' | cut -d':' -f2- | sed 's/^ *//;s/  \+/ /g') ${RESET_COLOR}"
  156.     echo -e " RAM -> ${BOLD_GREEN}${SERVER_MEMORY}MB${RESET_COLOR}"
  157.     echo -e " PRIMARY PORT -> ${BOLD_GREEN}${SERVER_PORT}${RESET_COLOR}"
  158.     echo -e " EXTRA PORTS -> ${BOLD_GREEN}${P_SERVER_ALLOCATION_LIMIT}${RESET_COLOR}"
  159.     echo -e " SERVER UUID -> ${BOLD_GREEN}${P_SERVER_UUID}${RESET_COLOR}"
  160.     echo -e " LOCATION -> ${BOLD_GREEN}${P_SERVER_LOCATION}${RESET_COLOR}"
  161. }
  162.  
  163. display_footer() {
  164.     echo -e "${BOLD_MAGENTA}___________________________________________________${RESET_COLOR}"
  165.     echo -e ""
  166.     echo -e "           ${YELLOW}-----&gt; VPS HAS STARTED <----${RESET_COLOR}"
  167. }
  168.  
  169. # Main script execution
  170. clear
  171.  
  172. display_header
  173. display_resources
  174. display_footer
  175.  
  176.  
  177. ###########################
  178. # Start PRoot environment #
  179. ###########################
  180.  
  181. # This command starts PRoot and binds several important directories
  182. # from the host file system to our special root file system.
  183. $ROOTFS_DIR/usr/local/bin/proot \
  184. --rootfs="${ROOTFS_DIR}" \
  185. -0 -w "/root" -b /dev -b /sys -b /proc -b /etc/resolv.conf --kill-on-exit