packweb-apache: Use $SUDO_USER when possible in phpContainer #136

Closed
mtrossevin wants to merge 1 commit from mtrossevin/ansible-roles:use-sudo_user into unstable
3 changed files with 5 additions and 4 deletions

View file

@ -24,13 +24,14 @@ The **patch** part changes is incremented if multiple releases happen the same m
* mongodb: Deny the install on Debian 11 « Bullseye » when the version is unsupported
* mongodb: Support version 5.0 (for buster)
* mongodb: Allow to specify a mongodb version for buster & bullseye
* packweb-apache: phpContainer now use $SUDO\_USER when available (so when run through sudo or as an unprivileged user) and $LOGNAME when not.
### Fixed
* evolinux-base: fix alert5.service dependency syntax
* mysql : Create a default ~root/.my.cnf for compatibility reasons
* nginx : fix variable name and debug to actually use nginx-light
* packweb-apache : Support php 8.0
* packweb-apache : Support php 8.0
### Removed

View file

@ -1,3 +1,3 @@
Defaults env_keep += "LOGNAME PWD"
Defaults env_keep += "PWD"
ALL ALL = NOPASSWD: /usr/local/bin/phpContainer

View file

@ -6,10 +6,10 @@ if [ "$EUID" -ne 0 ]; then
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')
PHPVersion=$(grep SetHandler /etc/apache2/sites-enabled/${SUDO_USER:-${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}"
lxc-attach -n php$PHPVersion -- su - ${SUDO_USER:-${LOGNAME}} -c "cd \"${PWD@E}\" && php ${*@Q}"
else
# TODO: fallback?
# command php $*