chore: clean publish artifacts and add sources
This commit is contained in:
119
install-prerequisites.sh
Executable file
119
install-prerequisites.sh
Executable file
@@ -0,0 +1,119 @@
|
||||
#!/bin/bash
|
||||
# Prerequisites Installation Script for New Server
|
||||
|
||||
echo "========================================="
|
||||
echo " Installing SkyArtShop Prerequisites"
|
||||
echo "========================================="
|
||||
echo ""
|
||||
|
||||
# Colors
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
|
||||
# Check if running as root
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo -e "${YELLOW}This script needs sudo privileges.${NC}"
|
||||
echo "It will prompt for password when needed."
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Update system
|
||||
echo -e "${YELLOW}[1/6] Updating system packages...${NC}"
|
||||
sudo apt update
|
||||
echo -e "${GREEN}✓ System updated${NC}"
|
||||
echo ""
|
||||
|
||||
# Install .NET 8.0
|
||||
echo -e "${YELLOW}[2/6] Installing .NET 8.0 SDK...${NC}"
|
||||
if command -v dotnet &> /dev/null; then
|
||||
echo -e "${GREEN}✓ .NET already installed: $(dotnet --version)${NC}"
|
||||
else
|
||||
wget https://dot.net/v1/dotnet-install.sh -O /tmp/dotnet-install.sh
|
||||
chmod +x /tmp/dotnet-install.sh
|
||||
/tmp/dotnet-install.sh --channel 8.0
|
||||
|
||||
# Add to PATH
|
||||
export DOTNET_ROOT=$HOME/.dotnet
|
||||
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools
|
||||
|
||||
# Add to bashrc for persistence
|
||||
if ! grep -q "DOTNET_ROOT" ~/.bashrc; then
|
||||
echo 'export DOTNET_ROOT=$HOME/.dotnet' >> ~/.bashrc
|
||||
echo 'export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools' >> ~/.bashrc
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✓ .NET 8.0 installed${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Install MongoDB
|
||||
echo -e "${YELLOW}[3/6] Installing MongoDB...${NC}"
|
||||
if command -v mongod &> /dev/null; then
|
||||
echo -e "${GREEN}✓ MongoDB already installed${NC}"
|
||||
else
|
||||
# Import MongoDB public key
|
||||
curl -fsSL https://pgp.mongodb.com/server-7.0.asc | sudo gpg --dearmor -o /usr/share/keyrings/mongodb-server-7.0.gpg
|
||||
|
||||
# Add MongoDB repository
|
||||
echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
|
||||
|
||||
# Install MongoDB
|
||||
sudo apt update
|
||||
sudo apt install -y mongodb-org
|
||||
|
||||
# Start and enable MongoDB
|
||||
sudo systemctl start mongod
|
||||
sudo systemctl enable mongod
|
||||
|
||||
echo -e "${GREEN}✓ MongoDB installed and started${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Install Nginx
|
||||
echo -e "${YELLOW}[4/6] Installing Nginx...${NC}"
|
||||
if command -v nginx &> /dev/null; then
|
||||
echo -e "${GREEN}✓ Nginx already installed${NC}"
|
||||
else
|
||||
sudo apt install -y nginx
|
||||
sudo systemctl enable nginx
|
||||
echo -e "${GREEN}✓ Nginx installed${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Install utilities
|
||||
echo -e "${YELLOW}[5/6] Installing utilities...${NC}"
|
||||
sudo apt install -y git curl wget unzip tar
|
||||
echo -e "${GREEN}✓ Utilities installed${NC}"
|
||||
echo ""
|
||||
|
||||
# Configure firewall
|
||||
echo -e "${YELLOW}[6/6] Configuring firewall...${NC}"
|
||||
if command -v ufw &> /dev/null; then
|
||||
sudo ufw allow 'Nginx Full'
|
||||
sudo ufw allow OpenSSH
|
||||
sudo ufw --force enable
|
||||
echo -e "${GREEN}✓ Firewall configured${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}⚠ UFW not available, skipping firewall configuration${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Verify installations
|
||||
echo "========================================="
|
||||
echo " ✅ INSTALLATION COMPLETE"
|
||||
echo "========================================="
|
||||
echo ""
|
||||
echo "Installed versions:"
|
||||
echo " .NET SDK: $(dotnet --version 2>/dev/null || echo 'Not found')"
|
||||
echo " MongoDB: $(mongod --version 2>/dev/null | head -1 | awk '{print $3}' || echo 'Not found')"
|
||||
echo " Nginx: $(nginx -v 2>&1 | cut -d'/' -f2 || echo 'Not found')"
|
||||
echo ""
|
||||
echo "Service status:"
|
||||
systemctl is-active --quiet mongod && echo -e " MongoDB: ${GREEN}Running${NC}" || echo -e " MongoDB: ${RED}Stopped${NC}"
|
||||
systemctl is-active --quiet nginx && echo -e " Nginx: ${GREEN}Running${NC}" || echo -e " Nginx: ${RED}Stopped${NC}"
|
||||
echo ""
|
||||
echo "You can now run the restoration script:"
|
||||
echo -e " ${YELLOW}bash migrate-restore.sh${NC}"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user