mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Handle disclaimers
This commit is contained in:
parent
c8b1d7e2c3
commit
9009b3f9d3
3 changed files with 29 additions and 13 deletions
|
@ -1599,7 +1599,9 @@ tools:
|
|||
--auto:
|
||||
help: automatic mode, won't run manual migrations, use it only if you know what you are doing
|
||||
action: store_true
|
||||
|
||||
--accept-disclaimer:
|
||||
help: accept disclaimers of migration (please read them before using this option)
|
||||
action: store_true
|
||||
|
||||
### tools_migrations_state()
|
||||
state:
|
||||
|
|
|
@ -238,6 +238,7 @@
|
|||
"migrations_show_last_migration": "Last ran migration is {}",
|
||||
"migrations_skip_migration": "Skipping migration {number} {name}...",
|
||||
"migrations_to_be_ran_manually": "Migration {number} {name} has to be ran manually. Please go to Tools > Migrations on the webadmin, or run `yunohost tools migrations migrate`.",
|
||||
"migrations_need_to_accept_disclaimer": "To run the migration {number} {name}, your must accept the following disclaimer:\n---\n{disclaimer}\n---\nIf you accept to run the migration, please re-run the command with the option --accept-disclaimer.",
|
||||
"monitor_disabled": "The server monitoring has been disabled",
|
||||
"monitor_enabled": "The server monitoring has been enabled",
|
||||
"monitor_glances_con_failed": "Unable to connect to Glances server",
|
||||
|
|
|
@ -765,7 +765,7 @@ def tools_migrations_list(pending=False, done=False):
|
|||
return {"migrations": migrations}
|
||||
|
||||
|
||||
def tools_migrations_migrate(target=None, skip=False, auto=False):
|
||||
def tools_migrations_migrate(target=None, skip=False, auto=False, accept_disclaimer=False):
|
||||
"""
|
||||
Perform migrations
|
||||
"""
|
||||
|
@ -825,22 +825,35 @@ def tools_migrations_migrate(target=None, skip=False, auto=False):
|
|||
else: # can't happen, this case is handle before
|
||||
raise Exception()
|
||||
|
||||
# If we are migrating in "automatic mode" (i.e. from debian
|
||||
# configure during an upgrade of the package) but we are asked to run
|
||||
# migrations is to be ran manually by the user
|
||||
manual_migrations = [m for m in migrations if m.mode == "manual"]
|
||||
if auto and manual_migrations:
|
||||
for m in manual_migrations:
|
||||
logger.warn(m18n.n('migrations_to_be_ran_manually',
|
||||
number=m.number,
|
||||
name=m.name))
|
||||
return
|
||||
|
||||
# If some migrations have disclaimers, require the --accept-disclaimer
|
||||
# option
|
||||
migrations_with_disclaimer = [m for m in migrations if m.disclaimer]
|
||||
if not accept_disclaimer and migrations_with_disclaimer:
|
||||
for m in migrations_with_disclaimer:
|
||||
logger.warn(m18n.n('migrations_need_to_accept_disclaimer',
|
||||
number=m.number,
|
||||
name=m.name,
|
||||
disclaimer=m.disclaimer))
|
||||
return
|
||||
|
||||
# effectively run selected migrations
|
||||
for migration in migrations:
|
||||
if not skip:
|
||||
|
||||
# If we are migrating in "automatic mode" (i.e. from debian
|
||||
# configure during an upgrade of the package) but the migration
|
||||
# is to be ran manually by the user
|
||||
if auto and migration.mode == "manual":
|
||||
logger.warn(m18n.n('migrations_to_be_ran_manually',
|
||||
number=migration.number, name=migration.name))
|
||||
break
|
||||
else:
|
||||
logger.warn(m18n.n('migrations_show_currently_running_migration',
|
||||
number=migration.number, name=migration.name))
|
||||
|
||||
|
||||
try:
|
||||
if mode == "forward":
|
||||
migration.migrate()
|
||||
|
|
Loading…
Add table
Reference in a new issue