mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Added a .strip() to moulinette's check_output because was tired of adding it all over the places
This commit is contained in:
parent
5c19fb0a42
commit
7aa3ff5255
6 changed files with 12 additions and 12 deletions
|
@ -21,12 +21,12 @@ class BaseSystemDiagnoser(Diagnoser):
|
||||||
# Detect virt technology (if not bare metal) and arch
|
# Detect virt technology (if not bare metal) and arch
|
||||||
# Gotta have this "|| true" because it systemd-detect-virt return 'none'
|
# Gotta have this "|| true" because it systemd-detect-virt return 'none'
|
||||||
# with an error code on bare metal ~.~
|
# with an error code on bare metal ~.~
|
||||||
virt = check_output("systemd-detect-virt || true", shell=True).strip()
|
virt = check_output("systemd-detect-virt || true", shell=True)
|
||||||
if virt.lower() == "none":
|
if virt.lower() == "none":
|
||||||
virt = "bare-metal"
|
virt = "bare-metal"
|
||||||
|
|
||||||
# Detect arch
|
# Detect arch
|
||||||
arch = check_output("dpkg --print-architecture").strip()
|
arch = check_output("dpkg --print-architecture")
|
||||||
hardware = dict(meta={"test": "hardware"},
|
hardware = dict(meta={"test": "hardware"},
|
||||||
status="INFO",
|
status="INFO",
|
||||||
data={"virt": virt, "arch": arch},
|
data={"virt": virt, "arch": arch},
|
||||||
|
@ -102,7 +102,7 @@ class BaseSystemDiagnoser(Diagnoser):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
cmd = "LC_ALL=C apt policy %s 2>&1 | grep http -B1 | tr -d '*' | grep '+deb' | grep -v 'gbp' | head -n 1 | awk '{print $1}'" % package
|
cmd = "LC_ALL=C apt policy %s 2>&1 | grep http -B1 | tr -d '*' | grep '+deb' | grep -v 'gbp' | head -n 1 | awk '{print $1}'" % package
|
||||||
version_to_downgrade_to = check_output(cmd).strip()
|
version_to_downgrade_to = check_output(cmd)
|
||||||
yield (package, version_to_downgrade_to)
|
yield (package, version_to_downgrade_to)
|
||||||
|
|
||||||
def is_vulnerable_to_meltdown(self):
|
def is_vulnerable_to_meltdown(self):
|
||||||
|
|
|
@ -206,7 +206,7 @@ class DNSRecordsDiagnoser(Diagnoser):
|
||||||
Return the expiration datetime of a domain or None
|
Return the expiration datetime of a domain or None
|
||||||
"""
|
"""
|
||||||
command = "whois -H %s || echo failed" % (domain)
|
command = "whois -H %s || echo failed" % (domain)
|
||||||
out = check_output(command).strip().split("\n")
|
out = check_output(command).split("\n")
|
||||||
|
|
||||||
# Reduce output to determine if whois answer is equivalent to NOT FOUND
|
# Reduce output to determine if whois answer is equivalent to NOT FOUND
|
||||||
filtered_out = [line for line in out
|
filtered_out = [line for line in out
|
||||||
|
|
|
@ -201,7 +201,7 @@ class MailDiagnoser(Diagnoser):
|
||||||
|
|
||||||
command = 'postqueue -p | grep -v "Mail queue is empty" | grep -c "^[A-Z0-9]" || true'
|
command = 'postqueue -p | grep -v "Mail queue is empty" | grep -c "^[A-Z0-9]" || true'
|
||||||
try:
|
try:
|
||||||
output = check_output(command).strip()
|
output = check_output(command)
|
||||||
pending_emails = int(output)
|
pending_emails = int(output)
|
||||||
except (ValueError, CalledProcessError) as e:
|
except (ValueError, CalledProcessError) as e:
|
||||||
yield dict(meta={"test": "mail_queue"},
|
yield dict(meta={"test": "mail_queue"},
|
||||||
|
|
|
@ -184,7 +184,7 @@ class MyMigration(Migration):
|
||||||
" | awk '{print $1}'" \
|
" | awk '{print $1}'" \
|
||||||
" | { grep 'ynh-deps$' || true; }"
|
" | { grep 'ynh-deps$' || true; }"
|
||||||
|
|
||||||
output = check_output(command).strip()
|
output = check_output(command)
|
||||||
|
|
||||||
return output.split('\n') if output else []
|
return output.split('\n') if output else []
|
||||||
|
|
||||||
|
@ -214,13 +214,13 @@ class MyMigration(Migration):
|
||||||
|
|
||||||
def validate_and_upgrade_cert_if_necessary(self):
|
def validate_and_upgrade_cert_if_necessary(self):
|
||||||
|
|
||||||
active_certs = set(check_output("grep -roh '/.*crt.pem' /etc/nginx/").strip().split("\n"))
|
active_certs = set(check_output("grep -roh '/.*crt.pem' /etc/nginx/").split("\n"))
|
||||||
|
|
||||||
cmd = "LC_ALL=C openssl x509 -in %s -text -noout | grep -i 'Signature Algorithm:' | awk '{print $3}' | uniq"
|
cmd = "LC_ALL=C openssl x509 -in %s -text -noout | grep -i 'Signature Algorithm:' | awk '{print $3}' | uniq"
|
||||||
|
|
||||||
default_crt = '/etc/yunohost/certs/yunohost.org/crt.pem'
|
default_crt = '/etc/yunohost/certs/yunohost.org/crt.pem'
|
||||||
default_key = '/etc/yunohost/certs/yunohost.org/key.pem'
|
default_key = '/etc/yunohost/certs/yunohost.org/key.pem'
|
||||||
default_signature = check_output(cmd % default_crt).strip() if default_crt in active_certs else None
|
default_signature = check_output(cmd % default_crt) if default_crt in active_certs else None
|
||||||
if default_signature is not None and (default_signature.startswith("md5") or default_signature.startswith("sha1")):
|
if default_signature is not None and (default_signature.startswith("md5") or default_signature.startswith("sha1")):
|
||||||
logger.warning("%s is using a pretty old certificate incompatible with newer versions of nginx ... attempting to regenerate a fresh one" % default_crt)
|
logger.warning("%s is using a pretty old certificate incompatible with newer versions of nginx ... attempting to regenerate a fresh one" % default_crt)
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ class MyMigration(Migration):
|
||||||
os.system("mv %s.old %s" % (default_crt, default_crt))
|
os.system("mv %s.old %s" % (default_crt, default_crt))
|
||||||
os.system("mv %s.old %s" % (default_key, default_key))
|
os.system("mv %s.old %s" % (default_key, default_key))
|
||||||
|
|
||||||
signatures = {cert: check_output(cmd % cert).strip() for cert in active_certs}
|
signatures = {cert: check_output(cmd % cert) for cert in active_certs}
|
||||||
|
|
||||||
def cert_is_weak(cert):
|
def cert_is_weak(cert):
|
||||||
sig = signatures[cert]
|
sig = signatures[cert]
|
||||||
|
|
|
@ -216,8 +216,8 @@ def dyndns_update(operation_logger, dyn_host="dyndns.yunohost.org", domain=None,
|
||||||
'zone %s' % host,
|
'zone %s' % host,
|
||||||
]
|
]
|
||||||
|
|
||||||
old_ipv4 = check_output("dig @%s +short %s" % (dyn_host, domain)).strip() or None
|
old_ipv4 = check_output("dig @%s +short %s" % (dyn_host, domain)) or None
|
||||||
old_ipv6 = check_output("dig @%s +short aaaa %s" % (dyn_host, domain)).strip() or None
|
old_ipv6 = check_output("dig @%s +short aaaa %s" % (dyn_host, domain)) or None
|
||||||
|
|
||||||
# Get current IPv4 and IPv6
|
# Get current IPv4 and IPv6
|
||||||
ipv4_ = get_public_ip()
|
ipv4_ = get_public_ip()
|
||||||
|
|
|
@ -95,7 +95,7 @@ def ynh_packages_version(*args, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def dpkg_is_broken():
|
def dpkg_is_broken():
|
||||||
if check_output("dpkg --audit").strip() != "":
|
if check_output("dpkg --audit") != "":
|
||||||
return True
|
return True
|
||||||
# If dpkg is broken, /var/lib/dpkg/updates
|
# If dpkg is broken, /var/lib/dpkg/updates
|
||||||
# will contains files like 0001, 0002, ...
|
# will contains files like 0001, 0002, ...
|
||||||
|
|
Loading…
Add table
Reference in a new issue