forked from nephoscale/cloudscript
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsugarcrm.cloudscript
More file actions
204 lines (166 loc) · 6.32 KB
/
sugarcrm.cloudscript
File metadata and controls
204 lines (166 loc) · 6.32 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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# Install SugarCRM 6.5.20 on a CS1-SSD Cloudlet ($.015/hr) running Linux Ubuntu Server 14.04 LTS 64-bit
cloudscript sugarcrm
version = _latest
result_template = sugarcrm_result_template
globals
sugarcrm_hostname = 'sugarcrm'
sugarcrm_instance_type = 'CS1-SSD' # 1GB RAM, 1 vCore, 25GB SSD, 10Gbps
sugarcrm_image_type = 'Ubuntu Server 14.04 LTS'
sugarcrm_version = 'SugarCE-6.5.20.zip'
server_password = lib::random_password()
console_password = lib::random_password()
sugarcrm_db_password = lib::random_password()
sugarcrm_db_name = 'sugarcrm'
sugarcrm_db_username = 'sugarcrm'
sugarcrm_slice_user = 'sugarcrmsliceuser'
thread core
tasks = [install]
task install
#-----------------------
# create wordpress keys
#-----------------------
/key/password sugarcrm_server_key read_or_create
key_group = _SERVER
password = server_password
/key/password sugarcrm_console_key read_or_create
key_group = _CONSOLE
password = console_password
#----------------------------
# create sugarcrm bootstrap
# script and recipe
#----------------------------
# storage slice key
/key/token sugarcrm_slice_key read_or_create
username = sugarcrm_slice_user
# slice
/storage/slice sugarcrm_slice read_or_create
keys = [sugarcrm_slice_key]
# slice container
/storage/container sugarcrm_container => [sugarcrm_slice] read_or_create
slice = sugarcrm_slice
# store script as object in cloudstorage
/storage/object install_sugarcrm_script_object => [sugarcrm_slice, sugarcrm_container] read_or_create
container_name = 'sugarcrm_container'
file_name = 'install_sugarcrm.sh'
slice = sugarcrm_slice
content_data = install_sugarcrm_sh
# associate the cloudstorage object with the sugarcrm script
/orchestration/script install_sugarcrm_script => [sugarcrm_slice, sugarcrm_container, install_sugarcrm_script_object] read_or_create
data_uri = 'cloudstorage://sugarcrm_slice/sugarcrm_container/install_sugarcrm.sh'
script_type = _SHELL
encoding = _STORAGE
# create the recipe and associate the script
/orchestration/recipe install_sugarcrm_recipe read_or_create
scripts = [install_sugarcrm_script]
#------------------------
# create sugarcrm server
#------------------------
/server/cloud sugarcrm_server read_or_create
hostname = '{{ sugarcrm_hostname }}'
image = '{{ sugarcrm_image_type }}'
service_type = '{{ sugarcrm_instance_type }}'
keys = [sugarcrm_server_key, sugarcrm_console_key]
recipes = [install_sugarcrm_recipe]
text_template install_sugarcrm_sh
#!/bin/bash
#
# install sugarcrm service
#
# check permissions
[ `whoami` = 'root' ] || {
echo "ERROR: must have root permissions to execute the commands"
exit 1
}
apt-get update > /dev/null
[ $? -eq 0 ] && echo "OK: update local apt cache" || {
echo "ERROR: update local apt cache"
exit 1
}
# install unzip
apt-get install -y unzip > /dev/null
[ $? -eq 0 ] && echo "OK: install unzip" || {
echo "ERROR: install unzip"
exit 1
}
# install MySQL
DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server mysql-client > /dev/null
[ $? -eq 0 ] && echo "OK: install MySQL" || {
echo "ERROR: install MySQL"
exit 1
}
# install Apache2
DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 > /dev/null
[ $? -eq 0 ] && echo "OK: install Apache2" || {
echo "ERROR: install Apache2"
exit 1
}
# install PHP5
apt-get install -y php5 php5-cli libapache2-mod-php5 > /dev/null
[ $? -eq 0 ] && echo "OK: install PHP5" || {
echo "ERROR: install PHP5"
exit 1
}
# install required PHP5 modules
apt-get install -y php5-mysql php5-memcache php5-curl php5-gd php5-imap > /dev/null
[ $? -eq 0 ] && echo "OK: install PHP5 modules" || {
echo "ERROR: install PHP5 modules"
exit 1
}
# update php.ini
sed 's/^variables_order.*$/variables_order = "EGPCS"/' -i /etc/php5/apache2/php.ini
sed 's/^upload_max_filesize.*/upload_max_filesize = 10M/g' -i /etc/php5/apache2/php.ini
# enable PHP5 module
a2enmod php5 > /dev/null
# download sugarcrm source
cd /var/www/html/
wget -O sugarce.zip "http://sourceforge.net/projects/sugarcrm/files/1%20-%20SugarCRM%206.5.X/SugarCommunityEdition-6.5.X/{{ sugarcrm_version }}/download" > /dev/null 2>&1
[ $? -eq 0 ] && echo "OK: download sugarcrm source" || {
echo "ERROR: download sugarcrm source"
exit 1
}
# extract sugarcrm files
unzip sugarce.zip > /dev/null
[ $? -eq 0 ] && echo "OK: extract sugarcrm files" || {
echo "ERROR: extract sugarcrm files"
exit 1
}
# move sugarcrm files
mv ./Sugar* ./sugarcrm
[ $? -eq 0 ] && echo "OK: move sugarcrm files" || {
echo "ERROR: move sugarcrm files"
exit 1
}
# set ownership & permissions
chown -R www-data:www-data /var/www/html/sugarcrm
[ $? -eq 0 ] && echo "OK: set required permissions" || {
echo "ERROR: set required permissions"
exit 1
}
# create MySQL database & user
mysql <<EOF
create database {{ sugarcrm_db_name }};
grant all on {{ sugarcrm_db_name }}.* to {{ sugarcrm_db_username }}@localhost identified by '{{ sugarcrm_db_password }}';
EOF
[ $? -eq 0 ] && echo "OK: create sugarcrm database and user" || {
echo "ERROR: create sugarcrm database and user"
exit 1
}
# enable mod_rewrite
a2enmod rewrite > /dev/null 2>&1
# restart web server
service apache2 restart > /dev/null 2>&1
echo "OK: install sugarcrm service"
_eof
text_template sugarcrm_result_template
Thank you for provisioning a SugarCRM service.
You can now finish its configuration on the following page:
http://{{ sugarcrm_server.ipaddress_public }}/sugarcrm/install.php
Please use following credentials for database configuration:
hostname: localhost
username: {{ sugarcrm_db_username }}
password: {{ sugarcrm_db_password }}
database: {{ sugarcrm_db_name }}
You can also login to the server directly via SSH by connecting to:
root@{{ sugarcrm_server.ipaddress_public }}
using the password: {{ sugarcrm_server_key.password }}
_eof