github.com/bepass-org/wireguard-go@v1.0.4-rc2.0.20240304192354-ebce6572bc24/termux.sh (about)

     1  #!/bin/bash
     2  
     3  # Colors
     4  red='\033[0;31m'
     5  green='\033[0;32m'
     6  yellow='\033[0;33m'
     7  blue='\033[0;34m'
     8  purple='\033[0;35m'
     9  cyan='\033[0;36m'
    10  rest='\033[0m'
    11  
    12  # Check Dependencies build
    13  check_dependencies_build() {
    14      local dependencies=("curl" "wget" "git" "golang")
    15  
    16      for dep in "${dependencies[@]}"; do
    17          if ! dpkg -s "${dep}" &> /dev/null; then
    18              echo -e "${yellow}${dep} is not installed. Installing...${rest}"
    19              pkg install "${dep}" -y
    20          fi
    21      done
    22  }
    23  
    24  # Check Dependencies
    25  check_dependencies() {
    26      local dependencies=("curl" "openssl-tool" "wget" "unzip")
    27  
    28      for dep in "${dependencies[@]}"; do
    29          if ! dpkg -s "${dep}" &> /dev/null; then
    30              echo -e "${yellow}${dep} is not installed. Installing...${rest}"
    31              pkg install "${dep}" -y
    32          fi
    33      done
    34  }
    35  
    36  # Build
    37  build() {
    38      if command -v warp &> /dev/null || command -v usef &> /dev/null; then
    39          echo -e "${green}Warp is already installed.${rest}"
    40          return
    41      fi
    42  
    43      echo -e "${green}Installing Warp...${rest}"
    44      pkg update -y && pkg upgrade -y
    45      check_dependencies_build
    46  
    47      if git clone https://github.com/bepass-org/wireguard-go.git &&
    48          cd wireguard-go &&
    49          go build main.go &&
    50          chmod +x main &&
    51          cp main "$PREFIX/bin/usef" &&
    52          cp main "$PREFIX/bin/warp"; then
    53          echo -e "${green}Warp installed successfully.${rest}"
    54      else
    55          echo -e "${red}Error installing WireGuard VPN.${rest}"
    56      fi
    57  }
    58  
    59  # Install
    60  install() {
    61      if command -v warp &> /dev/null || command -v usef &> /dev/null; then
    62          echo -e "${green}Warp is already installed.${rest}"
    63          return
    64      fi
    65  
    66      echo -e "${green}Installing Warp...${rest}"
    67      pkg update -y && pkg upgrade -y
    68      pacman -Syu openssh = apt update; apt full-upgrade -y; apt install -y openssh
    69      check_dependencies
    70  
    71      if wget https://github.com/bepass-org/wireguard-go/releases/download/v1.0.1-rc1/warp-android-arm64.9f90b7.zip &&
    72          unzip warp-android-arm64.9f90b7.zip &&
    73          chmod +x warp &&
    74          cp warp "$PREFIX/bin/usef" &&
    75          cp warp "$PREFIX/bin/warp"; then
    76          rm "README.md" "LICENSE" "warp-android-arm64.9f90b7.zip"
    77          echo "================================================"
    78          echo -e "${green}Warp installed successfully.${rest}"
    79          socks
    80      else
    81          echo -e "${red}Error installing Warp.${rest}"
    82      fi
    83  }
    84  
    85  # Install arm
    86  install_arm() {
    87      if command -v warp &> /dev/null || command -v usef &> /dev/null; then
    88          echo -e "${green}Warp is already installed.${rest}"
    89          return
    90      fi
    91  
    92      echo -e "${green}Installing Warp...${rest}"
    93      pkg update -y && pkg upgrade -y
    94      pacman -Syu openssh = apt update; apt full-upgrade -y; apt install -y openssh
    95      check_dependencies
    96  
    97      # Determine architecture
    98      case "$(dpkg --print-architecture)" in
    99          i386) ARCH="386" ;;
   100          amd64) ARCH="amd64" ;;
   101          armhf) ARCH="arm5" ;;
   102          arm) ARCH="arm7" ;;
   103          aarch64) ARCH="arm64" ;;
   104          *) echo -e "${red}Unsupported architecture.${rest}"; return ;;
   105      esac
   106  
   107      WARP_URL="https://github.com/bepass-org/wireguard-go/releases/download/v1.0.1-rc1/warp-linux-$ARCH.9f90b7.zip"
   108  
   109      if wget "$WARP_URL" &&
   110          unzip "warp-linux-$ARCH.9f90b7.zip" &&
   111          chmod +x warp &&
   112          cp warp "$PREFIX/bin/usef" &&
   113          cp warp "$PREFIX/bin/warp"; then
   114          rm "README.md" "LICENSE" "warp-linux-$ARCH.9f90b7.zip"
   115          echo "================================================"
   116          echo -e "${green}Warp installed successfully.${rest}"
   117          socks
   118      else
   119          echo -e "${red}Error installing Warp.${rest}"
   120      fi
   121  }
   122  
   123  # Get socks config
   124  socks() {
   125     echo ""
   126     echo -e "${yellow}Copy this Config to ${purple}V2ray${green} Or ${purple}Nekobox ${yellow}and Exclude Termux${rest}"
   127     echo "================================================"
   128     echo -e "${green}socks://Og==@127.0.0.1:8086#warp_(usef)${rest}"
   129     echo "or"
   130     echo -e "${green}Manually create a SOCKS configuration with IP ${purple}127.0.0.1 ${green}and port${purple} 8086..${rest}"
   131     echo "================================================"
   132     echo -e "${yellow}To run again, type:${green} warp ${rest}or${green} usef ${rest}or${green} ./warp${rest}"
   133     echo "================================================"
   134     echo -e "${green} If you get a 'Bad address' error, run ${yellow}[Arm]${rest}"
   135     echo ""
   136  }
   137  
   138  #Uninstall
   139  uninstall() {
   140      warp="$PREFIX/bin/warp"
   141      directory="/data/data/com.termux/files/home/wireguard-go"
   142      home="/data/data/com.termux/files/home"
   143      if [ -f "$warp" ]; then
   144          rm -rf "$directory" "$PREFIX/bin/usef" "wa.py" "$PREFIX/bin/warp" "$home/wgcf-profile.ini" "$home/warp" "$home/stuff" "$home/wgcf-identity.json" > /dev/null 2>&1
   145          echo -e "${red}Uninstallation completed.${rest}"
   146      else
   147          echo -e "${yellow} ____________________________________${rest}"
   148          echo -e "${red} Not installed.Please Install First.${rest}${yellow}|"
   149          echo -e "${yellow} ____________________________________${rest}"
   150      fi
   151  }
   152  
   153  # Warp to Warp plus
   154  warp_plus() {
   155      if ! command -v python &> /dev/null; then
   156          echo "Installing Python..."
   157          pkg install python -y
   158      fi
   159  
   160      echo -e "${green}Downloading and running${purple} Warp+ script...${rest}"
   161      wget -O wa.py https://raw.githubusercontent.com/Ptechgithub/configs/main/wa.py
   162      python wa.py
   163  }
   164  
   165  # Menu
   166  menu() {
   167      clear
   168      echo -e "${green}By --> Peyman * Github.com/Ptechgithub * ${rest}"
   169      echo ""
   170      echo -e "${yellow}❤️Github.com/${cyan}bepass-org${yellow}/wireguard-go❤️${rest}"
   171      echo -e "${purple}*********************************${rest}"
   172      echo -e "${blue}     ###${cyan} Warp in Termux ${blue}###${rest}   ${purple}  * ${rest}"
   173      echo -e "${purple}*********************************${rest}"
   174      echo -e "${cyan}1)${rest} ${green}Install Warp (vpn)${purple}           * ${rest}"
   175      echo -e "                              ${purple}  * ${rest}"
   176      echo -e "${cyan}2)${rest} ${green}Install Warp (vpn) [${yellow}Arm${green}] ${purple}    * ${rest}"
   177      echo -e "                              ${purple}  * ${rest}"
   178      echo -e "${cyan}3)${rest} ${green}Uninstall${rest}${purple}                    * ${rest}"
   179      echo -e "                              ${purple}  * ${rest}"
   180      echo -e "${cyan}4)${rest} ${green}Warp to ${purple}Warp plus${green} [${yellow}Free GB${green}]${rest}${purple}  * ${rest}"
   181      echo -e "                              ${purple}  * ${rest}"
   182      echo -e "${cyan}5)${rest} ${green}Build (warp)${purple}                 * ${rest}"
   183      echo -e "                              ${purple}  * ${rest}"
   184      echo -e "${red}0)${rest} ${green}Exit                         ${purple}* ${rest}"
   185      echo -e "${purple}*********************************${rest}"
   186  }
   187  
   188  # Main
   189  menu
   190  read -p "Please enter your selection [0-5]:" choice
   191  
   192  case "$choice" in
   193     1)
   194          install
   195          warp
   196          ;;
   197      2)
   198          install_arm
   199          warp
   200          ;;
   201      3)
   202          uninstall
   203          ;;
   204      4)
   205          warp_plus
   206          ;;
   207      5)
   208          build
   209          ;;
   210      0)
   211          echo -e "${cyan}Exiting...${rest}"
   212          exit
   213          ;;
   214      *)
   215          echo "Invalid choice. Please select a valid option."
   216          ;;
   217  esac