Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

PI-676 updated installer to download correct php version #101

Merged
merged 1 commit into from
Jul 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions cloudflare.install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,15 @@ install $SOURCE_DIR/APIKey $INSTALL_DIR/bin/admin/CloudFlare/APIKey
chmod 0700 $INSTALL_DIR/bin/admin/CloudFlare/APIKey
echo "mode=simple" > $INSTALL_DIR/bin/admin/CloudFlare/APIKey.conf

# Get PHP Version
CPANELSUPPORTEDPHPPATH=`ls -al $INSTALL_DIR/3rdparty/bin/php | awk '{print $11}'`
PHPVERSION=`echo $CPANELSUPPORTEDPHPPATH | rev | cut -d '/' -f 3 | rev`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about

#!/bin/bash
IN="/usr/local/cpanel/3rdparty/php/56/bin/php"
IFS="/" && Array=($IN)
PHPVERSION=${Array[6]}
echo $PHPVERSION

http://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash

This rev, cut, rev logic scares me because I don't know bash and if they change the path its not clear how to fix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a one liner which will get you the PHP version in the format you want:
PHPVERSION=/usr/local/cpanel/3rdparty/bin/php --version | head -1 | awk '{print $2}' | sed 's/.//' | cut -f 1 -d .``

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was hoping for something a little more human readable haha :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jwineman That doesn't work. In my opinion rev logic is clear enough. I can add comment to be more clear though?


# Install PHP code
install -d $INSTALL_DIR/3rdparty/php/54/lib/php/cloudflare/vendor
cp -r $SOURCE_DIR/vendor/* $INSTALL_DIR/3rdparty/php/54/lib/php/cloudflare/vendor
install -d $INSTALL_DIR/3rdparty/php/54/lib/php/cloudflare/src
cp -r $SOURCE_DIR/src/* $INSTALL_DIR/3rdparty/php/54/lib/php/cloudflare/src
install -d $INSTALL_DIR/3rdparty/php/$PHPVERSION/lib/php/cloudflare/vendor
cp -r $SOURCE_DIR/vendor/* $INSTALL_DIR/3rdparty/php/$PHPVERSION/lib/php/cloudflare/vendor
install -d $INSTALL_DIR/3rdparty/php/$PHPVERSION/lib/php/cloudflare/src
cp -r $SOURCE_DIR/src/* $INSTALL_DIR/3rdparty/php/$PHPVERSION/lib/php/cloudflare/src

# Register the plugin buttons with Cpanel
/usr/local/cpanel/scripts/install_plugin $SOURCE_DIR/installers/cloudflare_simple.tar.bz2
Expand Down