-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmacos_setup.sh
112 lines (94 loc) · 3.5 KB
/
macos_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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# Function to install Docker on macOS
install_docker() {
echo "[INFO] Docker not found. Attempting to install Docker..."
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
echo "[INFO] Architecture detected: amd64 (x86_64)"
DOCKER_URL="https://desktop.docker.com/mac/main/amd64/Docker.dmg"
elif [ "$ARCH" = "arm64" ]; then
echo "[INFO] architecture detected: arm64"
DOCKER_URL="https://desktop.docker.com/mac/main/arm64/Docker.dmg"
fi
# Download Docker Desktop for Mac using curl and open the downloaded file
curl -o ~/Downloads/Docker.dmg "$DOCKER_URL"
# Mount the DMG
hdiutil attach ~/Downloads/Docker.dmg
# Copy Docker to the Applications folder
echo "[INFO] Installing Docker. This may require your password."
sudo cp -R /Volumes/Docker/Docker.app /Applications
# Unmount the DMG
hdiutil detach /Volumes/Docker
# Cleanup the downloaded file
rm ~/Downloads/Docker.dmg
# Start Docker
echo "[INFO] Starting Docker for the first time. Please wait..."
open /Applications/Docker.app
# 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."
# Check if Docker is now installed
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 (Docker Desktop includes Docker Compose)
if ! command -v docker-compose &> /dev/null; then
echo "[ERROR] Docker Compose is required. It should be included with Docker Desktop."
exit 1
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 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