From e95482a81a9075b0034ad7261d49913de76cc02d Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Fri, 31 Aug 2018 20:44:58 +0200 Subject: [PATCH 1/3] [enh] add jq as a dependancy --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 6bb97a85a..be63436da 100644 --- a/debian/control +++ b/debian/control @@ -14,7 +14,7 @@ Depends: ${python:Depends}, ${misc:Depends} , python-psutil, python-requests, python-dnspython, python-openssl , python-apt, python-miniupnpc, python-dbus, python-jinja2 , glances - , dnsutils, bind9utils, unzip, git, curl, cron, wget + , dnsutils, bind9utils, unzip, git, curl, cron, wget, jq , ca-certificates, netcat-openbsd, iproute , mariadb-server, php-mysql | php-mysqlnd , slapd, ldap-utils, sudo-ldap, libnss-ldapd, unscd From e56616af5e7a883824ced4beb5db2d6583c6f638 Mon Sep 17 00:00:00 2001 From: irina11y <38069993+irina11y@users.noreply.github.com> Date: Sun, 2 Sep 2018 18:18:01 +0200 Subject: [PATCH 2/3] Allow to add a service description on "yunohost service add" (#529) * [enh] add a service description with YML file * moins "espace" --- data/actionsmap/yunohost.yml | 3 +++ src/yunohost/service.py | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 8509bfb23..6e2743015 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -1136,6 +1136,9 @@ service: full: --runlevel help: Runlevel priority of the service type: int + -d: + full: --description + help: Description of the service ### service_remove() remove: diff --git a/src/yunohost/service.py b/src/yunohost/service.py index 66ae837a9..dbdaa1cdf 100644 --- a/src/yunohost/service.py +++ b/src/yunohost/service.py @@ -50,7 +50,7 @@ MOULINETTE_LOCK = "/var/run/moulinette_yunohost.lock" 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 @@ -59,6 +59,7 @@ def service_add(name, status=None, log=None, runlevel=None): status -- Custom status command log -- Absolute path to log file to display runlevel -- Runlevel priority of the service + description -- description of the service """ services = _get_services() @@ -74,6 +75,9 @@ def service_add(name, status=None, log=None, runlevel=None): if runlevel is not None: services[name]['runlevel'] = runlevel + if description is not None: + services[name]['description'] = description + try: _save_services(services) except: @@ -251,7 +255,10 @@ def service_status(names=[]): else: 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's the only way to test for that for now From 64204e41daf7679d6a23dd1624a6f27aa86caf54 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 3 Sep 2018 02:38:02 +0200 Subject: [PATCH 3/3] Run hook_exec as root by default (#522) --- src/yunohost/app.py | 12 +++++------- src/yunohost/backup.py | 7 +++---- src/yunohost/hook.py | 4 ++-- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 1fed09425..62fe9129c 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -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"))) if hook_exec(os.path.join(APP_TMP_FOLDER, 'scripts/change_url'), - args=args_list, env=env_dict, user="root") != 0: + args=args_list, env=env_dict) != 0: msg = "Failed to change '%s' url." % app logger.error(msg) operation_logger.error(msg) @@ -640,7 +640,7 @@ def app_upgrade(auth, app=[], url=None, file=None): # Execute App upgrade script os.system('chown -hR admin: %s' % INSTALL_TMP) if hook_exec(extracted_app_folder + '/scripts/upgrade', - args=args_list, env=env_dict, user="root") != 0: + args=args_list, env=env_dict) != 0: msg = m18n.n('app_upgrade_failed', app=app_instance_name) 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: install_retcode = hook_exec( os.path.join(extracted_app_folder, 'scripts/install'), - args=args_list, env=env_dict, user="root" + args=args_list, env=env_dict ) except (KeyboardInterrupt, EOFError): 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( 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 ) if remove_retcode != 0: msg = m18n.n('app_not_properly_removed', @@ -912,7 +912,7 @@ def app_remove(operation_logger, auth, app): operation_logger.flush() if hook_exec('/tmp/yunohost_remove/scripts/remove', args=args_list, - env=env_dict, user="root") == 0: + env=env_dict) == 0: logger.success(m18n.n('app_removed', app=app)) 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, args=["show"], env=env, - user="root", stdout_callback=parse_stdout, ) @@ -1656,7 +1655,6 @@ def app_config_apply(app_id, args): return_code = hook_exec(config_script, args=["apply"], env=env, - user="root", ) if return_code != 0: diff --git a/src/yunohost/backup.py b/src/yunohost/backup.py index 88959cc2f..0749312d3 100644 --- a/src/yunohost/backup.py +++ b/src/yunohost/backup.py @@ -680,7 +680,7 @@ class BackupManager(): subprocess.call(['install', '-Dm555', app_script, tmp_script]) hook_exec(tmp_script, args=[tmp_app_bkp_dir, app], - raise_on_error=True, chdir=tmp_app_bkp_dir, env=env_dict, user="root") + raise_on_error=True, chdir=tmp_app_bkp_dir, env=env_dict) self._import_to_list_to_backup(env_dict["YNH_BACKUP_CSV"]) except: @@ -1310,8 +1310,7 @@ class RestoreManager(): args=[app_backup_in_archive, app_instance_name], chdir=app_backup_in_archive, raise_on_error=True, - env=env_dict, - user="root") + env=env_dict) except: msg = m18n.n('restore_app_failed',app=app_instance_name) logger.exception(msg) @@ -1336,7 +1335,7 @@ class RestoreManager(): # Execute remove script # TODO: call app_remove instead if hook_exec(remove_script, args=[app_instance_name], - env=env_dict_remove, user="root") != 0: + env=env_dict_remove) != 0: msg = m18n.n('app_not_properly_removed', app=app_instance_name) logger.warning(msg) operation_logger.error(msg) diff --git a/src/yunohost/hook.py b/src/yunohost/hook.py index 87844ce17..46c25d50d 100644 --- a/src/yunohost/hook.py +++ b/src/yunohost/hook.py @@ -281,7 +281,7 @@ def hook_callback(action, hooks=[], args=None, no_trace=False, chdir=None, hook_args = pre_callback(name=name, priority=priority, path=path, args=args) hook_exec(path, args=hook_args, chdir=chdir, env=env, - no_trace=no_trace, raise_on_error=True, user="root") + no_trace=no_trace, raise_on_error=True) except MoulinetteError as e: state = 'failed' logger.error(e.strerror, exc_info=1) @@ -298,7 +298,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, - chdir=None, env=None, user="admin", stdout_callback=None, + chdir=None, env=None, user="root", stdout_callback=None, stderr_callback=None): """ Execute hook from a file with arguments