-
Notifications
You must be signed in to change notification settings - Fork 13
/
deploy
executable file
·70 lines (60 loc) · 2.19 KB
/
deploy
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
#!/bin/bash
# This deploy hook gets executed after dependencies are resolved and the
# build hook has been run but before the application has been started back
# up again. This script gets executed directly, so it could be python, php,
# ruby, etc.
source $OPENSHIFT_CARTRIDGE_SDK_BASH
set -e
echo "Setting environment variables..."
export APP_ENV="${APPLICATION_ENV:-production}"
if [[ "${APPLICATION_ENV:-}" != "development" ]]; then
export APP_DEBUG=false
else
export APP_DEBUG=true
fi
if [ "$(type -t set_env_var)" == "function" ]; then
set_env_var 'APP_ENV' $APP_ENV $OPENSHIFT_HOMEDIR/.env/user_vars
set_env_var 'APP_DEBUG' $APP_DEBUG $OPENSHIFT_HOMEDIR/.env/user_vars
fi
if [ ! -z "$OPENSHIFT_APP_DNS" ]; then
export APP_URL="$OPENSHIFT_APP_DNS"
if [ "$(type -t set_env_var)" == "function" ]; then
set_env_var 'APP_URL' $APP_URL $OPENSHIFT_HOMEDIR/.env/user_vars
fi
fi
if [ ! -z "$OPENSHIFT_SECRET_TOKEN" ]; then
export APP_KEY=${OPENSHIFT_SECRET_TOKEN:0:31}
if [ "$(type -t set_env_var)" == "function" ]; then
set_env_var 'APP_KEY' $APP_KEY $OPENSHIFT_HOMEDIR/.env/user_vars
fi
fi
if [ ! -z "$OPENSHIFT_POSTGRESQL_DB_HOST" ]; then
export DB_CONNECTION="pgsql"
fi
if [ ! -z "$OPENSHIFT_MYSQL_DB_HOST" ]; then
export DB_CONNECTION="mysql"
fi
if [ -z "$DB_CONNECTION" ]; then
echo "Could not find the database cartridge. Please run:"
echo "rhc cartridge add -a $OPENSHIFT_APP_NAME -c mysql-5.5"
echo "or"
echo "rhc cartridge add -a $OPENSHIFT_APP_NAME -c postgresql-9.2"
echo "then make a sample commit (add whitespace somewhere) and re-push"
exit 5
else
echo "Database driver set to '$DB_CONNECTION'..."
if [ "$(type -t set_env_var)" == "function" ]; then
set_env_var 'DB_CONNECTION' $DB_CONNECTION $OPENSHIFT_HOMEDIR/.env/user_vars
fi
fi
# Use repository .env
if [ -f ${OPENSHIFT_REPO_DIR}/.openshift/tmpl/.env.tmpl ]; then
echo "Creating enviroments settings file '.env' ..."
cp -f ${OPENSHIFT_REPO_DIR}/.openshift/tmpl/.env.tmpl ${OPENSHIFT_REPO_DIR}/.env
else
echo "Enviroments settings file '.env' not found ..."
fi
echo "Running 'php artisan migrate --force'..."
pushd ${OPENSHIFT_REPO_DIR} > /dev/null
php artisan migrate --force
popd > /dev/null