From f71117b401b5d33f703e31287913c6f7fff94076 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 17 Mar 2019 23:30:57 +0100 Subject: [PATCH] Support yunohost-api.log --- data/helpers.d/system | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/data/helpers.d/system b/data/helpers.d/system index 87529c733..3c065e592 100644 --- a/data/helpers.d/system +++ b/data/helpers.d/system @@ -1,5 +1,14 @@ #!/bin/bash +# Determine whether the scripts is executed from a terminal or the admin JS. +# +# [internal] +ynh_is_term () { + # Return true if $TERM return xterm-XXXcolor + # Which means the script is executed from a terminal, not from the admin JS + [[ "$TERM" =~ "xterm" ]] +} + # Manage a fail of the script # # [internal] @@ -29,7 +38,13 @@ ynh_exit_properly () { # Unset xtrace to not spoil the log set +x - local ynh_log="/var/log/yunohost/yunohost-cli.log" + + if ynh_is_term + then + local ynh_log="/var/log/yunohost/yunohost-cli.log" + else + local ynh_log="/var/log/yunohost/yunohost-api.log" + fi # Wait for the log to be fill with the data until the crash. local timeout=0 while ! tail --lines=20 "$ynh_log" | grep --quiet "ynh_exit_properly"