Compare commits
No commits in common. "8fb5a93b7f3aaddf6b081bba3f6b3fb66d8ed9d4" and "be3095e00066694177204af0b9777521a088b92d" have entirely different histories.
8fb5a93b7f
...
be3095e000
@ -1,36 +1,38 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
# Lenvi Smart Composer Wrapper
|
||||||
# Lenvi Smart Composer Wrapper (v2)
|
|
||||||
#
|
|
||||||
# This script automatically detects the required PHP version for a project
|
# This script automatically detects the required PHP version for a project
|
||||||
# by reading a central Lenvi.yaml file and uses the correct PHP binary.
|
# by looking for a `Lenvi.yaml` file and uses the correct PHP binary.
|
||||||
|
|
||||||
# --- The real composer binary and default PHP ---
|
|
||||||
COMPOSER_PHAR="/usr/local/bin/composer.phar"
|
COMPOSER_PHAR="/usr/local/bin/composer.phar"
|
||||||
DEFAULT_PHP_BINARY="/usr/bin/php"
|
DEFAULT_PHP_BINARY="/usr/bin/php"
|
||||||
PHP_BINARY=""
|
PHP_BINARY=""
|
||||||
|
|
||||||
# --- The EXACT path to the configuration file, baked in by Ansible ---
|
# Find the Lenvi.yaml file by looking in parent directories
|
||||||
LENVI_CONFIG_FILE="{{ playbook_dir }}/Lenvi.yaml"
|
LENVI_CONFIG_FILE=""
|
||||||
|
SEARCH_DIR=$(pwd)
|
||||||
|
while [[ "$SEARCH_DIR" != "" && ! -f "$SEARCH_DIR/Lenvi.yaml" ]]; do
|
||||||
|
SEARCH_DIR=${SEARCH_DIR%/*}
|
||||||
|
done
|
||||||
|
|
||||||
# Check if the central config file actually exists
|
if [[ -f "$SEARCH_DIR/Lenvi.yaml" ]]; then
|
||||||
if [[ -f "$LENVI_CONFIG_FILE" ]]; then
|
LENVI_CONFIG_FILE="$SEARCH_DIR/Lenvi.yaml"
|
||||||
# We have the config file, now find the PHP version for the current project directory
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$LENVI_CONFIG_FILE" ]]; then
|
||||||
|
# We found a config file, now find the PHP version for the current project directory
|
||||||
CURRENT_PROJECT_ROOT=$(pwd)
|
CURRENT_PROJECT_ROOT=$(pwd)
|
||||||
PHP_VERSION=$(yq eval '.sites[] | select(.project_root == "'"$CURRENT_PROJECT_ROOT"'") | .php_version' "$LENVI_CONFIG_FILE")
|
PHP_VERSION=$(yq eval '.sites[] | select(.project_root == "'"$CURRENT_PROJECT_ROOT"'") | .php_version' "$LENVI_CONFIG_FILE")
|
||||||
|
|
||||||
if [[ -n "$PHP_VERSION" && -x "/usr/bin/php$PHP_VERSION" ]]; then
|
if [[ -n "$PHP_VERSION" && -x "/usr/bin/php$PHP_VERSION" ]]; then
|
||||||
# Version found and the corresponding PHP binary exists
|
|
||||||
PHP_BINARY="/usr/bin/php$PHP_VERSION"
|
PHP_BINARY="/usr/bin/php$PHP_VERSION"
|
||||||
echo "Lenvi: Project configuration found. Using PHP $PHP_VERSION..." >&2
|
echo "Lenvi: Project found. Using PHP $PHP_VERSION..." >&2
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If no specific PHP binary was found after checking, use the system default
|
# If no specific PHP binary was found, use the system default
|
||||||
if [[ -z "$PHP_BINARY" ]]; then
|
if [[ -z "$PHP_BINARY" ]]; then
|
||||||
echo "Lenvi: No specific project configuration found for this directory. Using default system PHP." >&2
|
echo "Lenvi: No project configuration found for this directory. Using default system PHP." >&2
|
||||||
PHP_BINARY="$DEFAULT_PHP_BINARY"
|
PHP_BINARY="$DEFAULT_PHP_BINARY"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Execute the real Composer with the determined PHP version and pass all arguments
|
|
||||||
exec "$PHP_BINARY" "$COMPOSER_PHAR" "$@"
|
exec "$PHP_BINARY" "$COMPOSER_PHAR" "$@"
|
@ -2,7 +2,7 @@ server {
|
|||||||
listen 80;
|
listen 80;
|
||||||
server_name {{ project.domain }};
|
server_name {{ project.domain }};
|
||||||
|
|
||||||
root {{ project.document_root }};
|
root {{ project.project_root }};
|
||||||
index index.php;
|
index index.php;
|
||||||
|
|
||||||
access_log /var/log/nginx/{{ project.domain }}-access.log;
|
access_log /var/log/nginx/{{ project.domain }}-access.log;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user