-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrun-ghost.sh
39 lines (31 loc) · 1.52 KB
/
run-ghost.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
#!/bin/sh
set -eo pipefail
if [[ "$*" == "node current/index.js" ]]; then
CONFIG="$GHOST_INSTALL/config.production.json"
if [ -f $GHOST_INSTALL/config.override.json ]; then
echo "Ghost override provided. Override the internal configuration"
cp $GHOST_INSTALL/config.override.json $GHOST_INSTALL/config.production.json
fi
# Set Config
if [ -z "$WEB_URL" ]; then
echo "WEB_URL is empty. Getting default: http://$(hostname -i):2368"
WEB_URL=http://$(hostname -i):2368
fi
echo "=> Change config based on ENV parameters:"
echo "========================================================================"
echo " WEB_URL: $WEB_URL"
echo "========================================================================"
sed -i "s|http://localhost:2368/|$WEB_URL|g" config.production.json
if [ -z "$(ls -A "$GHOST_CONTENT")" ]; then
echo "Missing content folder. Copying the default one..."
cp -r $GHOST_INSTALL/content.bck/* $GHOST_CONTENT
fi
if [ ! -s "$(awk '/"filename": "(.*)"/ {print $2}' $CONFIG | sed -e s/\"//g)" ]; then
echo "Empty database. Initializing..."
knex-migrator init --mgpath "$GHOST_INSTALL/current"
else
echo "Database already exists. Executing migration (if needed)"
knex-migrator migrate --mgpath "$GHOST_INSTALL/current"
fi
fi
exec "$@"