From 780cc0f73fe559069d65835129dfaa163ae02065 Mon Sep 17 00:00:00 2001 From: Helmut Hummel Date: Sun, 1 Jul 2012 14:20:24 +0200 Subject: [PATCH] Add install helper methods --- install-helper.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 install-helper.sh diff --git a/install-helper.sh b/install-helper.sh new file mode 100755 index 0000000..e478d9d --- /dev/null +++ b/install-helper.sh @@ -0,0 +1,62 @@ +#!/bin/bash +export DEBUG="echo" +export phpConfigFile=`php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` + +function addOptionToPhpConfig() { + if grep -q "$1" $phpConfigFile + then + echo "Option $1 already added" + else + if [ -n "$DEBUG" ] + then + echo "$1 >> $phpConfigFile" + else + echo "$1" >> $phpConfigFile + fi + fi +} + +function addModuleToPhpConfig() { + addOptionToPhpConfig "extension=$1.so" +} + +function installPhpModule() { + if [[ "$1" == "redis" ]] + then + installRedis + return + fi + if [[ "$1" == "-y" ]] + then + CONFIRM="printf \"no\n\" |" + shift + fi + $DEBUG $CONFIRM pecl install $1 + addModuleToPhpConfig $1 +} + +function installRedis() { + _pwd=$PWD + mkdir phpredis-build + cd phpredis-build + $DEBUG git clone --depth 1 git://github.com/nicolasff/phpredis.git + $DEBUG cd phpredis + $DEBUG phpize + $DEBUG ./configure + $DEBUG make + $DEBUG sudo make install + cd $_pwd +} + +installPhpModule igbinary +installPhpModule -y memcache +installPhpModule redis + +if [[ "$TRAVIS_PHP_VERSION" == "5.3" ]] +then + installPhpModule -y apc + addOptionToPhpConfig "apc.enable_cli=1" + addOptionToPhpConfig "apc.slam_defense=0" +fi + +