-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphase2.sh
executable file
·51 lines (42 loc) · 1.2 KB
/
phase2.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
#!/bin/bash
set -o errexit
set -o nounset
DEBUG=true
SCRIPTDIR="$(dirname "$0")"
if [ -v USE_ENV_CONFIG ]; then
echo "Using environment configuration. Make sure that all variables from config.sh are set in .env file of proper environment settings."
else
if [ -f "$SCRIPTDIR"/config.sh ]; then
echo "Using configuration from file"
source "$SCRIPTDIR"/config.sh
else
echo "ERROR: please create a config.sh file"
exit 10
fi
fi
if [ -f "$SCRIPTDIR"/functions.sh ]; then
source "$SCRIPTDIR"/functions.sh
else
echo "ERROR: functions.sh missing"
exit 10
fi
if [ $# -ne 2 ] && [ $# -ne 3 ]; then
echo "ERROR: Usage: $0 <sitename> <email>"
exit 10
fi
SITENAME=$(echo "$1" | tr -d ' ')
USEREMAIL=$(echo "$2" | tr -d ' ')
if [ $# -eq 3 ]; then
PROFILE=$(echo "$3" | tr -d ' ')
fi
DBNAME=${SITENAME//\./_}
DBNAME=${DBNAME//\-/_}
VHOST="/etc/apache2/sites-available/$SITENAME.conf"
# only allow root to run this script - because of special sudo rights and permissions
if [[ "$USER" != "root" ]]; then
echo "ERROR: Run with sudo or as root"
exit 10
fi
phase_2 $SITENAME
# Print successful status in the end of the line.
echo "complete_status:{\"provisioning_state\": \"completed\", \"status\": 1}"