mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Inject a new environment variable YNH_INTERFACE to test inside helpers if we're using Yunohost from the CLI or API
This commit is contained in:
parent
a4f3248545
commit
95d2c8f799
2 changed files with 5 additions and 12 deletions
|
@ -1,14 +1,5 @@
|
||||||
#!/bin/bash
|
#!/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
|
|
||||||
# Which means the script is executed from a terminal, not from the admin JS
|
|
||||||
[[ "$TERM" =~ "xterm" ]]
|
|
||||||
}
|
|
||||||
|
|
||||||
# Manage a fail of the script
|
# Manage a fail of the script
|
||||||
#
|
#
|
||||||
# [internal]
|
# [internal]
|
||||||
|
@ -36,8 +27,8 @@ ynh_exit_properly () {
|
||||||
|
|
||||||
ynh_print_err --message="!!\n $app's script has encountered an error. Its execution was cancelled.\n!!"
|
ynh_print_err --message="!!\n $app's script has encountered an error. Its execution was cancelled.\n!!"
|
||||||
|
|
||||||
# If the script is executed from a terminal, dump the end of the log that precedes the crash.
|
# If the script is executed from the CLI, dump the end of the log that precedes the crash.
|
||||||
if ynh_is_term
|
if [ "$YNH_INTERFACE" == "cli" ]
|
||||||
then
|
then
|
||||||
# Unset xtrace to not spoil the log
|
# Unset xtrace to not spoil the log
|
||||||
set +x
|
set +x
|
||||||
|
|
|
@ -28,7 +28,7 @@ import re
|
||||||
import tempfile
|
import tempfile
|
||||||
from glob import iglob
|
from glob import iglob
|
||||||
|
|
||||||
from moulinette import m18n
|
from moulinette import m18n, msettings
|
||||||
from yunohost.utils.error import YunohostError
|
from yunohost.utils.error import YunohostError
|
||||||
from moulinette.utils import log
|
from moulinette.utils import log
|
||||||
from moulinette.utils.filesystem import read_json
|
from moulinette.utils.filesystem import read_json
|
||||||
|
@ -337,6 +337,8 @@ def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
|
||||||
env = {}
|
env = {}
|
||||||
env['YNH_CWD'] = chdir
|
env['YNH_CWD'] = chdir
|
||||||
|
|
||||||
|
env['YNH_INTERFACE'] = msettings.get('interface')
|
||||||
|
|
||||||
stdinfo = os.path.join(tempfile.mkdtemp(), "stdinfo")
|
stdinfo = os.path.join(tempfile.mkdtemp(), "stdinfo")
|
||||||
env['YNH_STDINFO'] = stdinfo
|
env['YNH_STDINFO'] = stdinfo
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue