-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·51 lines (40 loc) · 1.69 KB
/
start.sh
File metadata and controls
executable file
·51 lines (40 loc) · 1.69 KB
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
#!/bin/bash
# Go to the source directory
cd "$( dirname "${BASH_SOURCE[0]}" )"
# As a default, judge this run as not new
FIRST_RUN="no"
# Detect if it's actually the first run
if [ ! -e ./instance ]; then
INSTANCE_KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
echo $INSTANCE_KEY > ./instance
FIRST_RUN="yes"
fi
# Load the instance ID
INSTANCE_ID="zend-cconvert-$(cat ./instance)"
echo "Instance ID: $INSTANCE_ID";
if [ $FIRST_RUN = "yes" ]; then
grep -rl "zend-cconvert" . --exclude=.git --exclude=start.sh | xargs sed -i "s/zend-cconvert/$INSTANCE_ID/g"
fi
# Go into source directory
cd ./public/
if [ $FIRST_RUN = "yes" ]; then
PROJECT_SRC_BRANCH=$(git branch | grep \* | awk -F ' ' '{ print $2 }')
if [ $PROJECT_SRC_BRANCH != "master" ]; then
git checkout master
fi
fi
# pull the current branch
echo "Pulling latest changes to current branch: $(git branch | grep \* | awk -F ' ' '{ print $2 }')"
git pull origin $(git branch | grep \* | awk -F ' ' '{ print $2 }')
# Start it all up
docker-compose down --remove-orphans && docker-compose build && docker-compose up -d
# Pull using composer
docker exec -ti -u tafhim $INSTANCE_ID-php bash -c "cd /var/www/html/public && composer install"
# Run DB seeds and init
if [ $FIRST_RUN = "yes" ]; then
# Migrate db imports
echo "Running DB init scripts"
docker exec -ti -u tafhim $INSTANCE_ID-php bash -c "cd /var/www/html/public && php /var/www/html/public/vendor/robmorgan/phinx/bin/phinx migrate"
docker exec -ti -u tafhim $INSTANCE_ID-php bash -c "cd /var/www/html/public && php /var/www/html/public/vendor/robmorgan/phinx/bin/phinx seed:run"
fi
echo 'Setup complete! Go to: http://localhost:1234/'