diff --git a/scripts/_common.sh b/scripts/_common.sh index 599c71e..9934791 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,6 +4,12 @@ # COMMON VARIABLES #================================================= +# Define a function to execute commands with `php_exec` +php_exec() { + (cd "$install_dir" && ynh_exec_as "$app" \ + php${phpversion} "$install_dir/bin/console" --no-interaction --env=prod "$@") +} + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 359b84b..fc4b7cb 100644 --- a/scripts/install +++ b/scripts/install @@ -45,22 +45,19 @@ ynh_add_config --template="parameters.yml" --destination="$install_dir/app/confi chmod 600 "$install_dir/app/config/parameters.yml" chown "$app:$app" "$install_dir/app/config/parameters.yml" -# Alias for php-cli execution command -php_exec=("php$phpversion" "$install_dir/bin/console" --no-interaction --env=prod) - # Install dependencies and Wallabag -ynh_exec_warn_less ynh_exec_as "$app" "${php_exec[@]}" wallabag:install +php_exec wallabag:install # Add users to Wallabag for username in $(ynh_user_list); do user_email=$(ynh_user_get_info --username="$username" --key=mail) # We don't care about that thanks to LDAP user_pass=$(ynh_string_random) - ynh_exec_as "$app" "${php_exec[@]}" fos:user:create "$username" "$user_email" "$user_pass" + php_exec fos:user:create "$username" "$user_email" "$user_pass" done # Set admin user -ynh_exec_as "$app" "${php_exec[@]}" fos:user:promote --super "$admin" +php_exec fos:user:promote --super "$admin" # Configure Wallabag instance URL ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" \ diff --git a/scripts/upgrade b/scripts/upgrade index 916c9ca..e040482 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -32,12 +32,9 @@ fi #================================================= ynh_script_progression --message="Reconfiguring $app..." --weight=1 -# Alias for php-cli execution command -php_exec=("php$phpversion" "$install_dir/bin/console" --no-interaction --env=prod) - # Upgrade database and clear the cache -ynh_exec_as "$app" "${php_exec[@]}" doctrine:migrations:migrate -ynh_exec_as "$app" "${php_exec[@]}" cache:clear +php_exec doctrine:migrations:migrate +php_exec cache:clear # Configure Wallabag instance URL ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" \