diff --git a/.gitlab/ci/install.gitlab-ci.yml b/.gitlab/ci/install.gitlab-ci.yml
index 1df4fc4b9..e2662e9e2 100644
--- a/.gitlab/ci/install.gitlab-ci.yml
+++ b/.gitlab/ci/install.gitlab-ci.yml
@@ -26,4 +26,4 @@ install-postinstall:
script:
- apt-get update -o Acquire::Retries=3
- DEBIAN_FRONTEND=noninteractive SUDO_FORCE_REMOVE=yes apt --assume-yes -o Dpkg::Options::="--force-confold" --allow-downgrades install ./$YNH_BUILD_DIR/*.deb
- - yunohost tools postinstall -d domain.tld -p the_password --ignore-dyndns
+ - yunohost tools postinstall -d domain.tld -p the_password --ignore-dyndns --force-diskspace
diff --git a/.gitlab/ci/test.gitlab-ci.yml b/.gitlab/ci/test.gitlab-ci.yml
index 6cbb89d0c..a4ec77ee8 100644
--- a/.gitlab/ci/test.gitlab-ci.yml
+++ b/.gitlab/ci/test.gitlab-ci.yml
@@ -34,7 +34,7 @@ full-tests:
PYTEST_ADDOPTS: "--color=yes"
before_script:
- *install_debs
- - yunohost tools postinstall -d domain.tld -p the_password --ignore-dyndns
+ - yunohost tools postinstall -d domain.tld -p the_password --ignore-dyndns --force-diskspace
script:
- python3 -m pytest --cov=yunohost tests/ src/yunohost/tests/ --junitxml=report.xml
needs:
diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml
index fcc0cdec4..f971afd6d 100644
--- a/data/actionsmap/yunohost.yml
+++ b/data/actionsmap/yunohost.yml
@@ -1423,6 +1423,10 @@ tools:
--force-password:
help: Use this if you really want to set a weak password
action: store_true
+ --force-diskspace:
+ help: Use this if you really want to install Yunohost on a setup with less than 10 GB on the root filesystem
+ action: store_true
+
### tools_update()
update:
diff --git a/data/hooks/diagnosis/50-systemresources.py b/data/hooks/diagnosis/50-systemresources.py
index 30a2ad1f8..fdda2c2f0 100644
--- a/data/hooks/diagnosis/50-systemresources.py
+++ b/data/hooks/diagnosis/50-systemresources.py
@@ -103,6 +103,26 @@ class SystemResourcesDiagnoser(Diagnoser):
yield item
+ #
+ # Check for minimal space on / + /var
+ # because some stupid VPS provider only configure a stupidly
+ # low amount of disk space for the root partition
+ # which later causes issue when it gets full...
+ #
+
+ main_disk_partitions = [d for d in disk_partitions if d.mountpoint in ['/', '/var']]
+ main_space = sum([psutil.disk_usage(d.mountpoint).total for d in main_disk_partitions])
+ if main_space < 10 * GB:
+ yield dict(meta={"test": "rootfstotalspace"},
+ data={"space": human_size(main_space)},
+ status="ERROR",
+ summary="diagnosis_rootfstotalspace_critical")
+ if main_space < 14 * GB:
+ yield dict(meta={"test": "rootfstotalspace"},
+ data={"space": human_size(main_space)},
+ status="WARNING",
+ summary="diagnosis_rootfstotalspace_warning")
+
#
# Recent kills by oom_reaper
#
diff --git a/locales/en.json b/locales/en.json
index 629907bb7..d34ee3002 100644
--- a/locales/en.json
+++ b/locales/en.json
@@ -232,6 +232,8 @@
"diagnosis_regenconf_allgood": "All configurations files are in line with the recommended configuration!",
"diagnosis_regenconf_manually_modified": "Configuration file {file}
appears to have been manually modified.",
"diagnosis_regenconf_manually_modified_details": "This is probably OK if you know what you're doing! YunoHost will stop updating this file automatically... But beware that YunoHost upgrades could contain important recommended changes. If you want to, you can inspect the differences with yunohost tools regen-conf {category} --dry-run --with-diff and force the reset to the recommended configuration with yunohost tools regen-conf {category} --force",
+ "diagnosis_rootfstotalspace_warning": "The root filesystem only has a total of {space}. This may be okay, but be careful because ultimately you may run out of disk space quickly... It's recommended to have at least 16 GB for the root filesystem.",
+ "diagnosis_rootfstotalspace_critical": "The root filesystem only has a total of {space} which is quite worrisome! You will likely run out of disk space very quickly! It's recommended to have at least 16 GB for the root filesystem.",
"diagnosis_security_vulnerable_to_meltdown": "You appear vulnerable to the Meltdown criticial security vulnerability",
"diagnosis_security_vulnerable_to_meltdown_details": "To fix this, you should upgrade your system and reboot to load the new linux kernel (or contact your server provider if this doesn't work). See https://meltdownattack.com/ for more infos.",
"diagnosis_description_basesystem": "Base system",
@@ -506,6 +508,7 @@
"permission_require_account": "Permission {permission} only makes sense for users having an account, and therefore cannot be enabled for visitors.",
"port_already_closed": "Port {port:d} is already closed for {ip_version:s} connections",
"port_already_opened": "Port {port:d} is already opened for {ip_version:s} connections",
+ "postinstall_low_rootfsspace": "The root filesystem has a total space less than 10 GB, which is quite worrisome! You will likely run out of disk space very quickly! It's recommended to have at least 16GB for the root filesystem. If you want to install YunoHost despite this warning, re-run the postinstall with --force-diskspace",
"regenconf_file_backed_up": "Configuration file '{conf}' backed up to '{backup}'",
"regenconf_file_copy_failed": "Could not copy the new configuration file '{new}' to '{conf}'",
"regenconf_file_kept_back": "The configuration file '{conf}' is expected to be deleted by regen-conf (category {category}) but was kept back.",
diff --git a/src/yunohost/tools.py b/src/yunohost/tools.py
index d39e3c2d4..5090c41aa 100644
--- a/src/yunohost/tools.py
+++ b/src/yunohost/tools.py
@@ -229,7 +229,7 @@ def _detect_virt():
@is_unit_operation()
def tools_postinstall(operation_logger, domain, password, ignore_dyndns=False,
- force_password=False):
+ force_password=False, force_diskspace=False):
"""
YunoHost post-install
@@ -242,6 +242,7 @@ def tools_postinstall(operation_logger, domain, password, ignore_dyndns=False,
"""
from yunohost.utils.password import assert_password_is_strong_enough
from yunohost.domain import domain_main_domain
+ import psutil
dyndns_provider = "dyndns.yunohost.org"
@@ -252,6 +253,14 @@ def tools_postinstall(operation_logger, domain, password, ignore_dyndns=False,
if os.path.isdir("/etc/yunohost/apps") and os.listdir("/etc/yunohost/apps") != []:
raise YunohostError("It looks like you're trying to re-postinstall a system that was already working previously ... If you recently had some bug or issues with your installation, please first discuss with the team on how to fix the situation instead of savagely re-running the postinstall ...", raw_msg=True)
+ # Check there's at least 10 GB on the rootfs...
+ disk_partitions = sorted(psutil.disk_partitions(), key=lambda k: k.mountpoint)
+ main_disk_partitions = [d for d in disk_partitions if d.mountpoint in ['/', '/var']]
+ main_space = sum([psutil.disk_usage(d.mountpoint).total for d in main_disk_partitions])
+ GB = 1024**3
+ if not force_diskspace and main_space < 10 * GB:
+ raise YunohostError("postinstall_low_rootfsspace")
+
# Check password
if not force_password:
assert_password_is_strong_enough("admin", password)