mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Explicitely tell when to start the uo logging to avoid displaying the message about logs when not needed
This commit is contained in:
parent
37c5547755
commit
5e99db7c63
6 changed files with 33 additions and 22 deletions
|
@ -191,8 +191,8 @@ def app_fetchlist(url=None, name=None):
|
||||||
_write_appslist_list(appslists)
|
_write_appslist_list(appslists)
|
||||||
|
|
||||||
|
|
||||||
@is_unit_operation()
|
@is_unit_operation(auto=False)
|
||||||
def app_removelist(name):
|
def app_removelist(uo, name):
|
||||||
"""
|
"""
|
||||||
Remove list from the repositories
|
Remove list from the repositories
|
||||||
|
|
||||||
|
@ -206,6 +206,8 @@ def app_removelist(name):
|
||||||
if name not in appslists.keys():
|
if name not in appslists.keys():
|
||||||
raise MoulinetteError(errno.ENOENT, m18n.n('appslist_unknown', appslist=name))
|
raise MoulinetteError(errno.ENOENT, m18n.n('appslist_unknown', appslist=name))
|
||||||
|
|
||||||
|
uo.start()
|
||||||
|
|
||||||
# Remove json
|
# Remove json
|
||||||
json_path = '%s/%s.json' % (REPO_PATH, name)
|
json_path = '%s/%s.json' % (REPO_PATH, name)
|
||||||
if os.path.exists(json_path):
|
if os.path.exists(json_path):
|
||||||
|
|
|
@ -162,7 +162,6 @@ def _certificate_install_selfsigned(domain_list, force=False):
|
||||||
|
|
||||||
uo = UnitOperation('selfsigned_cert_install', [('domain', domain)],
|
uo = UnitOperation('selfsigned_cert_install', [('domain', domain)],
|
||||||
args={'force': force})
|
args={'force': force})
|
||||||
uo.start()
|
|
||||||
|
|
||||||
# Paths of files and folder we'll need
|
# Paths of files and folder we'll need
|
||||||
date_tag = datetime.now().strftime("%Y%m%d.%H%M%S")
|
date_tag = datetime.now().strftime("%Y%m%d.%H%M%S")
|
||||||
|
@ -186,6 +185,8 @@ def _certificate_install_selfsigned(domain_list, force=False):
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||||
'certmanager_attempt_to_replace_valid_cert', domain=domain))
|
'certmanager_attempt_to_replace_valid_cert', domain=domain))
|
||||||
|
|
||||||
|
uo.start()
|
||||||
|
|
||||||
# Create output folder for new certificate stuff
|
# Create output folder for new certificate stuff
|
||||||
os.makedirs(new_cert_folder)
|
os.makedirs(new_cert_folder)
|
||||||
|
|
||||||
|
@ -288,8 +289,6 @@ def _certificate_install_letsencrypt(auth, domain_list, force=False, no_checks=F
|
||||||
uo = UnitOperation('letsencrypt_cert_install', [('domain', domain)],
|
uo = UnitOperation('letsencrypt_cert_install', [('domain', domain)],
|
||||||
args={'force': force, 'no_checks': no_checks,
|
args={'force': force, 'no_checks': no_checks,
|
||||||
'staging': staging})
|
'staging': staging})
|
||||||
uo.start()
|
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"Now attempting install of certificate for domain %s!", domain)
|
"Now attempting install of certificate for domain %s!", domain)
|
||||||
|
|
||||||
|
@ -297,6 +296,8 @@ def _certificate_install_letsencrypt(auth, domain_list, force=False, no_checks=F
|
||||||
if not no_checks:
|
if not no_checks:
|
||||||
_check_domain_is_ready_for_ACME(domain)
|
_check_domain_is_ready_for_ACME(domain)
|
||||||
|
|
||||||
|
uo.start()
|
||||||
|
|
||||||
_configure_for_acme_challenge(auth, domain)
|
_configure_for_acme_challenge(auth, domain)
|
||||||
_fetch_and_enable_new_certificate(domain, staging)
|
_fetch_and_enable_new_certificate(domain, staging)
|
||||||
_install_cron()
|
_install_cron()
|
||||||
|
@ -389,7 +390,6 @@ def certificate_renew(auth, domain_list, force=False, no_checks=False, email=Fal
|
||||||
uo = UnitOperation('letsencrypt_cert_renew', [('domain', domain)],
|
uo = UnitOperation('letsencrypt_cert_renew', [('domain', domain)],
|
||||||
args={'force': force, 'no_checks': no_checks,
|
args={'force': force, 'no_checks': no_checks,
|
||||||
'staging': staging, 'email': email})
|
'staging': staging, 'email': email})
|
||||||
uo.start()
|
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"Now attempting renewing of certificate for domain %s !", domain)
|
"Now attempting renewing of certificate for domain %s !", domain)
|
||||||
|
@ -398,6 +398,8 @@ def certificate_renew(auth, domain_list, force=False, no_checks=False, email=Fal
|
||||||
if not no_checks:
|
if not no_checks:
|
||||||
_check_domain_is_ready_for_ACME(domain)
|
_check_domain_is_ready_for_ACME(domain)
|
||||||
|
|
||||||
|
uo.start()
|
||||||
|
|
||||||
_fetch_and_enable_new_certificate(domain, staging)
|
_fetch_and_enable_new_certificate(domain, staging)
|
||||||
|
|
||||||
logger.success(
|
logger.success(
|
||||||
|
|
|
@ -62,8 +62,8 @@ def domain_list(auth):
|
||||||
return {'domains': result_list}
|
return {'domains': result_list}
|
||||||
|
|
||||||
|
|
||||||
@is_unit_operation()
|
@is_unit_operation(auto=False)
|
||||||
def domain_add(auth, domain, dyndns=False):
|
def domain_add(uo, auth, domain, dyndns=False):
|
||||||
"""
|
"""
|
||||||
Create a custom domain
|
Create a custom domain
|
||||||
|
|
||||||
|
@ -80,6 +80,8 @@ def domain_add(auth, domain, dyndns=False):
|
||||||
except MoulinetteError:
|
except MoulinetteError:
|
||||||
raise MoulinetteError(errno.EEXIST, m18n.n('domain_exists'))
|
raise MoulinetteError(errno.EEXIST, m18n.n('domain_exists'))
|
||||||
|
|
||||||
|
uo.start()
|
||||||
|
|
||||||
# DynDNS domain
|
# DynDNS domain
|
||||||
if dyndns:
|
if dyndns:
|
||||||
|
|
||||||
|
@ -131,8 +133,8 @@ def domain_add(auth, domain, dyndns=False):
|
||||||
logger.success(m18n.n('domain_created'))
|
logger.success(m18n.n('domain_created'))
|
||||||
|
|
||||||
|
|
||||||
@is_unit_operation()
|
@is_unit_operation(auto=False)
|
||||||
def domain_remove(auth, domain, force=False):
|
def domain_remove(uo, auth, domain, force=False):
|
||||||
"""
|
"""
|
||||||
Delete domains
|
Delete domains
|
||||||
|
|
||||||
|
@ -163,6 +165,7 @@ def domain_remove(auth, domain, force=False):
|
||||||
raise MoulinetteError(errno.EPERM,
|
raise MoulinetteError(errno.EPERM,
|
||||||
m18n.n('domain_uninstall_app_first'))
|
m18n.n('domain_uninstall_app_first'))
|
||||||
|
|
||||||
|
uo.start()
|
||||||
if auth.remove('virtualdomain=' + domain + ',ou=domains') or force:
|
if auth.remove('virtualdomain=' + domain + ',ou=domains') or force:
|
||||||
os.system('rm -rf /etc/yunohost/certs/%s' % domain)
|
os.system('rm -rf /etc/yunohost/certs/%s' % domain)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -127,7 +127,6 @@ def dyndns_subscribe(uo, subscribe_host="dyndns.yunohost.org", domain=None, key=
|
||||||
if domain is None:
|
if domain is None:
|
||||||
domain = _get_maindomain()
|
domain = _get_maindomain()
|
||||||
uo.related_to.append(('domain', domain))
|
uo.related_to.append(('domain', domain))
|
||||||
uo.start()
|
|
||||||
|
|
||||||
# Verify if domain is provided by subscribe_host
|
# Verify if domain is provided by subscribe_host
|
||||||
if not _dyndns_provides(subscribe_host, domain):
|
if not _dyndns_provides(subscribe_host, domain):
|
||||||
|
@ -140,6 +139,8 @@ def dyndns_subscribe(uo, subscribe_host="dyndns.yunohost.org", domain=None, key=
|
||||||
raise MoulinetteError(errno.ENOENT,
|
raise MoulinetteError(errno.ENOENT,
|
||||||
m18n.n('dyndns_unavailable', domain=domain))
|
m18n.n('dyndns_unavailable', domain=domain))
|
||||||
|
|
||||||
|
uo.start()
|
||||||
|
|
||||||
if key is None:
|
if key is None:
|
||||||
if len(glob.glob('/etc/yunohost/dyndns/*.key')) == 0:
|
if len(glob.glob('/etc/yunohost/dyndns/*.key')) == 0:
|
||||||
if not os.path.exists('/etc/yunohost/dyndns'):
|
if not os.path.exists('/etc/yunohost/dyndns'):
|
||||||
|
@ -217,17 +218,12 @@ def dyndns_update(uo, dyn_host="dyndns.yunohost.org", domain=None, key=None,
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
logger.info("Updated needed, going on...")
|
logger.info("Updated needed, going on...")
|
||||||
if domain is not None:
|
|
||||||
uo.related_to.append(('domain', domain))
|
|
||||||
|
|
||||||
# If domain is not given, try to guess it from keys available...
|
# If domain is not given, try to guess it from keys available...
|
||||||
if domain is None:
|
if domain is None:
|
||||||
(domain, key) = _guess_current_dyndns_domain(dyn_host)
|
(domain, key) = _guess_current_dyndns_domain(dyn_host)
|
||||||
uo.related_to.append(('domain', domain))
|
|
||||||
uo.start()
|
|
||||||
# If key is not given, pick the first file we find with the domain given
|
# If key is not given, pick the first file we find with the domain given
|
||||||
else:
|
else:
|
||||||
uo.start()
|
|
||||||
if key is None:
|
if key is None:
|
||||||
keys = glob.glob('/etc/yunohost/dyndns/K{0}.+*.private'.format(domain))
|
keys = glob.glob('/etc/yunohost/dyndns/K{0}.+*.private'.format(domain))
|
||||||
|
|
||||||
|
@ -236,6 +232,9 @@ def dyndns_update(uo, dyn_host="dyndns.yunohost.org", domain=None, key=None,
|
||||||
|
|
||||||
key = keys[0]
|
key = keys[0]
|
||||||
|
|
||||||
|
uo.related_to.append(('domain', domain))
|
||||||
|
uo.start()
|
||||||
|
|
||||||
# This mean that hmac-md5 is used
|
# This mean that hmac-md5 is used
|
||||||
# (Re?)Trigger the migration to sha256 and return immediately.
|
# (Re?)Trigger the migration to sha256 and return immediately.
|
||||||
# The actual update will be done in next run.
|
# The actual update will be done in next run.
|
||||||
|
|
|
@ -249,8 +249,8 @@ def _is_inside_container():
|
||||||
return out.split()[1] != "(1,"
|
return out.split()[1] != "(1,"
|
||||||
|
|
||||||
|
|
||||||
@is_unit_operation()
|
@is_unit_operation(auto=False)
|
||||||
def tools_postinstall(domain, password, ignore_dyndns=False):
|
def tools_postinstall(uo, domain, password, ignore_dyndns=False):
|
||||||
"""
|
"""
|
||||||
YunoHost post-install
|
YunoHost post-install
|
||||||
|
|
||||||
|
@ -299,6 +299,7 @@ def tools_postinstall(domain, password, ignore_dyndns=False):
|
||||||
else:
|
else:
|
||||||
dyndns = False
|
dyndns = False
|
||||||
|
|
||||||
|
uo.start()
|
||||||
logger.info(m18n.n('yunohost_installing'))
|
logger.info(m18n.n('yunohost_installing'))
|
||||||
|
|
||||||
service_regen_conf(['nslcd', 'nsswitch'], force=True)
|
service_regen_conf(['nslcd', 'nsswitch'], force=True)
|
||||||
|
|
|
@ -99,8 +99,8 @@ def user_list(auth, fields=None):
|
||||||
return {'users': users}
|
return {'users': users}
|
||||||
|
|
||||||
|
|
||||||
@is_unit_operation('username:user')
|
@is_unit_operation('username:user', auto=False)
|
||||||
def user_create(auth, username, firstname, lastname, mail, password,
|
def user_create(uo, auth, username, firstname, lastname, mail, password,
|
||||||
mailbox_quota="0"):
|
mailbox_quota="0"):
|
||||||
"""
|
"""
|
||||||
Create user
|
Create user
|
||||||
|
@ -136,6 +136,8 @@ def user_create(auth, username, firstname, lastname, mail, password,
|
||||||
m18n.n('mail_domain_unknown',
|
m18n.n('mail_domain_unknown',
|
||||||
domain=mail.split("@")[1]))
|
domain=mail.split("@")[1]))
|
||||||
|
|
||||||
|
uo.start()
|
||||||
|
|
||||||
# Get random UID/GID
|
# Get random UID/GID
|
||||||
all_uid = {x.pw_uid for x in pwd.getpwall()}
|
all_uid = {x.pw_uid for x in pwd.getpwall()}
|
||||||
all_gid = {x.pw_gid for x in pwd.getpwall()}
|
all_gid = {x.pw_gid for x in pwd.getpwall()}
|
||||||
|
@ -257,8 +259,8 @@ def user_delete(auth, username, purge=False):
|
||||||
logger.success(m18n.n('user_deleted'))
|
logger.success(m18n.n('user_deleted'))
|
||||||
|
|
||||||
|
|
||||||
@is_unit_operation('username:user', exclude='auth,change_password')
|
@is_unit_operation('username:user', exclude='auth,change_password', auto=False)
|
||||||
def user_update(auth, username, firstname=None, lastname=None, mail=None,
|
def user_update(uo, auth, username, firstname=None, lastname=None, mail=None,
|
||||||
change_password=None, add_mailforward=None, remove_mailforward=None,
|
change_password=None, add_mailforward=None, remove_mailforward=None,
|
||||||
add_mailalias=None, remove_mailalias=None, mailbox_quota=None):
|
add_mailalias=None, remove_mailalias=None, mailbox_quota=None):
|
||||||
"""
|
"""
|
||||||
|
@ -359,6 +361,8 @@ def user_update(auth, username, firstname=None, lastname=None, mail=None,
|
||||||
if mailbox_quota is not None:
|
if mailbox_quota is not None:
|
||||||
new_attr_dict['mailuserquota'] = mailbox_quota
|
new_attr_dict['mailuserquota'] = mailbox_quota
|
||||||
|
|
||||||
|
uo.start()
|
||||||
|
|
||||||
if auth.update('uid=%s,ou=users' % username, new_attr_dict):
|
if auth.update('uid=%s,ou=users' % username, new_attr_dict):
|
||||||
logger.success(m18n.n('user_updated'))
|
logger.success(m18n.n('user_updated'))
|
||||||
app_ssowatconf(auth)
|
app_ssowatconf(auth)
|
||||||
|
|
Loading…
Add table
Reference in a new issue