From 9971c1751b8340dfb3c2be957cc6089cb873d524 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 21 Jan 2021 22:49:40 +0100 Subject: [PATCH 1/3] Abort postinstall if /etc/yunohost/apps ain't empty --- src/yunohost/tools.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/yunohost/tools.py b/src/yunohost/tools.py index f01f6adb8..da88560c3 100644 --- a/src/yunohost/tools.py +++ b/src/yunohost/tools.py @@ -249,6 +249,9 @@ def tools_postinstall(operation_logger, domain, password, ignore_dyndns=False, if os.path.isfile('/etc/yunohost/installed'): raise YunohostError('yunohost_already_installed') + 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 password if not force_password: assert_password_is_strong_enough("admin", password) From 0606df529b78296d004908f22e842eb70259575e Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 23 Jan 2021 00:08:50 +0100 Subject: [PATCH 2/3] Also add a check on debian/postinst because we're about to move a bunch of init step to debian/postinst instead of 'yunohost tools postintall' --- debian/postinst | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/debian/postinst b/debian/postinst index 4b43b2506..fd2a24b9e 100644 --- a/debian/postinst +++ b/debian/postinst @@ -6,10 +6,18 @@ do_configure() { rm -rf /var/cache/moulinette/* if [ ! -f /etc/yunohost/installed ]; then - bash /usr/share/yunohost/hooks/conf_regen/01-yunohost init - bash /usr/share/yunohost/hooks/conf_regen/02-ssl init - bash /usr/share/yunohost/hooks/conf_regen/06-slapd init - bash /usr/share/yunohost/hooks/conf_regen/15-nginx init + + # If apps/ is not empty, we're probably already installed in the past and + # something funky happened ... + if [ -d /etc/yunohost/apps/ ] && ls /etc/yunohost/apps/* 2>/dev/null + then + echo "Sounds like /etc/yunohost/installed mysteriously disappeared ... You should probably contact the Yunohost support ..." + else + bash /usr/share/yunohost/hooks/conf_regen/01-yunohost init + bash /usr/share/yunohost/hooks/conf_regen/02-ssl init + bash /usr/share/yunohost/hooks/conf_regen/06-slapd init + bash /usr/share/yunohost/hooks/conf_regen/15-nginx init + fi else echo "Regenerating configuration, this might take a while..." yunohost tools regen-conf --output-as none From b6b33d99dee501baf912e653e30438b58ecb2586 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 28 Jan 2021 00:29:38 +0100 Subject: [PATCH 3/3] We don't want any output of ls, just the return code Co-authored-by: Kayou --- debian/postinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/postinst b/debian/postinst index fd2a24b9e..8fdb288bc 100644 --- a/debian/postinst +++ b/debian/postinst @@ -9,7 +9,7 @@ do_configure() { # If apps/ is not empty, we're probably already installed in the past and # something funky happened ... - if [ -d /etc/yunohost/apps/ ] && ls /etc/yunohost/apps/* 2>/dev/null + if [ -d /etc/yunohost/apps/ ] && ls /etc/yunohost/apps/* >/dev/null 2>&1 then echo "Sounds like /etc/yunohost/installed mysteriously disappeared ... You should probably contact the Yunohost support ..." else