-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlinux_setup.sh
98 lines (85 loc) · 3.06 KB
/
linux_setup.sh
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
#!/bin/bash
# Function to install Docker on Linux
install_docker() {
echo "[INFO] Docker not found. Attempting to install Docker..."
# Update package database and install Docker
sudo apt-get update
sudo apt-get install -y docker.io
# Start Docker service
echo "[INFO] Starting Docker service..."
sudo systemctl start docker
sudo systemctl enable docker
# Add the current user to the Docker group (requires re-login to take effect)
sudo usermod -aG docker $USER
# Wait for Docker to be available
echo "[INFO] Waiting for Docker to start..."
while ! docker info &> /dev/null; do
echo "[INFO] Docker not ready yet. Retrying in 2 seconds..."
sleep 2
done
echo "[INFO] Docker is now available."
# Verify Docker installation
if command -v docker &> /dev/null; then
echo "[INFO] Docker installed successfully."
else
echo "[ERROR] Docker installation failed. Please install it manually and try again."
exit 1
fi
}
# Check if Docker is installed; if not, install it
if ! command -v docker &> /dev/null; then
install_docker
else
echo "[INFO] Docker is already installed."
fi
# Ensure Docker Compose is installed
if ! command -v docker-compose &> /dev/null; then
echo "[INFO] Docker Compose not found. Installing Docker Compose..."
sudo apt-get install -y docker-compose
if ! command -v docker-compose &> /dev/null; then
echo "[ERROR] Docker Compose installation failed. Please install it manually and try again."
exit 1
fi
else
echo "[INFO] Docker Compose is installed."
fi
# Function to pull images from Docker Hub
pull_images() {
echo "[INFO] Pulling pre-built images from Docker Hub..."
docker pull bspsupsi/sleepyland:gui
docker pull bspsupsi/sleepyland:manager-api
docker pull bspsupsi/sleepyland:usleepyland
docker pull bspsupsi/sleepyland:notebook
docker pull bspsupsi/sleepyland:nsrr-download
docker pull bspsupsi/sleepyland:wild-to-fancy
if [ $? -eq 0 ]; then
echo "[INFO] Docker images pulled successfully."
else
echo "[ERROR] Failed to pull Docker images. Please check your internet connection or Docker Hub access."
exit 1
fi
}
force_pull=true
# Pull Docker images if there were changes in the repository
if [ "$force_pull" = true ]; then
pull_images
else
echo "[INFO] No Docker images pull required."
fi
# Start Docker containers with --force-recreate
echo "[INFO] Starting Docker containers with forced recreation..."
docker compose -f docker-compose.yml -p sleepyland up -d --force-recreate
if [ $? -eq 0 ]; then
echo "[INFO] Docker containers started successfully."
else
echo "[ERROR] Failed to start Docker containers."
exit 1
fi
# Open the web interface in the default browser
echo "[INFO] Opening the web interface in the default browser..."
if xdg-open "http://localhost:8887" &> /dev/null; then
echo "[INFO] Web interface opened successfully."
else
echo "[ERROR] Failed to open the web interface. Please check your default browser settings."
exit 1
fi