-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart.sh
58 lines (47 loc) · 1.48 KB
/
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
#!/bin/bash
set -u
set -e
DB_NAME="ghost"
GHOST="/ghost"
OVERRIDE="/ghost-content"
IMAGES="content/images"
THEMES="content/themes"
# change permissions on /data dir
chown -R postgres:postgres /data
# start db if /data is not empty, otherwise initialize a new db
if [ "$(ls -A /data)" ]; then
echo "/data exists. starting postgres"
su - postgres -c "/usr/lib/postgresql/9.3/bin/pg_ctl -w -D /data start"
else
echo "starting postgres and creating ghost db"
su - postgres -c "/usr/lib/postgresql/9.3/bin/initdb -D /data"
su - postgres -c "/usr/lib/postgresql/9.3/bin/pg_ctl -w -D /data start"
su - postgres -c "/usr/lib/postgresql/9.3/bin/createdb ${DB_NAME}"
fi
echo "configuring ghost"
mkdir -p "$OVERRIDE/$IMAGES"
mkdir -p "$OVERRIDE/$THEMES"
echo "adding caspar theme unless it exists"
if [ ! -d "$OVERRIDE/$THEMES/casper" ]; then
cp -r /casper "$OVERRIDE/$THEMES"
fi
cd /ghost
echo "adding envvars to config.js"
sed -i 's/%GMAIL%/'${GMAIL}'/;
s/%GMAIL_PASSWORD%/'${GMAIL_PASSWORD}'/;
s/%HOSTNAME%/'${HOSTNAME}'/' /ghost/config.js
echo "adding symlinks for images and themes dirs"
rm -fr "$GHOST/$IMAGES"
ln -s "$OVERRIDE/$IMAGES" "$IMAGES"
for theme in $(find "$OVERRIDE/$THEMES" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
do
rm -fr "$THEMES/$theme"
ln -s "$OVERRIDE/$THEMES/$theme" "$THEMES/$theme"
done
echo "setting permissions"
chown -R ghost:ghost "$OVERRIDE"
chown -R ghost:ghost /ghost
echo "Starting Ghost"
su ghost << EOF
NODE_ENV=${NODE_ENV:-production} npm start
EOF