mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge branch 'stretch-unstable' into hook_return
This commit is contained in:
commit
d03cdb4e95
6 changed files with 23 additions and 16 deletions
|
@ -1136,6 +1136,9 @@ service:
|
||||||
full: --runlevel
|
full: --runlevel
|
||||||
help: Runlevel priority of the service
|
help: Runlevel priority of the service
|
||||||
type: int
|
type: int
|
||||||
|
-d:
|
||||||
|
full: --description
|
||||||
|
help: Description of the service
|
||||||
|
|
||||||
### service_remove()
|
### service_remove()
|
||||||
remove:
|
remove:
|
||||||
|
|
2
debian/control
vendored
2
debian/control
vendored
|
@ -14,7 +14,7 @@ Depends: ${python:Depends}, ${misc:Depends}
|
||||||
, python-psutil, python-requests, python-dnspython, python-openssl
|
, python-psutil, python-requests, python-dnspython, python-openssl
|
||||||
, python-apt, python-miniupnpc, python-dbus, python-jinja2
|
, python-apt, python-miniupnpc, python-dbus, python-jinja2
|
||||||
, glances
|
, glances
|
||||||
, dnsutils, bind9utils, unzip, git, curl, cron, wget
|
, dnsutils, bind9utils, unzip, git, curl, cron, wget, jq
|
||||||
, ca-certificates, netcat-openbsd, iproute
|
, ca-certificates, netcat-openbsd, iproute
|
||||||
, mariadb-server, php-mysql | php-mysqlnd
|
, mariadb-server, php-mysql | php-mysqlnd
|
||||||
, slapd, ldap-utils, sudo-ldap, libnss-ldapd, unscd
|
, slapd, ldap-utils, sudo-ldap, libnss-ldapd, unscd
|
||||||
|
|
|
@ -513,7 +513,7 @@ def app_change_url(operation_logger, auth, app, domain, path):
|
||||||
os.system('chmod +x %s' % os.path.join(os.path.join(APP_TMP_FOLDER, "scripts", "change_url")))
|
os.system('chmod +x %s' % os.path.join(os.path.join(APP_TMP_FOLDER, "scripts", "change_url")))
|
||||||
|
|
||||||
if hook_exec(os.path.join(APP_TMP_FOLDER, 'scripts/change_url'),
|
if hook_exec(os.path.join(APP_TMP_FOLDER, 'scripts/change_url'),
|
||||||
args=args_list, env=env_dict, user="root")[0] != 0:
|
args=args_list, env=env_dict)[0] != 0:
|
||||||
msg = "Failed to change '%s' url." % app
|
msg = "Failed to change '%s' url." % app
|
||||||
logger.error(msg)
|
logger.error(msg)
|
||||||
operation_logger.error(msg)
|
operation_logger.error(msg)
|
||||||
|
@ -640,7 +640,7 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
||||||
# Execute App upgrade script
|
# Execute App upgrade script
|
||||||
os.system('chown -hR admin: %s' % INSTALL_TMP)
|
os.system('chown -hR admin: %s' % INSTALL_TMP)
|
||||||
if hook_exec(extracted_app_folder + '/scripts/upgrade',
|
if hook_exec(extracted_app_folder + '/scripts/upgrade',
|
||||||
args=args_list, env=env_dict, user="root")[0] != 0:
|
args=args_list, env=env_dict)[0] != 0:
|
||||||
msg = m18n.n('app_upgrade_failed', app=app_instance_name)
|
msg = m18n.n('app_upgrade_failed', app=app_instance_name)
|
||||||
logger.error(msg)
|
logger.error(msg)
|
||||||
operation_logger.error(msg)
|
operation_logger.error(msg)
|
||||||
|
@ -800,7 +800,7 @@ def app_install(operation_logger, auth, app, label=None, args=None, no_remove_on
|
||||||
try:
|
try:
|
||||||
install_retcode = hook_exec(
|
install_retcode = hook_exec(
|
||||||
os.path.join(extracted_app_folder, 'scripts/install'),
|
os.path.join(extracted_app_folder, 'scripts/install'),
|
||||||
args=args_list, env=env_dict, user="root"
|
args=args_list, env=env_dict
|
||||||
)[0]
|
)[0]
|
||||||
except (KeyboardInterrupt, EOFError):
|
except (KeyboardInterrupt, EOFError):
|
||||||
install_retcode = -1
|
install_retcode = -1
|
||||||
|
@ -824,7 +824,7 @@ def app_install(operation_logger, auth, app, label=None, args=None, no_remove_on
|
||||||
|
|
||||||
remove_retcode = hook_exec(
|
remove_retcode = hook_exec(
|
||||||
os.path.join(extracted_app_folder, 'scripts/remove'),
|
os.path.join(extracted_app_folder, 'scripts/remove'),
|
||||||
args=[app_instance_name], env=env_dict_remove, user="root"
|
args=[app_instance_name], env=env_dict_remove
|
||||||
)[0]
|
)[0]
|
||||||
if remove_retcode != 0:
|
if remove_retcode != 0:
|
||||||
msg = m18n.n('app_not_properly_removed',
|
msg = m18n.n('app_not_properly_removed',
|
||||||
|
@ -912,7 +912,7 @@ def app_remove(operation_logger, auth, app):
|
||||||
operation_logger.flush()
|
operation_logger.flush()
|
||||||
|
|
||||||
if hook_exec('/tmp/yunohost_remove/scripts/remove', args=args_list,
|
if hook_exec('/tmp/yunohost_remove/scripts/remove', args=args_list,
|
||||||
env=env_dict, user="root")[0] == 0:
|
env=env_dict)[0] == 0:
|
||||||
logger.success(m18n.n('app_removed', app=app))
|
logger.success(m18n.n('app_removed', app=app))
|
||||||
|
|
||||||
hook_callback('post_app_remove', args=args_list, env=env_dict)
|
hook_callback('post_app_remove', args=args_list, env=env_dict)
|
||||||
|
@ -1573,7 +1573,6 @@ def app_config_show_panel(app_id):
|
||||||
return_code = hook_exec(config_script,
|
return_code = hook_exec(config_script,
|
||||||
args=["show"],
|
args=["show"],
|
||||||
env=env,
|
env=env,
|
||||||
user="root",
|
|
||||||
stdout_callback=parse_stdout,
|
stdout_callback=parse_stdout,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1656,7 +1655,6 @@ def app_config_apply(app_id, args):
|
||||||
return_code = hook_exec(config_script,
|
return_code = hook_exec(config_script,
|
||||||
args=["apply"],
|
args=["apply"],
|
||||||
env=env,
|
env=env,
|
||||||
user="root",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if return_code != 0:
|
if return_code != 0:
|
||||||
|
|
|
@ -680,7 +680,7 @@ class BackupManager():
|
||||||
subprocess.call(['install', '-Dm555', app_script, tmp_script])
|
subprocess.call(['install', '-Dm555', app_script, tmp_script])
|
||||||
|
|
||||||
hook_exec(tmp_script, args=[tmp_app_bkp_dir, app],
|
hook_exec(tmp_script, args=[tmp_app_bkp_dir, app],
|
||||||
raise_on_error=True, chdir=tmp_app_bkp_dir, env=env_dict, user="root")[0]
|
raise_on_error=True, chdir=tmp_app_bkp_dir, env=env_dict)[0]
|
||||||
|
|
||||||
self._import_to_list_to_backup(env_dict["YNH_BACKUP_CSV"])
|
self._import_to_list_to_backup(env_dict["YNH_BACKUP_CSV"])
|
||||||
except:
|
except:
|
||||||
|
@ -1310,8 +1310,7 @@ class RestoreManager():
|
||||||
args=[app_backup_in_archive, app_instance_name],
|
args=[app_backup_in_archive, app_instance_name],
|
||||||
chdir=app_backup_in_archive,
|
chdir=app_backup_in_archive,
|
||||||
raise_on_error=True,
|
raise_on_error=True,
|
||||||
env=env_dict,
|
env=env_dict)[0]
|
||||||
user="root")[0]
|
|
||||||
except:
|
except:
|
||||||
msg = m18n.n('restore_app_failed',app=app_instance_name)
|
msg = m18n.n('restore_app_failed',app=app_instance_name)
|
||||||
logger.exception(msg)
|
logger.exception(msg)
|
||||||
|
@ -1336,7 +1335,7 @@ class RestoreManager():
|
||||||
# Execute remove script
|
# Execute remove script
|
||||||
# TODO: call app_remove instead
|
# TODO: call app_remove instead
|
||||||
if hook_exec(remove_script, args=[app_instance_name],
|
if hook_exec(remove_script, args=[app_instance_name],
|
||||||
env=env_dict_remove, user="root")[0] != 0:
|
env=env_dict_remove)[0] != 0:
|
||||||
msg = m18n.n('app_not_properly_removed', app=app_instance_name)
|
msg = m18n.n('app_not_properly_removed', app=app_instance_name)
|
||||||
logger.warning(msg)
|
logger.warning(msg)
|
||||||
operation_logger.error(msg)
|
operation_logger.error(msg)
|
||||||
|
|
|
@ -282,7 +282,7 @@ def hook_callback(action, hooks=[], args=None, no_trace=False, chdir=None,
|
||||||
hook_args = pre_callback(name=name, priority=priority,
|
hook_args = pre_callback(name=name, priority=priority,
|
||||||
path=path, args=args)
|
path=path, args=args)
|
||||||
hook_return = hook_exec(path, args=hook_args, chdir=chdir, env=env,
|
hook_return = hook_exec(path, args=hook_args, chdir=chdir, env=env,
|
||||||
no_trace=no_trace, raise_on_error=True, user="root")[1]
|
no_trace=no_trace, raise_on_error=True)[1]
|
||||||
except MoulinetteError as e:
|
except MoulinetteError as e:
|
||||||
state = 'failed'
|
state = 'failed'
|
||||||
logger.error(e.strerror, exc_info=1)
|
logger.error(e.strerror, exc_info=1)
|
||||||
|
@ -297,7 +297,7 @@ def hook_callback(action, hooks=[], args=None, no_trace=False, chdir=None,
|
||||||
|
|
||||||
|
|
||||||
def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
|
def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
|
||||||
chdir=None, env=None, user="admin", stdout_callback=None,
|
chdir=None, env=None, user="root", stdout_callback=None,
|
||||||
stderr_callback=None):
|
stderr_callback=None):
|
||||||
"""
|
"""
|
||||||
Execute hook from a file with arguments
|
Execute hook from a file with arguments
|
||||||
|
|
|
@ -50,7 +50,7 @@ MOULINETTE_LOCK = "/var/run/moulinette_yunohost.lock"
|
||||||
logger = log.getActionLogger('yunohost.service')
|
logger = log.getActionLogger('yunohost.service')
|
||||||
|
|
||||||
|
|
||||||
def service_add(name, status=None, log=None, runlevel=None):
|
def service_add(name, status=None, log=None, runlevel=None, description=None):
|
||||||
"""
|
"""
|
||||||
Add a custom service
|
Add a custom service
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ def service_add(name, status=None, log=None, runlevel=None):
|
||||||
status -- Custom status command
|
status -- Custom status command
|
||||||
log -- Absolute path to log file to display
|
log -- Absolute path to log file to display
|
||||||
runlevel -- Runlevel priority of the service
|
runlevel -- Runlevel priority of the service
|
||||||
|
description -- description of the service
|
||||||
|
|
||||||
"""
|
"""
|
||||||
services = _get_services()
|
services = _get_services()
|
||||||
|
@ -74,6 +75,9 @@ def service_add(name, status=None, log=None, runlevel=None):
|
||||||
if runlevel is not None:
|
if runlevel is not None:
|
||||||
services[name]['runlevel'] = runlevel
|
services[name]['runlevel'] = runlevel
|
||||||
|
|
||||||
|
if description is not None:
|
||||||
|
services[name]['description'] = description
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_save_services(services)
|
_save_services(services)
|
||||||
except:
|
except:
|
||||||
|
@ -251,7 +255,10 @@ def service_status(names=[]):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
translation_key = "service_description_%s" % name
|
translation_key = "service_description_%s" % name
|
||||||
description = m18n.n(translation_key)
|
if "description" in services[name] is not None:
|
||||||
|
description = services[name].get("description")
|
||||||
|
else:
|
||||||
|
description = m18n.n(translation_key)
|
||||||
|
|
||||||
# that mean that we don't have a translation for this string
|
# that mean that we don't have a translation for this string
|
||||||
# that's the only way to test for that for now
|
# that's the only way to test for that for now
|
||||||
|
|
Loading…
Add table
Reference in a new issue