Skip to content

Commit bf2c7af

Browse files
authored
Update setup script for Tool-X installation process
1 parent f8a9c40 commit bf2c7af

1 file changed

Lines changed: 74 additions & 50 deletions

File tree

setup.sh

Lines changed: 74 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,126 @@
11
#!/bin/bash
22
# Author: Lokesh Kumar
3-
# Update: 08/03/2026
4-
# setup.sh
3+
# Update: 28/03/2026
4+
# Project: Tool-X Universal Installer
55

66
TOOL_DIR="$HOME/tool-x"
77
REPO_URL="https://github.com/trmxvibs/Tool-X"
88
INSTALLER_SCRIPT="tool-x.py"
9-
ALIAS_NAME="Tool-x"
109

11-
# Define colors
10+
# User-friendly command variations (Case-insensitivity)
11+
COMMANDS=("toolx" "Toolx" "Tool-x" "tool-x")
12+
13+
# Colors for UI
1214
GREEN='\033[1;32m'
1315
YELLOW='\033[1;33m'
1416
RED='\033[1;31m'
1517
NC='\033[0m'
1618

1719
echo -e "\n${GREEN}[*] Initializing Tool-X Universal Setup...${NC}"
1820

19-
# >> Step 1: Detect Environment & Install Dependencies ---
21+
# --- STEP 1: Advanced OS & Package Manager Detection ---
2022
echo -e "${YELLOW}[*] Detecting Operating System and Package Manager...${NC}"
2123

2224
if [ -d "$PREFIX" ] && grep -q "com.termux" "$PREFIX/etc/bash.bashrc" 2>/dev/null; then
23-
IS_TERMUX=true
25+
# 1. Termux (Android)
26+
OS_TYPE="termux"
27+
BIN_DIR="$PREFIX/bin"
2428
echo -e "${GREEN}[+] Environment: Termux Detected.${NC}"
25-
pkg update -y
26-
pkg install git python -y
29+
pkg update -y && pkg install git python -y
30+
31+
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then
32+
# 2. Windows (Git Bash / MSYS2)
33+
OS_TYPE="windows"
34+
echo -e "${GREEN}[+] Environment: Windows Detected.${NC}"
35+
# Windows users need to have Git and Python installed manually
36+
37+
elif [[ "$OSTYPE" == "darwin"* ]]; then
38+
# 3. macOS
39+
OS_TYPE="macos"
40+
BIN_DIR="/usr/local/bin"
41+
echo -e "${GREEN}[+] Environment: macOS (Homebrew) Detected.${NC}"
42+
if command -v brew >/dev/null; then
43+
brew install git python
44+
else
45+
echo -e "${RED}[!] Homebrew not found. Please install Homebrew first.${NC}"
46+
fi
47+
2748
else
28-
IS_TERMUX=false
29-
#>> Smart Package Manager Detection for Linux/Mac
49+
# 4. Linux Distributions (Debian, Ubuntu, Kali, Parrot, Arch, Manjaro, BlackArch, Fedora, RedHat)
50+
OS_TYPE="linux"
51+
BIN_DIR="/usr/local/bin"
52+
3053
if command -v apt-get >/dev/null; then
3154
echo -e "${GREEN}[+] Environment: Debian/Ubuntu/Kali/Parrot Detected.${NC}"
32-
sudo apt-get update -y
33-
sudo apt-get install git python3 python3-pip -y
55+
sudo apt-get update -y && sudo apt-get install git python3 python3-pip -y
3456
elif command -v pacman >/dev/null; then
3557
echo -e "${GREEN}[+] Environment: Arch/Manjaro/BlackArch Detected.${NC}"
3658
sudo pacman -Sy --noconfirm git python python-pip
3759
elif command -v dnf >/dev/null; then
3860
echo -e "${GREEN}[+] Environment: Fedora/RedHat Detected.${NC}"
3961
sudo dnf install -y git python3 python3-pip
40-
elif command -v brew >/dev/null; then
41-
echo -e "${GREEN}[+] Environment: macOS (Homebrew) Detected.${NC}"
42-
brew install git python
4362
else
44-
echo -e "${YELLOW}[!] Package manager not recognized (Windows/GitBash?). Please install Git and Python manually.${NC}"
63+
echo -e "${RED}[!] Unknown Linux Distro. Attempting manual dependency check...${NC}"
4564
fi
4665
fi
4766

48-
# >>> Step 2: Install Python Requirements ---
67+
# --- STEP 2: Python Libraries Setup ---
4968
echo -e "\n${YELLOW}[*] Installing Python Libraries (Rich UI)...${NC}"
50-
# >>break-system-packages is used for newer Python versions (PEP 668)
69+
# Handling PEP 668 for newer Linux distros
5170
pip install rich requests beautifulsoup4 --break-system-packages 2>/dev/null || pip install rich requests beautifulsoup4
5271

53-
# >> Step 3: Clone or Update Repository ---
72+
# --- STEP 3: Clone or Update Tool-X ---
5473
if [ -d "$TOOL_DIR" ]; then
55-
echo -e "\n${YELLOW}[*] Updating Tool-X...${NC}"
74+
echo -e "\n${YELLOW}[*] Updating Tool-X Repository...${NC}"
5675
cd "$TOOL_DIR" || exit
5776
git pull
5877
else
59-
echo -e "\n${GREEN}[*] Cloning Tool-X...${NC}"
78+
echo -e "\n${GREEN}[*] Cloning Tool-X Repository...${NC}"
6079
git clone "$REPO_URL" "$TOOL_DIR"
6180
cd "$TOOL_DIR" || exit
6281
fi
63-
6482
chmod +x "$INSTALLER_SCRIPT" 2>/dev/null || true
6583

66-
# >> Step 4: Smart Alias Setup (Handles bash and zsh) ---
67-
echo -e "\n${YELLOW}[*] Setting up shortcut command...${NC}"
84+
# --- STEP 4: Centralization (The Global Shortcut Logic) ---
85+
echo -e "\n${YELLOW}[*] Centralizing Commands for Global Access...${NC}"
6886

69-
if [ "$IS_TERMUX" = true ]; then
70-
SHELL_RC="$PREFIX/etc/bash.bashrc"
71-
else
72-
# Check if user is using zsh (Default in Kali & Mac)
73-
if [ "$(basename "$SHELL")" = "zsh" ]; then
74-
SHELL_RC="$HOME/.zshrc"
75-
else
76-
SHELL_RC="$HOME/.bashrc"
77-
fi
78-
fi
87+
if [ "$OS_TYPE" == "windows" ]; then
88+
# Windows CMD/PowerShell Support (.bat files)
89+
for cmd in "${COMMANDS[@]}"; do
90+
echo "@echo off" > "$TOOL_DIR/$cmd.bat"
91+
echo "python \"$TOOL_DIR/$INSTALLER_SCRIPT\" %*" >> "$TOOL_DIR/$cmd.bat"
92+
done
93+
# Git Bash Support (Linux-like wrapper in ~/bin)
94+
mkdir -p "$HOME/bin"
95+
for cmd in "${COMMANDS[@]}"; do
96+
echo "python \"$TOOL_DIR/$INSTALLER_SCRIPT\" \"\$@\"" > "$HOME/bin/$cmd"
97+
chmod +x "$HOME/bin/$cmd"
98+
done
99+
echo -e "${GREEN}[+] Windows Batch and Bash wrappers created.${NC}"
79100

80-
if [ -f "$SHELL_RC" ]; then
81-
ALIAS_CMD="alias $ALIAS_NAME='python $TOOL_DIR/$INSTALLER_SCRIPT'"
82-
83-
if grep -q "alias $ALIAS_NAME=" "$SHELL_RC"; then
84-
echo -e "${YELLOW}[!] Alias '$ALIAS_NAME' already exists in $SHELL_RC.${NC}"
85-
else
86-
echo -e "\n# Tool-X Alias" >> "$SHELL_RC"
87-
echo "$ALIAS_CMD" >> "$SHELL_RC"
88-
echo -e "${GREEN}[+] Shortcut '$ALIAS_NAME' added to $SHELL_RC${NC}"
89-
fi
90101
else
91-
echo -e "${YELLOW}[!] Shell config file not found. Run tool manually: python $TOOL_DIR/$INSTALLER_SCRIPT${NC}"
102+
# Linux, macOS, and Termux (Global binary creation)
103+
SUDO_CMD=""
104+
[ "$OS_TYPE" != "termux" ] && SUDO_CMD="sudo"
105+
106+
for cmd in "${COMMANDS[@]}"; do
107+
WRAPPER="#!/bin/bash\npython3 \"$TOOL_DIR/$INSTALLER_SCRIPT\" \"\$@\""
108+
if [ "$OS_TYPE" == "termux" ]; then
109+
echo -e "$WRAPPER" > "$BIN_DIR/$cmd"
110+
chmod +x "$BIN_DIR/$cmd"
111+
else
112+
echo -e "$WRAPPER" | $SUDO_CMD tee "$BIN_DIR/$cmd" > /dev/null
113+
$SUDO_CMD chmod +x "$BIN_DIR/$cmd"
114+
fi
115+
done
116+
echo -e "${GREEN}[+] Centralized commands created in $BIN_DIR${NC}"
92117
fi
93118

94119
echo -e "\n${GREEN}========================================${NC}"
95-
echo -e "${GREEN} Setup Complete! Type: $ALIAS_NAME ${NC}"
120+
echo -e "${GREEN} Setup Complete! Type: toolx ${NC}"
96121
echo -e "${GREEN}========================================${NC}"
122+
echo -e "${YELLOW}Supported Commands: ${NC}${COMMANDS[*]}"
97123

98-
if [ "$IS_TERMUX" = true ]; then
99-
echo -e "${YELLOW}Please restart Termux to apply changes.${NC}"
100-
else
101-
echo -e "${YELLOW}Please restart your terminal or type: source $SHELL_RC${NC}"
124+
if [ "$OS_TYPE" == "windows" ]; then
125+
echo -e "\n${RED}[!] Windows Note:${NC} Add '$TOOL_DIR' to your System PATH to use commands in CMD."
102126
fi

0 commit comments

Comments
 (0)