install.sh.txt 3.67 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
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
########################################################################
# basic variables, change before release
33 34
AEGIR_VERSION="HEAD"
DRUSH_VERSION=All-versions-3.0
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

# 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 

}

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

72
AEGIR_HOME="$HOME"
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
DRUSH="$AEGIR_HOME/drush/drush.php"

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
EOF

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

95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
# 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

118
if $DRUSH help | grep "^ provision-install" > /dev/null ; then
119 120 121 122 123 124 125 126 127 128 129 130 131
  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
132

133
msg "Installing the frontend"
134
$DRUSH hostmaster-install $@