Allow for installation of php in ~/.mwphp and don't die if maintenance/dev/data alrea...
[lhc/web/wiklou.git] / maintenance / dev / installphp.sh
1 #!/bin/bash
2
3 if [ "x$BASH_SOURCE" == "x" ]; then echo '$BASH_SOURCE not set'; exit 1; fi
4 DEV=$(cd -P "$(dirname "${BASH_SOURCE[0]}" )" && pwd)
5
6 set -e # DO NOT USE PIPES unless this is rewritten
7
8 if [ -d "$DEV/php" -a -x "$DEV/php/bin/php" ] || [ -d "$HOME/.mwphp" -a -x "$HOME/.mwphp/bin/php" ]; then
9 echo "PHP is already installed"
10 exit 0
11 fi
12
13 TAR=php5.4-latest.tar.gz
14 PHPURL="http://snaps.php.net/$TAR"
15
16 cd "$DEV"
17
18 echo "Preparing to download and install a local copy of PHP 5.4, note that this can take some time to do."
19 echo "If you wish to avoid re-doing this for uture dev installations of MediaWiki we suggest installing php in ~/.mwphp"
20 echo -n "Install PHP in ~/.mwphp [y/N]: "
21 read INSTALLINHOME
22
23 case "$INSTALLINHOME" in
24 [Yy] | [Yy][Ee][Ss] )
25 PREFIX="$HOME/.mwphp"
26 ;;
27 *)
28 PREFIX="$DEV/php/"
29 ;;
30 esac
31
32 # Some debain-like systems bundle wget but not curl, some other systems
33 # like os x bundle curl but not wget... use whatever is available
34 echo -n "Downloading PHP 5.4"
35 if command -v wget &>/dev/null; then
36 echo "- using wget"
37 wget "$PHPURL"
38 elif command -v curl &>/dev/null; then
39 echo "- using curl"
40 curl -O "$PHPURL"
41 else
42 echo "- aborting"
43 echo "Could not find curl or wget." >&2;
44 exit 1;
45 fi
46
47 echo "Extracting php 5.4"
48 tar -xzf "$TAR"
49
50 cd php5.4-*/
51
52 echo "Configuring and installing php 5.4 in $PREFIX"
53 ./configure --prefix="$PREFIX"
54 make
55 make install