Offer apps to set service name for ynh_spawn_app_shell

This commit is contained in:
tituspijean 2023-05-24 22:19:10 +00:00
parent a47e491869
commit 5fa58f19ce
No known key found for this signature in database
GPG key ID: EF3B0D7CC0A94720

View file

@ -159,8 +159,12 @@ ynh_spawn_app_shell() {
exit 1
fi
# Load the app's service name, or default to $app
local service=$(ynh_app_setting_get --app=$app --key=service)
[ -z "$service" ] && service=$app;
# Load the Environment variables from the app's service
local env_var=`systemctl show $app.service -p "Environment" --value`
local env_var=`systemctl show $service.service -p "Environment" --value`
[ -n "$env_var" ] && export $env_var;
export HOME=$install_dir;
@ -173,7 +177,7 @@ ynh_spawn_app_shell() {
fi
# Source the EnvironmentFiles from the app's service
local env_files=(`systemctl show $app.service -p "EnvironmentFiles" --value`)
local env_files=(`systemctl show $service.service -p "EnvironmentFiles" --value`)
if [ ${#env_files[*]} -gt 0 ]
then
# set -/+a enables and disables new variables being automatically exported. Needed when using `source`.
@ -186,7 +190,7 @@ ynh_spawn_app_shell() {
fi
# cd into the WorkingDirectory set in the service, or default to the install_dir
local env_dir = $(systemctl show $app.service -p "WorkingDirectory" --value)
local env_dir = $(systemctl show $service.service -p "WorkingDirectory" --value)
[ -z $env_dir ] && env_dir=$install_dir;
cd $env_dir