install.sh.txt 6.62 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
#! /bin/sh

# $Id$

########################################################################
# Aegir quick install script
#
# This script takes care of deploying all the required PHP scripts for
# the frontend to run properly. It should be ran as the Aegir user.
#
# It should keep to strict POSIX shell syntax to ensure maximum
# portability. The aim here is to ease the burden on porters but also
13
14
# allow people using various platforms to zip through the install
# quicker.
15
16
17
18
#
# This script also *DOES NOT CHECK* if the requirements have been met.
# It's up to the admin to follow the proper install instructions or use
# the packages provided by their platform.
19
20
21
22
23
########################################################################
# This script takes the following steps:
#
# 1. parse commandline
# 2. prompt for confirmation
anarcat's avatar
anarcat committed
24
25
26
27
28
29
# 3. creates a basic directory structure in $AEGIR_HOME
# 4. downloads drush in $AEGIR_HOME
# 5. downloads drush_make in $AEGIR_HOME/.drush
# 6. downloads provision in $AEGIR_HOME/.drush
# 7. deploys hostmaster in $AEGIR_HOME using drush
# 8. creates an apache config file in $AEGIR_HOME/config/vhost.d
30
#
31
32
33
34
35
36
########################################################################
# basic variables, change before release
AEGIR_DOMAIN=aegir.example.com 
AEGIR_VERSION=HEAD
AEGIR_HOME=$HOME
WEB_GROUP=www-data
37
# doesn't exist yet, but we need drush_prompt in HEAD
38
39
DRUSH_VERSION=6.x-3.0-rc3
DRUSH_MAKE_VERSION=6.x-2.0-beta6
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

# when adding a variable here, add it to the display below

########################################################################
# functions

# noticeable messages
msg() {
  echo "==> $*"
}

# simple prompt
prompt_yes_no() {
  while true ; do
    printf "$* [Y/n] "
    read answer
    if [ -z "$answer" ] ; then
      return 0
    fi
    case $answer in
      [Yy]|[Yy][Ee][Ss])
        return 0
        ;;
      [Nn]|[Nn][Oo])
        return 1
        ;;
      *)
        echo "Please answer yes or no"
        ;;
    esac
 done 

}

usage() {
  cat <<EOF
Usage: $0 [ -V version ] [ -h ] [ -w group ] [ -d home ] hostname
EOF
}

########################################################################
# Main script

# stop on error
set -e

# parse commandline
87
args=`getopt bV:w:d:h $*`
88
89
90
91
92
93
94
95
set -- $args

for i
do
  case "$i" in
    -w) shift; WEB_GROUP=$1; shift;;
    -V) shift; AEGIR_VERSION=$1; shift;;
    -d) shift; AEGIR_HOME=$1; shift;;
96
    -b) BACKEND_ONLY=1; shift;;
anarcat's avatar
anarcat committed
97
    -h) shift; usage; exit;;
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
    --) shift; break;;
  esac
done

AEGIR_DOMAIN=${1:-$AEGIR_DOMAIN}
DRUSH="$AEGIR_HOME/drush/drush.php"
HOSTMASTER_DIR=$AEGIR_HOME/hostmaster-$AEGIR_VERSION

msg "Aegir automated install script"

if [ `whoami` = "root" ] ; then
  msg "This script should be ran as a non-root user"
  exit 1
fi

msg "This script makes the following assumptions: "
cat <<EOF
 * you have read INSTALL.txt and prepared the platform accordingly
 * you are running as your "aegir" user
 * the following settings are correct:
AEGIR_DOMAIN=$AEGIR_DOMAIN
AEGIR_VERSION=$AEGIR_VERSION
AEGIR_HOME=$AEGIR_HOME
WEB_GROUP=$WEB_GROUP
HOSTMASTER_DIR=$HOSTMASTER_DIR
DRUSH=$DRUSH
DRUSH_VERSION=$DRUSH_VERSION

Some of those settings can be changed on the commandline, see:

 $0 -h

for more information.
EOF

if prompt_yes_no "Do you want to proceed with the install?" ; then
  true
else
  echo "installation aborted by user"
  exit 1
fi

anarcat's avatar
anarcat committed
140
141
msg "Creating basic directory structure"
mkdir -p $AEGIR_HOME/config/vhost.d
142
mkdir -p $AEGIR_HOME/config/platform.d
143
mkdir -p $AEGIR_HOME/config/apache.d
anarcat's avatar
anarcat committed
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
mkdir -p $AEGIR_HOME/backups
chmod 0711 $AEGIR_HOME/config
chmod 0700 $AEGIR_HOME/backups

# we need to check both because some platforms (like SunOS) return 0 even if the binary is not found
if which drush 2> /dev/null && which drush | grep -v 'no drush in' > /dev/null; then
  msg "Drush is in the path, good"
  DRUSH=drush
elif [ -x $DRUSH ] ; then
  msg "Drush found in $DRUSH, good"
  DRUSH="php $AEGIR_HOME/drush/drush.php"
else
  msg "Installing drush in $AEGIR_HOME"
  cd $AEGIR_HOME
  wget http://ftp.drupal.org/files/projects/drush-$DRUSH_VERSION.tar.gz
  gunzip -c drush-$DRUSH_VERSION.tar.gz | tar -xf -
  rm drush-$DRUSH_VERSION.tar.gz
  DRUSH="php $AEGIR_HOME/drush/drush.php"
fi

if $DRUSH help > /dev/null ; then
  msg "Drush seems to be functionning properly"
else
  msg "Drush is broken ($DRUSH help failed)"
  exit 1
fi

if $DRUSH help | grep "^ make" > /dev/null ; then
  msg "Drush make already seems to be installed"
else
  msg "Installing drush make in $AEGIR_HOME/.drush"
  mkdir -p $AEGIR_HOME/.drush
  $DRUSH dl drush_make-$DRUSH_MAKE_VERSION --destination=$AEGIR_HOME/.drush
fi

179
if $DRUSH help | grep "^ provision-install" > /dev/null ; then
anarcat's avatar
anarcat committed
180
181
182
183
184
185
186
187
188
189
190
191
192
  msg "Provision already seems to be installed"
else
  msg "Installing provision backend in $AEGIR_HOME/.drush"
  mkdir -p $AEGIR_HOME/.drush
  if [ "$AEGIR_VERSION" = "HEAD" ]; then
    git clone git://git.aegirproject.org/provision $AEGIR_HOME/.drush/provision
  else
    cd $AEGIR_HOME/.drush
    wget http://files.aegirproject.org/provision-$AEGIR_VERSION.tgz
    gunzip -c provision-$AEGIR_VERSION.tgz | tar -xf -
    rm provision-$AEGIR_VERSION.tgz
  fi
fi
193

194
# this will prompt the user for the database password if not provided through stdin in JSON
195
$DRUSH provision-verify --parent_path="$AEGIR_HOME" --web_group="$WEB_GROUP" --drush_path="$DRUSH"
196
197
198
199
200
201
202

msg "Aegir provision backend installed successfully"

if [ ! -z "$BACKEND_ONLY" ] ; then
  exit 0
fi

203
204
205
if [ ! -d $HOSTMASTER_DIR ] ; then
  msg "Deploying hostmaster application"
  $DRUSH hostmaster-make $HOSTMASTER_DIR
206
207
  # this, and the remaining of this file, should be handled by
  # provision-install, see http://drupal.org/node/711740
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
  cd $HOSTMASTER_DIR
  mkdir sites/$AEGIR_DOMAIN
  cp sites/default/default.settings.php sites/$AEGIR_DOMAIN/settings.php
  chmod g+w sites/$AEGIR_DOMAIN/settings.php
  mkdir sites/$AEGIR_DOMAIN/files
  chmod 2770 sites/$AEGIR_DOMAIN/files
  chgrp $WEB_GROUP sites/$AEGIR_DOMAIN/settings.php
  chgrp $WEB_GROUP sites/$AEGIR_DOMAIN/files
fi

if [ ! -f $AEGIR_HOME/config/vhost.d/$AEGIR_DOMAIN ]; then
  sed -e "s#DocumentRoot .*#DocumentRoot $HOSTMASTER_DIR#" -e "s#Directory .*#Directory $HOSTMASTER_DIR>#" -e "s/ServerName .*/ServerName $AEGIR_DOMAIN/" $HOSTMASTER_DIR/profiles/hostmaster/apache2.conf.txt > $AEGIR_HOME/config/vhost.d/$AEGIR_DOMAIN
  msg "Installed apache configuration file for $AEGIR_DOMAIN, you will need to restart apache"
fi

msg "Install process complete: follow the wizard"

cat <<EOF
Now point your browser to http://$AEGIR_DOMAIN/install.php and proceed
with the remainder of the installation using the Hostmaster Install profile.
Some of the instructions given, you will already have completed, but carefully
read each step in turn to ensure you don't miss anything.
EOF