-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubsite_create.sh
executable file
·63 lines (54 loc) · 1.44 KB
/
subsite_create.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
52
53
54
55
56
57
58
59
60
61
62
63
#!/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
validate_sitename "$SITENAME"
validate_email "$USEREMAIL"
check_existence_create "$SITENAME"
init "$SITENAME"
create_db "$DBNAME"
create_dirs
create_vhost
add_to_hosts "$SITENAME"
install_drupal
set_permissions
add_to_crontab
add_subsiteadmin
transfer_base_files
# Print successful status in the end of the line.
echo "complete_status:{\"provisioning_state\": \"completed\", \"status\": 1}"