-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathphpbb.cloudscript
More file actions
205 lines (167 loc) · 6.02 KB
/
phpbb.cloudscript
File metadata and controls
205 lines (167 loc) · 6.02 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
205
# Install phpBB 3.1.2 on a CS1-SSD Cloudlet ($.015/hr) running Linux Ubuntu Server 14.04 LTS 64-bit
cloudscript phpbb
version = _latest
result_template = phpbb_result_template
globals
phpbb_hostname = 'phpbb'
phpbb_instance_type = 'CS1-SSD' # 1GB RAM, 1 vCore, 25GB SSD, 10Gbps
phpbb_image_type = 'Ubuntu Server 14.04 LTS'
# Check for new version here: https://www.phpbb.com/files/release/
phpbb_version = 'phpBB-3.1.2'
# passwords setup
server_password = lib::random_password()
console_password = lib::random_password()
phpbb_db_password = lib::random_password()
phpbb_db_name = 'phpbb'
phpbb_db_username = 'phpbb'
default_slice_user = 'phpbb'
thread phpbb_setup
tasks = [phpbb_server_setup]
task phpbb_server_setup
#-------------------
# Create phpbb keys
#-------------------
# Create phpbb server root password key
/key/password phpbb_server_password_key read_or_create
key_group = _SERVER
password = server_password
# Create phpbb server console key
/key/password phpbb_server_console_key read_or_create
key_group = _CONSOLE
password = console_password
#-----------------------------
# Create phpbb storage slice,
# bootstrap script and recipe
#-----------------------------
# Create storage slice keys
/key/token default_slice_key read_or_create
username = default_slice_user
# 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 phpbb_container => [default_slice] read_or_create
slice = default_slice
# Place script data in cloudstorage
/storage/object phpbb_bootstrap_object => [default_slice, phpbb_container] read_or_create
container_name = 'phpbb_container'
file_name = 'bootstrap_phpbb.sh'
slice = default_slice
content_data = phpbb_bootstrap_data
# Associate the cloudstorage object with the phpbb script
/orchestration/script phpbb_bootstrap_script => [default_slice, phpbb_container, phpbb_bootstrap_object] read_or_create
data_uri = 'cloudstorage://default_slice/phpbb_container/bootstrap_phpbb.sh'
script_type = _SHELL
encoding = _STORAGE
# Create the recipe and associate the script
/orchestration/recipe phpbb_bootstrap_recipe read_or_create
scripts = [phpbb_bootstrap_script]
#---------------------
# Create phpbb server
#---------------------
/server/cloud phpbb_server read_or_create
hostname = '{{ phpbb_hostname }}'
image = '{{ phpbb_image_type }}'
service_type = '{{ phpbb_instance_type }}'
keys = [phpbb_server_password_key, phpbb_server_console_key]
recipes = [phpbb_bootstrap_recipe]
text_template phpbb_bootstrap_data
#!/bin/sh
#
# install phpbb 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 apache2 -y > /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
}
# enable PHP5 module
a2enmod php5 > /dev/null
# download phpbb source
cd /var/www/html/
wget -O phpbb.zip "https://www.phpbb.com/files/release/{{ phpbb_version }}.zip" > /dev/null 2>&1
[ $? -eq 0 ] && echo "OK: download phpbb source" || {
echo "ERROR: download phpbb source"
exit 1
}
# extract phpbb files
unzip phpbb.zip > /dev/null
[ $? -eq 0 ] && echo "OK: extract phpbb files" || {
echo "ERROR: extract phpbb files"
exit 1
}
# move phpbb files
mv ./phpBB3 ./phpbb
[ $? -eq 0 ] && echo "OK: move phpbb files" || {
echo "ERROR: move phpbb files"
exit 1
}
# set ownership & permissions
chown -R www-data:www-data /var/www/html/phpbb
[ $? -eq 0 ] && echo "OK: set required permissions" || {
echo "ERROR: set required permissions"
exit 1
}
# create MySQL database & user
mysql <<EOF
create database {{ phpbb_db_name }};
grant all on {{ phpbb_db_name }}.* to {{ phpbb_db_username }}@localhost identified by '{{ phpbb_db_password }}';
EOF
[ $? -eq 0 ] && echo "OK: create phpbb database and user" || {
echo "ERROR: create phpbb 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 phpbb service"
_eof
text_template phpbb_result_template
Thank you for provisioning a phpbb service.
You can now finish its configuration on the following page:
http://{{ phpbb_server.ipaddress_public }}/phpbb/
Please use following credentials for database configuration:
hostname: localhost
username: {{ phpbb_db_username }}
password: {{ phpbb_db_password }}
database: {{ phpbb_db_name }}
You can also login to the server directly via SSH by connecting to:
root@{{ phpbb_server.ipaddress_public }}
using the password: {{ phpbb_server_password_key.password }}
_eof