2024-08-26 14:55:36 -04:00
|
|
|
#!/usr/bin/env python3
|
2026-03-11 23:15:07 -04:00
|
|
|
# © 2021-2026 TechnoLibre (http://www.technolibre.ca)
|
2024-08-26 14:55:36 -04:00
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
|
|
|
|
|
|
2022-01-24 14:00:47 -05:00
|
|
|
import argparse
|
|
|
|
|
import logging
|
|
|
|
|
import subprocess
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def execute_shell(cmd):
|
2025-11-26 22:20:43 -05:00
|
|
|
result = subprocess.run(
|
|
|
|
|
cmd,
|
|
|
|
|
shell=True,
|
|
|
|
|
capture_output=True,
|
|
|
|
|
text=True,
|
|
|
|
|
)
|
|
|
|
|
output = (result.stdout or "") + (result.stderr or "")
|
|
|
|
|
return result.returncode, output.strip()
|
2022-01-24 14:00:47 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_config():
|
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
|
|
|
description="""\
|
|
|
|
|
Drop all database, caution!
|
|
|
|
|
""",
|
|
|
|
|
epilog="""\
|
|
|
|
|
""",
|
|
|
|
|
)
|
2022-01-26 16:39:42 -05:00
|
|
|
parser.add_argument(
|
|
|
|
|
"--test_only",
|
|
|
|
|
help="test and test_* and other by system test.",
|
|
|
|
|
action="store_true",
|
|
|
|
|
)
|
2025-10-31 01:10:54 -04:00
|
|
|
parser.add_argument(
|
|
|
|
|
"--database",
|
|
|
|
|
help="Specify database to delete, separate by coma",
|
|
|
|
|
)
|
2022-01-24 14:00:47 -05:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
return args
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
config = get_config()
|
|
|
|
|
|
2025-11-28 16:32:35 -05:00
|
|
|
status, out_db = execute_shell("./odoo_bin.sh db --list")
|
2022-01-24 14:00:47 -05:00
|
|
|
lst_db = out_db.split("\n")
|
2025-10-31 01:10:54 -04:00
|
|
|
|
|
|
|
|
lst_database_to_delete = []
|
|
|
|
|
if config.database:
|
|
|
|
|
lst_database_to_delete = [
|
|
|
|
|
a.strip() for a in config.database.split(",")
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
cmd_all = "parallel :::"
|
|
|
|
|
cmd_end = ""
|
|
|
|
|
lst_db_name = []
|
2022-01-24 14:00:47 -05:00
|
|
|
for db_name in lst_db:
|
2022-01-26 16:39:42 -05:00
|
|
|
if config.test_only and not (
|
|
|
|
|
db_name in ("test",)
|
|
|
|
|
or db_name.startswith("test_")
|
|
|
|
|
or db_name.startswith("new_project_")
|
|
|
|
|
):
|
|
|
|
|
continue
|
2025-10-31 01:10:54 -04:00
|
|
|
if lst_database_to_delete and db_name not in lst_database_to_delete:
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
cmd_end += f' "./odoo_bin.sh db --drop --database {db_name}"'
|
|
|
|
|
lst_db_name.append(db_name)
|
|
|
|
|
if cmd_end:
|
[FIX] cache et journal : hôte imbriqué soustrait, décision écrite
Un invité sans magasin de confiance ne peut RIEN recevoir, et sur un hôte
Proxmox c'est l'HÔTE qu'il faut excepter : imbriqué, l'invité sort masqué
derrière lui et le pont ne voit jamais sa propre adresse. Mesuré depuis
l'invité : code 000 et vérification SSL 19, puis 200 et 0. Sans cela le
gestionnaire de paquets se rabattait sur 564 dérivations à construire.
Le journal par VM ne portait AUCUN message du menu : la cause vivait sur
une console qui défile, et le fichier qu'on rouvre après l'échec n'avait
que le symptôme. Et « db_drop_all » annonçait détruites des bases qui ne
l'étaient pas, son code de retour jeté.
--- EN ---
A guest with no trust store can receive NOTHING, and on a Proxmox host it
is the HOST that must be exempted: nested, the guest leaves masqueraded
behind it and the bridge never sees its own address. Measured from the
guest: code 000 and SSL verification 19, then 200 and 0. Without it the
package manager fell back to building 564 derivations.
The per-VM log carried NO message from the menu: the cause lived on a
console that scrolls away, and the file reopened after failure held only
the symptom. And "db_drop_all" announced databases as dropped that were
not, its exit status discarded.
Assisted-by: Claude Opus 5
2026-09-16 00:43:40 -04:00
|
|
|
code, sortie = execute_shell(cmd_all + cmd_end)
|
|
|
|
|
if code:
|
|
|
|
|
# Une destruction qui annonce un succès qu'elle n'a pas obtenu
|
|
|
|
|
# est pire que celle qui échoue : l'opérateur passe à la suite en
|
|
|
|
|
# croyant ses bases parties. Le cas s'atteint dès que « parallel »
|
|
|
|
|
# manque du PATH — le shell rend 127 et pas une base n'est
|
|
|
|
|
# touchée, pendant que la liste s'affiche.
|
|
|
|
|
print("Database NOT deleted :", file=sys.stderr)
|
|
|
|
|
if sortie:
|
|
|
|
|
print(sortie, file=sys.stderr)
|
|
|
|
|
return code
|
2025-10-31 01:10:54 -04:00
|
|
|
print("Database deleted :")
|
|
|
|
|
for db_name in lst_db_name:
|
|
|
|
|
print(db_name)
|
2022-01-24 14:00:47 -05:00
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
sys.exit(main())
|