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 8eee048f2..fcc2c5e72 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -1416,6 +1416,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/locales/en.json b/locales/en.json index 33efcda14..931b1476b 100644 --- a/locales/en.json +++ b/locales/en.json @@ -508,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 f01f6adb8..f7b2b91cb 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" @@ -249,6 +250,14 @@ def tools_postinstall(operation_logger, domain, password, ignore_dyndns=False, if os.path.isfile('/etc/yunohost/installed'): raise YunohostError('yunohost_already_installed') + # 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)