Skip to content

Commit 8e90f45

Browse files
committed
refactor: enhance dependency installation process in installation script
1 parent 9d0afe0 commit 8e90f45

1 file changed

Lines changed: 33 additions & 7 deletions

File tree

Home/Scripts/Install.sh

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,45 @@ echo ""
2323
# Check for required dependencies
2424
echo -e "${YELLOW}Checking dependencies...${NC}"
2525

26+
# Detect package manager
27+
install_package() {
28+
if command -v apt-get &> /dev/null; then
29+
sudo apt-get update -y && sudo apt-get install -y "$@"
30+
elif command -v yum &> /dev/null; then
31+
sudo yum install -y "$@"
32+
elif command -v dnf &> /dev/null; then
33+
sudo dnf install -y "$@"
34+
elif command -v pacman &> /dev/null; then
35+
sudo pacman -Sy --noconfirm "$@"
36+
else
37+
echo -e "${RED}Error: Could not detect package manager. Please install $* manually.${NC}"
38+
exit 1
39+
fi
40+
}
41+
2642
if ! command -v git &> /dev/null; then
27-
echo -e "${RED}Error: git is not installed. Please install git first.${NC}"
28-
exit 1
43+
echo -e "${YELLOW}git is not installed. Installing git...${NC}"
44+
install_package git
2945
fi
3046

31-
if ! command -v npm &> /dev/null; then
32-
echo -e "${RED}Error: npm is not installed. Please install Node.js and npm first.${NC}"
33-
exit 1
47+
if ! command -v node &> /dev/null || ! command -v npm &> /dev/null; then
48+
echo -e "${YELLOW}Node.js/npm is not installed. Installing Node.js and npm...${NC}"
49+
if command -v apt-get &> /dev/null || command -v yum &> /dev/null || command -v dnf &> /dev/null; then
50+
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
51+
install_package nodejs
52+
elif command -v pacman &> /dev/null; then
53+
install_package nodejs npm
54+
else
55+
echo -e "${RED}Error: Could not install Node.js automatically. Please install Node.js and npm manually.${NC}"
56+
exit 1
57+
fi
3458
fi
3559

3660
if ! command -v docker &> /dev/null; then
37-
echo -e "${RED}Error: docker is not installed. Please install Docker first.${NC}"
38-
exit 1
61+
echo -e "${YELLOW}Docker is not installed. Installing Docker...${NC}"
62+
curl -fsSL https://get.docker.com | sh
63+
sudo systemctl start docker
64+
sudo systemctl enable docker
3965
fi
4066

4167
echo -e "${GREEN}All dependencies are installed.${NC}"

0 commit comments

Comments
 (0)