-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathjoomla.cloudscript
More file actions
198 lines (154 loc) · 6.85 KB
/
joomla.cloudscript
File metadata and controls
198 lines (154 loc) · 6.85 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
# Install Joomla 3.3.6 on a CS1-SSD Cloudlet ($.015/hr) running Linux Ubuntu Server 14.04 LTS 64-bit
cloudscript joomla_single_stack
version = _latest
result_template = joomla_result_template
globals
joomla_hostname = 'joomla'
joomla_image_type = 'Ubuntu Server 14.04 LTS'
joomla_instance_type = 'CS1-SSD' # 1GB RAM, 1 vCore, 25GB SSD, 10Gbps
mysql_root_password = lib::random_password()
joomla_admin_password = lib::random_password()
default_slice_user = 'joomla'
joomla_db_name = 'joomla'
joomla_db_username = 'joomla'
joomla_db_password = lib::random_password()
server_password = lib::random_password()
console_password = lib::random_password()
thread joomla_setup
tasks = [joomla_server_setup]
task joomla_server_setup
#--------------------
# create joomla keys
#--------------------
# create joomla server root password key
/key/password joomla_server_password_key read_or_create
key_group = _SERVER
password = server_password
# create joomla server console key
/key/password joomla_server_console_key read_or_create
key_group = _CONSOLE
password = console_password
# create storage slice keys
/key/token default_slice_key read_or_create
username = default_slice_user
#-------------------------
# create joomla bootstrap
# script and recipe
#-------------------------
# create slice to store script in cloudstorage
/storage/slice default_slice read_or_create
keys = [default_slice_key]
# create slice container to store script in cloudstorage
/storage/container joomla_container => [default_slice] read_or_create
slice = default_slice
# place script data in cloudstorage
/storage/object joomla_bootstrap_object => [default_slice] read_or_create
container_name = 'joomla_container'
file_name = 'bootstrap_joomla.sh'
slice = default_slice
content_data = joomla_bootstrap_data
# associate the cloudstorage object with the joomla script
/orchestration/script joomla_bootstrap_script => [default_slice, joomla_container, joomla_bootstrap_object] read_or_create
data_uri = 'cloudstorage://default_slice/joomla_container/bootstrap_joomla.sh'
script_type = _SHELL
encoding = _STORAGE
# create the recipe and associate the script
/orchestration/recipe joomla_bootstrap_recipe read_or_create
scripts = [joomla_bootstrap_script]
#----------------------
# create joomla server
#----------------------
# create a new instance of joomla every time the cloudscript is run
/server/cloud joomla_server create_enumerate
hostname = '{{ joomla_hostname }}'
image = '{{ joomla_image_type }}'
service_type = '{{ joomla_instance_type }}'
keys = [joomla_server_password_key, joomla_server_console_key]
recipes = [joomla_bootstrap_recipe]
text_template joomla_bootstrap_data
#!/bin/sh
#-------------------------
# Install packages
#-------------------------
# get latest package list
apt-get update
# install apache2
apt-get install -y apache2
# let the user know joomla is coming
echo "Joomla is installing, please wait..." > /var/www/html/index.html
# prepare mysql preseed
echo "mysql-server-5.5 mysql-server/root_password password {{ mysql_root_password }}" > mysql.preseed
echo "mysql-server-5.5 mysql-server/root_password_again password {{ mysql_root_password }}" >> mysql.preseed
echo "mysql-server-5.5 mysql-server/start_on_boot boolean true" >> mysql.preseed
cat mysql.preseed | sudo debconf-set-selections
rm mysql.preseed
# install php/mysql packages
apt-get -y install mysql-server
apt-get -y install libapache2-mod-php5
apt-get -y install php5-mysql
# restart apache to use the modules
service apache2 restart
# get and install zip
apt-get -y install unzip
# download wordpress
wget -q -O /tmp/latest.zip https://github.com/joomla/joomla-cms/releases/download/3.3.6/Joomla_3.3.6-Stable-Full_Package.zip
# extract it and fix permissions
cd /var/www/html/
unzip /tmp/latest.zip > /dev/null
chown -R www-data:www-data /var/www/html/
#-------------------------
# Set MySQL Permissions
#-------------------------
echo "Doing perms"
cat <<\EOF>/tmp/create_accounts.mysql
INSERT INTO `jos_users` VALUES (62, 'Administrator', 'admin', 'nobody@amazon.com', MD5('{{ joomla_admin_password }}'), 'Super Administrator', 0, 1, '2012-01-01 00:00:00', '2012-01-01 00:00:00', '', '');
INSERT INTO `jos_user_usergroup_map` (`user_id`, `group_id`) VALUES (62,8);
EOF
cat <<\EOF>/tmp/setup.mysql
CREATE DATABASE {{ joomla_db_name }};
CREATE USER '{{ joomla_db_username }}'@'localhost' IDENTIFIED BY '{{ joomla_db_password }}';
GRANT ALL ON {{ joomla_db_name }}.* TO '{{ joomla_db_username }}'@'localhost';
FLUSH PRIVILEGES;
EOF
# run setup.mysql
echo "Running mysql"
mysql --user=root --password='{{ mysql_root_password }}' < /tmp/setup.mysql
# create joomla sql config
echo "Create joomla sql config"
sed -e 's/#__/jos_/g' < /var/www/html/installation/sql/mysql/joomla.sql > /var/www/html/joomla.sql
# run joomla sql config
echo "Load joomla sql config"
mysql {{ joomla_db_name }} --user="{{ joomla_db_username }}" --password="{{ joomla_db_password }}" < /var/www/html/joomla.sql
# create joomla accounts
echo "Create joomla sql accounts"
mysql {{ joomla_db_name }} --user="{{ joomla_db_username }}" --password="{{ joomla_db_password }}" < /tmp/create_accounts.mysql
#-----------------------------
# Create joomla config file
#-----------------------------
# create joomla config
echo "Create joomla php config"
sed -e "s/\$user = ''/\$user = '{{ joomla_db_username }}'/g" \
-e "s/\$password = ''/\$password = '{{ joomla_db_password }}'/g" \
-e "s/\$db = ''/\$db = '{{ joomla_db_name }}'/g" \
-e "s/\$live_site = 'joomla'/\$live_site = ''/g" \
< /var/www/html/installation/configuration.php-dist > /var/www/html/configuration.php
#-----------------------------
# Cleanup
#-----------------------------
echo "Doing cleanup"
# cleanup setup files
rm -f /tmp/setup.mysql
rm -f /tmp/create_accounts.mysql
rm -f /var/www/html/joomla.sql
rm -Rf /var/www/html/installation
rm -rf /var/www/html/index.html
_eof
text_template joomla_result_template
You can now access your Joomla administration site at the
following URL:
http://{{ joomla_server.ipaddress_public }}/administrator
You can login with the username 'admin' using the
password '{{ joomla_admin_password }}'. You can also
visit your public Joomla site at the following URL:
http://{{ joomla_server.ipaddress_public }}
_eof