ansible-roles/packweb-apache/files/phpContainer
Ludovic Poujol bd63e7037f
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
packweb-apache: Do the install & conffigure phpContainer script (instead of evoadmin-web role)
2020-04-08 17:54:43 +02:00

19 lines
593 B
Bash

#!/usr/bin/env bash
# If this script isn't run as root, then, re-run it with sudo.
if [ "$EUID" -ne 0 ]; then
sudo $(readlink -f ${BASH_SOURCE[0]}) ${*@Q}
exit 0;
fi;
PHPVersion=$(grep SetHandler /etc/apache2/sites-enabled/$LOGNAME.conf 2>/dev/null | grep -m 1 -o 'fpm[0-9][0-9]' | head -n 1 | sed 's/php//g' | sed 's/fpm//g')
if [ "$PHPVersion" != "" ]; then
lxc-attach -n php$PHPVersion -- su - $LOGNAME -c "cd \"${PWD@E}\" && php ${*@Q}"
else
# TODO: fallback?
# command php $*
echo "ERROR - Could not determine \$PHPVersion - Are you a web account ?"
exit 1
fi