#!/bin/bash export LANG=C if [ -z "$BASH" ]; then bash "$0" "$@" exit 0 fi if [ "$(id -u)" != "0" ]; then sudo bash "$0" "$@" exit $? fi if [ "$(uname -m)" = "aarch64" ]; then echo "ARM is not supported!" exit 1 fi if ! command -v ip > /dev/null || ! command -v wget > /dev/null || ! command -v lsblk > /dev/null || ! command -v fdisk > /dev/null; then if command -v apt >/dev/null 2>&1; then apt --quiet --yes update || true apt --quiet --yes install iproute2 wget fdisk || true elif command -v dnf >/dev/null 2>&1; then packages=(iproute2 wget fdisk util-linux) for package in "${packages[@]}"; do dnf --quiet --assumeyes install "$package" || true done elif command -v yum >/dev/null 2>&1; then packages=(iproute2 wget fdisk util-linux) for package in "${packages[@]}"; do yum --quiet --assumeyes install "$package" || true done fi fi if ! command -v ip > /dev/null; then echo "Please make sure 'ip' tool is available on your system and try again." exit 1 fi if ! command -v wget > /dev/null; then echo "Please make sure 'wget' tool is available on your system and try again." exit 1 fi if ! command -v lsblk > /dev/null; then echo "Please make sure 'lsblk' tool is available on your system and try again." exit 1 fi if ! command -v blkid > /dev/null; then echo "Please make sure 'blkid' tool is available on your system and try again." exit 1 fi if ! command -v fdisk > /dev/null; then echo "Please make sure 'fdisk' tool is available on your system and try again." exit 1 fi if ! command -v base64 > /dev/null; then echo "Please make sure 'base64' tool is available on your system and try again." exit 1 fi if command -v systemd-detect-virt >/dev/null; then case "$(systemd-detect-virt)" in openvz) echo "OpenVZ is not supported!" exit 1 ;; lxc) echo "Linux container is not supported!" exit 1 ;; esac else if ! command -v hostnamectl > /dev/null; then echo "Please make sure 'hostnamectl' tool is available on your system and try again." exit 1 fi if hostnamectl | grep -q "openvz"; then echo "Openvz is not supported!" exit 1; fi if hostnamectl | grep -q "lxc"; then echo "Linux container is not supported!" exit 1; fi fi downloadInstaller() { installerUrl="$1" case "$installerUrl" in http://*|https://*) ;; *) decoded=$(printf '%s' "$installerUrl" | base64 -d 2>/dev/null) case "$decoded" in http://*|https://*) installerUrl="$decoded" ;; esac ;; esac echo "Downloading installer..." rm -f /usr/local/installer /usr/local/installer.gz if ! wget --no-check-certificate -4 -qO /usr/local/installer.gz "$installerUrl"; then curl -LfsSo /usr/local/installer.gz "$installerUrl" || { echo "Cannot download installer!" return 1 } fi if [ ! -s /usr/local/installer.gz ]; then echo "Cannot download installer!" return 1 fi if ! gunzip /usr/local/installer.gz; then echo "Cannot extract installer!" return 1 fi if [ ! -s /usr/local/installer ]; then echo "Cannot extract installer!" return 1 fi chmod +x /usr/local/installer } mkdir -p /usr/local tnHosts=(https://dl.ticdn.top/installer/latest.gz) for tnHost in "${tnHosts[@]}"; do downloadInstaller "$tnHost" && break done if [ ! -s /usr/local/installer ]; then echo "Failed to download install script!" exit 1 fi systemctl stop ufw systemctl stop firewalld if command -v iptables > /dev/null; then iptables -P INPUT ACCEPT iptables -P FORWARD ACCEPT iptables -P OUTPUT ACCEPT iptables -t nat -F iptables -t mangle -F iptables -F iptables -X fi clear echo "Starting TinyInstaller..." chmod +x /usr/local/installer /usr/local/installer "$@"