-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path10-init-neos
executable file
·98 lines (86 loc) · 2.59 KB
/
10-init-neos
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
#!/usr/bin/with-contenv /bin/bash
set -ex
# Layout default directory structure\
mkdir -p /data/logs
mkdir -p /data/tmp/nginx
###
# Initial provisioning
###
/provision-neos.sh
# On first launch unpack provisioned files into /data/www
if [ -f /data/www/composer.json ] || [ -z "$REPOSITORY_URL" ]
then
echo "Do nothing, provisioned files were already moved"
else
if [ -d /data/www/ ]
then
echo "/data/www/ has probably been locally mounted. Moving provisioned files into it."
# Move files our from /data/www/, in case there's already something partially mounted (e.g. a locally mounted package folder)
rsync -a /data/www-provisioned/ /data/www/
else
echo "Symlink /data/www/ to provisioned files"
ln -s /data/www-provisioned /data/www
fi
fi
if [ -z "$DEVELOPMENT" ]
then
echo "Production mode on, no destructive provisioning allowed"
else
###
# Check if DB already exists and is not empty
###
set +e
RESULT=`mysql -u $DB_USER -p$DB_PASS -h $DB_HOST -e "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema ='${DB_DATABASE}'" --batch --skip-column-names`
set -e
if [[ $RESULT -gt 0 ]];
then
echo "Database already exists, skipping DB import"
else
###
# Import DB dump from AWS
###
if [ -z "$AWS_BACKUP_ARN" ]
then
echo "AWS_BACKUP_ARN not set, skipping"
else
if [ -z "$AWS_ENDPOINT" ]
then
aws s3 cp ${AWS_BACKUP_ARN}db.sql /data/www/Data/Persistent/db.sql
else
aws s3 --endpoint-url=$AWS_ENDPOINT cp ${AWS_BACKUP_ARN}db.sql /data/www/Data/Persistent/db.sql
fi
fi
###
# Create and import DB
###
echo "CREATE DATABASE IF NOT EXISTS $DB_DATABASE" | mysql -u $DB_USER -p$DB_PASS -h $DB_HOST
if [ -f /data/www/Data/Persistent/db.sql ]
then
mysql -u $DB_USER -p$DB_PASS -h $DB_HOST $DB_DATABASE < /data/www/Data/Persistent/db.sql
fi
cd /data/www
sudo -u www-data /data/www/flow doctrine:migrate
if [ -z "$SITE_PACKAGE" ]
then
echo "SITE_PACKAGE not set"
else
sudo -u www-data /data/www/flow site:import --package-key=$SITE_PACKAGE
fi
if [ -z "$ADMIN_PASSWORD" ]
then
echo "No ADMIN_PASSWORD set"
else
sudo -u www-data /data/www/flow user:create --roles='Administrator' --username='admin' --password=$ADMIN_PASSWORD --first-name='UpdateMe' --last-name='Now'
fi
if [ -z "$DONT_PUBLISH_PERSISTENT" ]
then
sudo -u www-data /data/www/flow resource:publish
fi
fi
fi
if [ "$(ls -A /data/www/Web/_Resources/Static/)" ]
then
echo "No need to publish static resources"
else
sudo -u www-data /data/www/flow resource:publish --collection static
fi