-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·63 lines (52 loc) · 2.41 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·63 lines (52 loc) · 2.41 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
#!/bin/bash
# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${BLUE}======================================================${NC}"
echo -e "${BLUE} Udjat (AI Anti-Phishing) Installer ${NC}"
echo -e "${BLUE}======================================================${NC}"
# Check for Node.js
if ! command -v node > /dev/null 2>&1 || ! command -v npm > /dev/null 2>&1; then
echo -e "${YELLOW}Warning: Node.js or npm is not installed.${NC}"
read -p "Would you like to install Node.js (v22 LTS) now? (Requires sudo) [Y/n]: " install_node
install_node=${install_node:-Y}
if [[ "$install_node" =~ ^[Yy]$ ]]; then
echo -e "${GREEN}Installing Node.js v22 LTS...${NC}"
if ! command -v curl > /dev/null 2>&1; then
echo -e "${YELLOW}curl not found. Attempting to install curl...${NC}"
sudo apt-get update && sudo apt-get install -y curl
fi
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs
if ! command -v node > /dev/null 2>&1; then
echo -e "${RED}Failed to install Node.js. Please install it manually from https://nodejs.org/${NC}"
exit 1
fi
echo -e "${GREEN}Node.js installed successfully!${NC}"
else
echo -e "${RED}Cannot proceed without Node.js. Please install it manually from https://nodejs.org/${NC}"
exit 1
fi
else
echo -e "${GREEN}Node.js is already installed. Proceeding...${NC}"
fi
echo -e "\n${GREEN}[1/3] Preparing the backend directory...${NC}"
cd "$(dirname "$0")/backend" || { echo -e "${RED}Error: 'backend' folder not found${NC}"; exit 1; }
echo -e "\n${GREEN}[2/3] Downloading and installing dependencies...${NC}"
echo -e "${YELLOW}(This may take a few seconds depending on your connection)${NC}"
npm install
echo -e "\n${GREEN}[3/3] Configuration Wizard...${NC}"
# If config doesn't exist, run the setup
if [ ! -f ".env" ]; then
npm run setup
else
echo -e "${YELLOW}A configuration file (.env) already exists. Keeping it intact.${NC}"
fi
echo -e "\n${BLUE}======================================================${NC}"
echo -e "${GREEN}✔ Installation completed successfully!${NC}"
echo -e "${BLUE}======================================================${NC}"
echo -e "Starting the protection server (Press Ctrl+C to stop)...\n"
npm start