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/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 diff --git a/src/yunohost/app.py b/src/yunohost/app.py index bad1797b3..ff12f5878 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] != 0: + args=args_list, env=env_dict)[0] != 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] != 0: + args=args_list, env=env_dict)[0] != 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 )[0] 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 )[0] 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] == 0: + env=env_dict)[0] == 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 bad2f53c2..2aee2bee1 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")[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"]) 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")[0] + env=env_dict)[0] 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] != 0: + env=env_dict_remove)[0] != 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 7ad95c8ab..121630e9f 100644 --- a/src/yunohost/hook.py +++ b/src/yunohost/hook.py @@ -282,7 +282,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_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: state = 'failed' 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, - 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 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