/[drupal]/contributions/profiles/hostmaster/install.sh.txt
ViewVC logotype

Contents of /contributions/profiles/hostmaster/install.sh.txt

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.18 - (show annotations) (download)
Wed Oct 28 22:41:51 2009 UTC (4 weeks, 2 days ago) by mig5
Branch: MAIN
Changes since 1.17: +1 -1 lines
File MIME type: text/plain
#617490 by adrinux - add unzip as a system dependency in hostmaster, to handle extraction of jquery.ui lib
1 #!/usr/bin/env bash
2
3 AEGIR_VERSION=0.4
4 DRUPAL_VERSION=6.14
5
6 DRUSH_TAG=DRUPAL-6--2-1
7 PROVISION_TAG=DRUPAL-6--0-4-ALPHA2
8 HOSTING_TAG=DRUPAL-6--0-4-ALPHA2
9 AMENU_TAG=DRUPAL-6--1-5
10 INSTPROFILEAPI_TAG=DRUPAL-6--2-1
11
12 aegir_title () {
13 echo "$1"
14 }
15
16 aegir_prompt () {
17 echo "$1 "
18 }
19
20 aegir_environment () {
21 AEGIR_USER=''
22 aegir_prompt "Initialize Ubuntu (or similar with apt-get) Aegir environment? yes/no (Y/n) :"
23 read yesno
24 if `echo $yesno | grep -qi y`; then
25 # basic server maintenance
26 apt-get -y update;
27 apt-get -y upgrade;
28
29 # Specific to this environment
30 apt-get -y install openssh-server;
31 # Install postfix if no sendmail is present.
32 if [ -z `which sendmail` ]; then
33 apt-get -y install postfix;
34 fi
35 # Required components
36 apt-get -y install sudo wget cvs unzip;
37 apt-get -y install mysql-server-5.0;
38 apt-get -y install apache2;
39 apt-get -y install php5 php5-cli php5-mysql;
40
41 # Extra php components
42 apt-get -y install php5-gd php5-imap php5-xcache;
43
44 # Code tools.
45 apt-get -y install build-essential subversion git-core;
46
47 ###
48 ### Aegir user setup
49 ###
50
51 AEGIR_USER="aegir"
52 create_user
53
54 a2enmod php5;
55 a2enmod rewrite;
56
57 #increase php memory limit
58 aegir_prompt "Increase php.ini memory limits to 64M for apache2 and 128M for cli? yes/no (Y/n) :"
59 read yesno
60 if `echo $yesno | grep -qi y`; then
61 if [ -f /etc/php5/apache2/php.ini ]; then
62 mv /etc/php5/apache2/php.ini /etc/php5/apache2/php.ini.aegir.bak
63 sed -e 's+^memory_limit[ ]*=[ ]*[0-9]*[M]*+memory_limit = 64M+' /etc/php5/apache2/php.ini.aegir.bak > /etc/php5/apache2/php.ini
64 else
65 echo "Set your apache2 php.ini file to have a larger memory limit manually if needed."
66 fi;
67
68 phpclipath=`php --ini | grep "Loaded Configuration File" | awk '{print $4}'`
69 if [ -f $phpclipath ]; then
70 mv $phpclipath $phpclipath.aegir.bak
71 sed -e 's+^memory_limit[ ]*=[ ]*[0-9]*[M]*+memory_limit = 128M+' $phpclipath.aegir.bak > $phpclipath
72 else
73 echo "Set your cli php.ini file to have a larger memory limit manually if needed."
74 fi;
75 fi;
76 $APACHECTL_BIN restart;
77 fi;
78 }
79
80 find_httpd () {
81 found=`which apache2 || which apache || which httpd`
82 if [ $? = 1 ]; then
83 echo "Could not find apache2, apache or httpd in your path. exiting";
84 exit;
85 fi;
86 export HTTPD_BIN=$found
87 }
88
89 find_web_group () {
90 bnfound=`basename $HTTPD_BIN`
91 group=`ps -eo user,group,comm | grep $bnfound | grep -v 'root' | awk '{print $2}' | head -n 1`
92 if [ $group = '' ]; then
93 echo "Could not find web group"
94 exit;
95 fi;
96 export WEB_GROUP=$group
97 }
98
99 create_user () {
100 aegir_prompt "Creating the $AEGIR_USER user.."
101 adduser --system --group --home /var/$AEGIR_USER $AEGIR_USER
102
103 find_httpd
104 find_web_group
105
106 echo "Adding $AEGIR_USER to group $WEB_GROUP"
107
108 adduser $AEGIR_USER $WEB_GROUP
109
110 find_apachectl
111 edit_visudo
112 }
113
114 find_apachectl () {
115 found=`which apache2ctl || which apachectl`
116 if [ $? = 1 ]; then
117 echo "Could not find apache2ctl or apachectl in your path. exiting";
118 exit;
119 fi;
120 export APACHECTL_BIN=$found
121 }
122
123 edit_visudo () {
124 echo "$AEGIR_USER ALL= NOPASSWD: $APACHECTL_BIN" >> /etc/sudoers
125 }
126
127 aegir_user () {
128 aegir_title "SECTION 1 : Aegir user account"
129 echo "Aegir is designed to run as its own user that was created specifically for it."
130 if [ $AEGIR_USER != '' ]; then
131 echo "Installing Aegir as the $AEGIR_USER user, already created."
132 aegir_user_home
133 return;
134 fi;
135 aegir_prompt "Install Aegir as the $USER user? yes/no (Y/n) :"
136 read yesno
137 if `echo $yesno | grep -qi y`; then
138 AEGIR_USER=$USER;
139 aegir_user_home
140 else
141 while [ -z $AEGIR_USER ]; do
142 aegir_prompt "Which user do you want to install aegir as? [aegir] :"
143 read USER_CHECK
144 if [ -z $USER_CHECK ]; then
145 USER_CHECK="aegir";
146 fi;
147
148 AEGIR_UID=`id -u $USER_CHECK 2> /dev/null`
149 if [ $? = 0 ]; then
150 aegir_prompt "User $USER_CHECK already exists. This script will assume it was properly configured. Maybe you are rerunning the script accidentally. Stopping now will leave your system unchanged. Continue? yes/no (Y/n) :";
151 read yesno
152 if `echo $yesno | grep -qi y`; then
153 AEGIR_USER=$USER_CHECK
154 aegir_user_home
155 else
156 echo "Nothing was changed."
157 exit;
158 fi;
159 else
160 find_httpd
161 find_web_group
162 aegir_prompt "User $USER_CHECK does not exist, do you want to create this user? It will have a home directory of /var/$USER_CHECK and will be part of the $WEB_GROUP group. yes/no (Y/n) :"
163 read yesno
164 if `echo $yesno | grep -qi y`; then
165 AEGIR_USER=$USER_CHECK
166 create_user
167 aegir_user_home
168 else
169 echo "Nothing was changed."
170 exit;
171 fi;
172 fi;
173 done;
174 fi;
175 }
176
177 aegir_user_home() {
178 if [ `uname` = 'Darwin' ]; then
179 AEGIR_HOME=`dscl localhost -read /Local/Default/Users/$AEGIR_USER NFSHomeDirectory | awk '{print $2}'`
180 else
181 AEGIR_HOME=`cat /etc/passwd | grep $AEGIR_USER | awk -F: '{print $6}'`
182 fi;
183
184 if [ -z $AEGIR_HOME ]; then
185 echo "Aegir requires the user to have a home directory";
186 exit 1;
187 fi;
188
189 return $?;
190 }
191
192
193 check_requirements () {
194 aegir_title "SECTION 2 : Checking dependencies"
195 echo "Checking that all the required commands are available :"
196
197 DOEXIT=0
198
199 found=`type php`
200 if [ $? != 0 ]; then
201 echo "PHP command line interface not available."
202 DOEXIT=1;
203 else
204 echo $found;
205 fi;
206
207 found=`type mysql`
208 if [ $? != 0 ]; then
209 echo "Mysql client binary not available."
210 DOEXIT=1;
211 else
212 echo $found;
213 fi;
214
215 found=`type cvs`
216 if [ $? != 0 ]; then
217 echo "CVS command not available."
218 DOEXIT=1
219 fi;
220
221 found=`type wget`
222 if [ $? != 0 ]; then
223 echo "Wget command not available."
224 DOEXIT=1;
225 else
226 echo $found;
227 fi;
228
229 if [ $DOEXIT = 1 ]; then
230 echo "\n Aegir can not be installed because of missing dependencies."
231 echo "Please install the missing packages and run this script again.\n\n\n"
232 exit
233 fi;
234
235 echo "All the requirements are available."
236 }
237
238
239 aegir_download () {
240 DRUPAL_DIR=$AEGIR_HOME/drupal-$DRUPAL_VERSION
241
242 aegir_title "SECTION 3 : Downloading Aegir"
243 echo "Logging in to Drupal CVS"
244
245 export CVSROOT=:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib
246
247 cvs login
248 cd $AEGIR_HOME
249 echo "Downloading Drush"
250 cvs_co modules/drush $DRUSH_TAG $AEGIR_HOME/drush
251
252 echo "Downloading Provision"
253 mkdir $AEGIR_HOME/.drush
254 cvs_co modules/provision $PROVISION_TAG $AEGIR_HOME/.drush/provision
255
256 echo "Download hostmaster install profile"
257 cvs_co profiles/hostmaster $HOSTING_TAG $AEGIR_HOME/hostmaster
258
259 mkdir $AEGIR_HOME/hostmaster/modules
260 mkdir $AEGIR_HOME/hostmaster/themes
261
262 echo "Downloading install profile api"
263 cvs_co modules/install_profile_api $INSTPROFILEAPI_TAG $AEGIR_HOME/hostmaster/modules/install_profile_api
264
265 echo "Download hosting front end"
266 cvs_co modules/hosting $HOSTING_TAG $AEGIR_HOME/hostmaster/modules/hosting
267
268 echo "Download eldir theme"
269 cvs_co themes/eldir $HOSTING_TAG $AEGIR_HOME/hostmaster/themes/eldir
270
271 echo "Download admin_menu module"
272 cvs_co modules/admin_menu $AMENU_TAG $AEGIR_HOME/hostmaster/modules/admin_menu
273
274 echo "Downloading Drupal"
275 cd $AEGIR_HOME
276 php $AEGIR_HOME/drush/drush.php dl drupal-$DRUPAL_VERSION
277 mv $AEGIR_HOME/hostmaster $DRUPAL_DIR/profiles/
278
279 }
280
281 cvs_co () {
282 bn=`basename $3`
283 cvs -z6 co -d $bn.tmp -r$2 contributions/$1
284 mv $bn.tmp $3
285 }
286
287 aegir_vhost () {
288 aegir_title "SECTION 4 : Creating Virtual host configuration file"
289 DOMAIN=""
290 while [ -z $DOMAIN ]; do
291 aegir_prompt "Choose a domain for your hosting site. It should be already pointed to this computer: "
292 read DOMAIN
293 done;
294 CONF_DIR=$AEGIR_HOME/config/vhost.d
295
296 echo Creating $CONF_DIR to store configuration files
297 sudo -u $AEGIR_USER mkdir -p $CONF_DIR
298
299 sudo -u $AEGIR_USER sed -e "s+aegir.example.com+$DOMAIN+g" $DRUPAL_DIR/profiles/hostmaster/apache2.conf.txt |
300 sed -e "s+/var/aegir/drupal-6.x+$DRUPAL_DIR+g" |
301 sed -e "s+/var/aegir/config/vhost.d+$CONF_DIR+g" > $CONF_DIR/$DOMAIN
302
303 echo "Setting up aegir site $DOMAIN in $DRUPAL_DIR/sites/"
304 mkdir $DRUPAL_DIR/sites/$DOMAIN
305 echo "Making settings.php writable"
306 cp $DRUPAL_DIR/sites/default/default.settings.php $DRUPAL_DIR/sites/$DOMAIN/settings.php
307 chmod 777 $DRUPAL_DIR/sites/$DOMAIN/settings.php
308 mkdir $DRUPAL_DIR/sites/$DOMAIN/files
309 chmod 777 $DRUPAL_DIR/sites/$DOMAIN/files
310 chown -R $AEGIR_USER:$AEGIR_USER $AEGIR_HOME
311
312 find_apachectl
313 find_httpdconf
314 if grep -q "Include $CONF_DIR" $HTTPD_CONF
315 then
316 echo "$CONF_DIR has already been included in $HTTPD_CONF, possibly from a previous installation, skipping.."
317 else
318 echo "Include $CONF_DIR" >> $HTTPD_CONF
319 $APACHECTL_BIN restart
320 fi
321 }
322
323 find_httpdconf () {
324 HTTPD_CONF=`$APACHECTL_BIN -V | grep SERVER_CONFIG_FILE | sed -e 's/.*=//' -e 's/"//g'`
325 }
326
327 aegir_database () {
328 aegir_title "SECTION 5 : Setting up MySQL"
329 found=""
330 while [ -z "$found" ]; do
331 aegir_prompt "MySQL root username [root]:"
332 read MYSQLUSER
333 if [ -z $MYSQLUSER ]; then
334 MYSQLUSER="root";
335 fi;
336 aegir_prompt "MySQL root user password : "
337 stty -echo
338 read DBPASS; echo
339 stty echo
340 if [ -z $DBPASS ]; then
341 found=`mysqladmin -u$MYSQLUSER ping`
342 else
343 found=`mysqladmin -u$MYSQLUSER -p$DBPASS ping`
344 fi;
345 done;
346
347 echo "Creating mysql database for hostmaster site :"
348 aegir_prompt "Database [aegir]:"
349 read HMDB
350 if [ -z $HMDB ]; then
351 HMDB="aegir";
352 fi;
353
354 if [ -z $DBPASS ]; then
355 mysqladmin -u$MYSQLUSER create $HMDB
356 else
357 mysqladmin -u$MYSQLUSER -p$DBPASS create $HMDB
358 fi;
359
360 echo "Creating $HMDB user account :"
361 aegir_prompt "Username [aegir]:"
362 read HMUSER
363 if [ -z $HMUSER ]; then
364 HMUSER="aegir";
365 fi;
366
367 aegir_prompt "Enter a password for the $HMDB user:"
368 stty -echo
369 read HMPASS; echo
370 stty echo
371
372 if [ -z $DBPASS ]; then
373 echo "GRANT ALL ON $HMDB.* TO '$HMUSER'@'localhost' IDENTIFIED BY '$HMPASS'" |
374 mysql -u$MYSQLUSER $HMDB
375 else
376 echo "GRANT ALL ON $HMDB.* TO '$HMUSER'@'localhost' IDENTIFIED BY '$HMPASS'" |
377 mysql -u$MYSQLUSER -p$DBPASS $HMDB
378 fi;
379
380 echo "Creating aegir mysql superuser account :"
381 aegir_prompt "Username [aegir_root]:"
382 read AEUSER
383 if [ -z $AEUSER ]; then
384 AEUSER="aegir_root";
385 fi;
386
387 aegir_prompt "Enter a password for the $AEUSER user:"
388 stty -echo
389 read AEPASS; echo
390 stty echo
391
392 if [ -z $DBPASS ]; then
393 echo "GRANT ALL PRIVILEGES ON *.* TO '$AEUSER'@'localhost' IDENTIFIED BY '$AEPASS' WITH GRANT OPTION" |
394 mysql -u$MYSQLUSER $HMDB
395 else
396 echo "GRANT ALL PRIVILEGES ON *.* TO '$AEUSER'@'localhost' IDENTIFIED BY '$AEPASS' WITH GRANT OPTION" |
397 mysql -u$MYSQLUSER -p$DBPASS $HMDB
398 fi;
399 }
400
401 aegir_install () {
402 echo -e "Please visit $DOMAIN in a browser and run the hostmaster install profile there. You will be prompted for some information during the install. Where required, use $HMUSER as the site mysql user, $AEUSER as the aegir 'super' mysql user, and $AEGIR_USER as the system's Unix user. You will be prompted for the full path to the drush executable, which is $AEGIR_HOME/drush/drush.php .\nAlso, ensure you run the drush command as instructed at the end of Aegir's install profile that initializes the hostmaster system - all other suggested commands have already been run by this script and can be ignored."
403 }
404 clear
405 aegir_title "Installing Aegir $AEGIR_VERSION"
406 if [ $USER != "root" ]; then
407 aegir_title "Must be run as root, exiting"
408 exit;
409 fi;
410 cd ~/
411 aegir_environment
412 aegir_user
413 check_requirements
414 aegir_download
415 aegir_vhost
416 aegir_database
417 aegir_install
418

  ViewVC Help
Powered by ViewVC 1.1.2