-
Notifications
You must be signed in to change notification settings - Fork 1
/
install-sitebrush-in-docker.sh
75 lines (62 loc) · 2.65 KB
/
install-sitebrush-in-docker.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
#!/bin/bash
# Check if Docker is installed
if ! [ -x "$(command -v docker)" ]; then
echo "Docker is not installed. Would you like to install it? (y/n)"
read install_docker
if [ "$install_docker" = "y" ]; then
echo "Installing Docker..."
# Commands to install Docker (you can customize this based on your system)
# For example, on Ubuntu:
sudo apt-get update
sudo apt-get install -y docker.io
# For other systems, refer to Docker documentation: https://docs.docker.com/get-docker/
echo "Docker installed successfully."
else
echo "Aborted. Exiting..."
exit 1
fi
fi
# Default values
default_backup_dir="/backup/sitebrush"
default_mailhub="smtp.gmail.com:587"
default_email="[email protected]"
default_auth_user="[email protected]"
default_auth_pass="your_password"
default_host_port=80
# Interactively prompt for backup directory
read -p "Enter backup directory path (default: $default_backup_dir): " backup_dir
backup_dir=${backup_dir:-$default_backup_dir}
mkdir -p "${backup_dir}/mysql" "$backup_dir/data"
# Create Docker volumes
docker volume rm sitebrush_mysql_data sitebrush_site_data &> /dev/null
docker volume create --opt type=none --opt device="$backup_dir/mysql" --opt o=bind sitebrush_mysql_data
docker volume create --opt type=none --opt device="$backup_dir/data" --opt o=bind sitebrush_site_data
# Interactively prompt for SMTP settings
read -p "Enter SMTP server address and port (default: $default_mailhub): " mailhub
mailhub=${mailhub:-$default_mailhub}
read -p "Enter email address for sending notifications (default: $default_email): " email
email=${email:-$default_email}
read -p "Enter SMTP authentication user (default: $default_auth_user): " auth_user
auth_user=${auth_user:-$default_auth_user}
read -p "Enter SMTP authentication password (default: $default_auth_pass): " auth_pass
auth_pass=${auth_pass:-$default_auth_pass}
# Extract domain from email address
domain=$(echo "$email" | awk -F'@' '{print $2}')
# Interactively prompt for Docker port mapping
read -p "Enter host port for mapping to container port 80 (default: $default_host_port): " host_port
host_port=${host_port:-$default_host_port}
# Run Docker container with provided settings
docker run -d -p "$host_port:80" \
-v "/etc/timezone:/etc/timezone:ro" \
-v "/etc/localtime:/etc/localtime:ro" \
-v sitebrush_mysql_data:/var/lib/mysql \
-v sitebrush_site_data:/opt/sitebrush.com \
-e MAILHUB="$mailhub" \
-e EMAIL="$email" \
-e DOMAIN="$domain" \
-e AUTH_USER="$auth_user" \
-e AUTH_PASS="$auth_pass" \
--restart=unless-stopped \
--name=sitebrush \
matveynator/sitebrush-v1:latest
echo "SiteBrush container has been started."