-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·107 lines (90 loc) · 3.05 KB
/
install.sh
File metadata and controls
executable file
·107 lines (90 loc) · 3.05 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# AddressTrackerBot v3 - Installer
set -e
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
NC='\033[0m'
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
echo ""
echo -e "${GREEN}AddressTrackerBot v3 - Installer${NC}"
echo ""
# Check for Python 3
if ! command -v python3 >/dev/null 2>&1; then
echo -e "${RED}Error:${NC} Python 3 is required but not installed."
echo "Install it with: sudo apt install python3 python3-venv python3-pip"
exit 1
fi
echo -e "${GREEN}Python 3 found:${NC} $(python3 --version)"
# Create virtual environment
if [ ! -d "$SCRIPT_DIR/venv" ]; then
echo -e "${YELLOW}Creating virtual environment...${NC}"
python3 -m venv "$SCRIPT_DIR/venv"
echo -e "${GREEN}Virtual environment created.${NC}"
else
echo -e "${GREEN}Virtual environment already exists.${NC}"
fi
# Install dependencies
echo -e "${YELLOW}Installing dependencies...${NC}"
"$SCRIPT_DIR/venv/bin/pip" install --upgrade pip -q
"$SCRIPT_DIR/venv/bin/pip" install -r "$SCRIPT_DIR/requirements.txt" -q
echo -e "${GREEN}Dependencies installed.${NC}"
# Setup .env file
if [ ! -f "$SCRIPT_DIR/.env" ]; then
echo ""
echo -e "${YELLOW}Setting up configuration...${NC}"
cp "$SCRIPT_DIR/.env.example" "$SCRIPT_DIR/.env"
read -p "Enter your Telegram Bot Token: " bot_token
read -p "Enter your Infura Project ID: " infura_id
sed -i "s|your_telegram_bot_token_here|$bot_token|" "$SCRIPT_DIR/.env"
sed -i "s|your_infura_project_id_here|$infura_id|" "$SCRIPT_DIR/.env"
echo -e "${GREEN}.env file created.${NC}"
else
echo -e "${GREEN}.env file already exists.${NC}"
fi
# Setup initial admin user
if [ ! -f "$SCRIPT_DIR/users.json" ]; then
echo ""
echo -e "${YELLOW}Setting up initial admin user...${NC}"
echo "You can find your Telegram chat ID by messaging @userinfobot on Telegram."
echo ""
read -p "Enter your Telegram username: " username
read -p "Enter your Telegram chat ID: " chat_id
cat > "$SCRIPT_DIR/users.json" << JSONEOF
{
"users": [
{
"username": "$username",
"chat_id": $chat_id
}
]
}
JSONEOF
echo -e "${GREEN}users.json created. This user will be migrated as admin.${NC}"
else
echo -e "${GREEN}users.json already exists.${NC}"
fi
# Run migration if upgrading from v2
if [ -f "$SCRIPT_DIR/addresses.json" ] || [ -f "$SCRIPT_DIR/users.json" ]; then
echo ""
echo -e "${YELLOW}Detected v2 data files. Running migration to SQLite...${NC}"
"$SCRIPT_DIR/venv/bin/python" "$SCRIPT_DIR/migrate.py"
echo -e "${GREEN}Migration complete.${NC}"
fi
# Create run script
cat > "$SCRIPT_DIR/run.sh" << 'RUNEOF'
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
"$SCRIPT_DIR/venv/bin/python" "$SCRIPT_DIR/main.py"
RUNEOF
chmod +x "$SCRIPT_DIR/run.sh"
echo ""
echo -e "${GREEN}Installation complete!${NC}"
echo ""
echo -e "To start the bot, run:"
echo -e " ${CYAN}./run.sh${NC}"
echo ""
echo -e "Or activate the venv manually:"
echo -e " ${CYAN}source venv/bin/activate && python3 main.py${NC}"
echo ""