-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
142 lines (122 loc) · 3.5 KB
/
Copy pathinstall.sh
File metadata and controls
142 lines (122 loc) · 3.5 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
# VPS Manager Installation Script
# This script installs VPS Manager and its dependencies
set -e
echo "VPS Manager Installation Script"
echo "================================"
# Check if running as root
if [[ $EUID -eq 0 ]]; then
echo "This script should not be run as root. Please run as a regular user with sudo access."
exit 1
fi
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to install system packages
install_system_package() {
local package=$1
if command_exists apt; then
sudo apt update
sudo apt install -y "$package"
elif command_exists yum; then
sudo yum install -y "$package"
elif command_exists dnf; then
sudo dnf install -y "$package"
else
echo "Unsupported package manager. Please install $package manually."
return 1
fi
}
# Create virtual environment
echo "Creating Python virtual environment..."
python3 -m venv vps-manager-env
source vps-manager-env/bin/activate
# Upgrade pip
echo "Upgrading pip..."
pip install --upgrade pip
# Install Python dependencies
echo "Installing Python dependencies..."
pip install -r requirements.txt
# Install the package in development mode
echo "Installing VPS Manager..."
pip install -e .
# Check system dependencies
echo "Checking system dependencies..."
# Check NGINX
if ! command_exists nginx; then
echo "NGINX not found. Installing..."
install_system_package nginx
sudo systemctl enable nginx
sudo systemctl start nginx
else
echo "✓ NGINX is installed"
fi
# Check Certbot
if ! command_exists certbot; then
echo "Certbot not found. Installing..."
install_system_package certbot
if command_exists apt; then
install_system_package python3-certbot-nginx
fi
else
echo "✓ Certbot is installed"
fi
# Check UFW
if ! command_exists ufw; then
echo "UFW not found. Installing..."
install_system_package ufw
else
echo "✓ UFW is installed"
fi
# Check Docker (optional)
if ! command_exists docker; then
echo "Docker not found. Installing (optional)..."
install_system_package docker.io
sudo systemctl enable docker
sudo systemctl start docker
sudo usermod -aG docker $USER
echo "✓ Docker installed. You may need to log out and back in for group changes to take effect."
else
echo "✓ Docker is installed"
fi
# Run tests
echo "Running setup tests..."
if python test_setup.py; then
echo "✓ All tests passed!"
else
echo "✗ Some tests failed. Please check the output above."
exit 1
fi
# Create activation script
cat > activate_vps_manager.sh << 'EOF'
#!/bin/bash
# Activation script for VPS Manager environment
source vps-manager-env/bin/activate
echo "VPS Manager environment activated."
echo "Run 'vps-manager' to start the application."
EOF
chmod +x activate_vps_manager.sh
# Check if installation was successful
if command -v vps-manager &> /dev/null; then
echo ""
echo "✓ VPS Manager installed successfully!"
echo ""
echo "To activate the environment and run VPS Manager:"
echo " source activate_vps_manager.sh"
echo " vps-manager"
echo ""
echo "Or run directly:"
echo " source vps-manager-env/bin/activate && vps-manager"
echo ""
echo "For help:"
echo " vps-manager --help"
echo ""
echo "To check your environment:"
echo " vps-manager --check"
else
echo "✗ Installation failed. Please check the output above."
exit 1
fi
echo ""
echo "Installation complete! Run 'vps-manager' to start."