-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathinstall.sh
More file actions
84 lines (70 loc) · 2.52 KB
/
install.sh
File metadata and controls
84 lines (70 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
# Define paths
INSTALL_DIR="$HOME/.programs/termai"
BIN_DIR="$PREFIX/bin"
SOURCE_FILE="termai.py"
# Colors
BLUE="\033[1;34m"
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
RED="\033[1;31m"
RESET="\033[0m"
echo -e "${BLUE}[+] Starting Termai Installer...${RESET}"
# 1. Install Dependencies
echo -e "${YELLOW}[*] Installing dependencies (python, requests)...${RESET}"
# Check if requests is installed before trying to install it
if ! pip show requests &> /dev/null; then
echo " 'requests' not found. Installing..."
pip install requests &> /dev/null
else
echo " 'requests' is already installed."
fi
# 2. Create Hidden Program Directory
echo -e "${YELLOW}[*] Creating installation directory: $INSTALL_DIR${RESET}"
mkdir -p "$INSTALL_DIR"
# 4. Move Source Code
if [ -f "$SOURCE_FILE" ]; then
cp "$SOURCE_FILE" "$INSTALL_DIR/"
echo " Source copied."
else
echo -e "${RED}[!] Error: $SOURCE_FILE not found in current folder.${RESET}"
exit 1
fi
# 5. Create Binary Alias ('ai')
echo -e "${YELLOW}[*] Creating 'ai' command in $BIN_DIR...${RESET}"
echo '#!/bin/bash' > "$BIN_DIR/ai"
echo "python \"$INSTALL_DIR/$SOURCE_FILE\" \"\$@\"" >> "$BIN_DIR/ai"
chmod +x "$BIN_DIR/ai"
# 6. Verify Installation
if command -v ai &> /dev/null; then
echo -e "${GREEN}[✓] Termai installed successfully!${RESET}"
echo " Type 'ai \"hello\"' to start."
echo " Type 'ai --help' to see commands."
else
echo -e "${RED}[!] Installation failed. 'ai' command not found.${RESET}"
exit 1
fi
# 7. Safe Cleanup (Interactive)
echo ""
echo -e "${BLUE}[?] Do you want to delete this installation folder to save space?${RESET}"
echo -e " (This deletes the repo you just cloned, NOT the installed tool)"
read -p " Delete? [y/N]: " confirm
if [[ "$confirm" =~ ^[yY]$ ]]; then
CURRENT_DIR_NAME=$(basename "$PWD")
# Enable case-insensitive matching
shopt -s nocasematch
# SAFETY CHECK: Only delete if the folder is named 'termai' (case-insensitive)
if [[ "$CURRENT_DIR_NAME" == "termai" ]]; then
echo -e "${YELLOW}[*] Cleaning up...${RESET}"
cd ..
rm -rf "$CURRENT_DIR_NAME"
echo -e "${GREEN}[✓] Cleaned up. Enjoy Termai!${RESET}"
else
echo -e "${RED}[!] Safety Stop: Current folder is named '$CURRENT_DIR_NAME', not 'termai'.${RESET}"
echo " Cleanup aborted to prevent accidental deletion of wrong files."
fi
# Disable case-insensitive matching
shopt -u nocasematch
else
echo -e "${GREEN}[✓] Setup complete. Files kept.${RESET}"
fi