forked from dan-v/docker-ghost-ssl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ghostblog_start.sh
executable file
·82 lines (67 loc) · 2.35 KB
/
ghostblog_start.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
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Must give blog URL as parameter (e.g. https://test.com)"
exit 1
fi
ghostblog_url=$1
cd $(dirname $0)
. config.sh
check=$(docker logs ${ghostblog_container} > /dev/null 2>&1)
if [ $? -eq 0 ]; then
echo "Container ${ghostblog_container} is still running. Exiting."
exit 1
fi
check=$(docker logs ${ghostblog_proxy_container} > /dev/null 2>&1)
if [ $? -eq 0 ]; then
echo "Container ${ghostblog_proxy_container} is still running. Exiting."
exit 1
fi
if [ ! -f ${ssl_crt} ]; then
echo "Need to put SSL certificate at ${ssl_crt}. Exiting."
exit 1
fi
if [ ! -f ${ssl_key} ]; then
echo "Need to put SSL key at ${ssl_crt}. Exiting."
exit 1
fi
if [ ! -f ${nginx_conf} ]; then
echo "Need to nginx conf file at ${nginx_conf}. Exiting."
exit 1
fi
if [ ! -f ${ghost_config_file} ]; then
echo "Need Ghost ${ghost_config_file} file. Exiting."
exit 1
fi
echo "Pulling latest image ${ghostblog_image_name}"
pull=$(docker pull ${ghostblog_image_name} > /dev/null 2>&1)
if [ $? -ne 0 ]; then
echo "Failed to pull image ${ghostblog_image_name}. Exiting."
exit 1
fi
echo "Pulling latest image ${ghostblog_proxy_image_name}"
pull=$(docker pull ${ghostblog_proxy_image_name} > /dev/null 2>&1)
if [ $? -ne 0 ]; then
echo "Failed to pull image ${ghostblog_proxy_image_name}. Exiting."
exit 1
fi
echo "Updating ${ghost_config_file} with blog url ${ghostblog_url}"
sed -i "/url:/c\ \ \ \ \ \ \ \ url:\ '${ghostblog_url}', " ${ghost_config_file}
if [ $? -ne 0 ]; then
echo "Failed to update ${ghost_config_file}. Exiting."
exit 1
fi
echo "Starting container ${ghostblog_container_name}"
sleep 1
start=$(docker run -d -p 2368 --name ${ghostblog_container_name} -v $(pwd)/${ghost_data_folder}:/ghost-override ${ghostblog_image_name})
if [ $? -ne 0 ]; then
echo "Container ${ghostblog_container_name} failed to start. Exiting."
exit 1
fi
echo "Starting container ${ghostblog_proxy_container_name}"
sleep 1
start=$(docker run -d -p 80:80 -p 443:443 --name ${ghostblog_proxy_container_name} --link ${ghostblog_container_name}:${ghostblog_container_name} -v $(pwd)/${cert_folder}:/etc/nginx/certificates -v $(pwd)/${nginx_sites_folder}:/etc/nginx/sites-enabled ${ghostblog_proxy_image_name})
if [ $? -ne 0 ]; then
echo "Container ${ghostblog_proxy_image_name} failed to start. Exiting."
exit 1
fi
echo "Blog is now up and running.."