Misc naming, description and comments improvements

This commit is contained in:
Alexandre Aubin 2018-10-25 14:38:49 +00:00
parent 5e91b5c780
commit ae3bf28481
2 changed files with 11 additions and 6 deletions

View file

@ -271,6 +271,7 @@
"migration_description_0003_migrate_to_stretch": "Upgrade the system to Debian Stretch and YunoHost 3.0",
"migration_description_0004_php5_to_php7_pools": "Reconfigure the PHP pools to use PHP 7 instead of 5",
"migration_description_0005_postgresql_9p4_to_9p6": "Migrate databases from postgresql 9.4 to 9.6",
"migration_description_0006_sync_admin_and_root_passwords": "Synchronize admin and root passwords",
"migration_0003_backward_impossible": "The stretch migration cannot be reverted.",
"migration_0003_start": "Starting migration to Stretch. The logs will be available in {logfile}.",
"migration_0003_patching_sources_list": "Patching the sources.lists ...",
@ -287,7 +288,7 @@
"migration_0005_postgresql_94_not_installed": "Postgresql was not installed on your system. Nothing to do!",
"migration_0005_postgresql_96_not_installed": "Postgresql 9.4 has been found to be installed, but not postgresql 9.6 !? Something weird might have happened on your system :( ...",
"migration_0005_not_enough_space": "Not enough space is available in {path} to run the migration right now :(.",
"migration_0006_root_admin_sync_warning": "Yunohost now expect admin and root passwords to be synchronized. By running this migration, your root password is going to be replaced by your root password.",
"migration_0006_disclaimer": "Yunohost now expects admin and root passwords to be synchronized. By running this migration, your root password is going to be replaced by the admin password.",
"migrations_backward": "Migrating backward.",
"migrations_bad_value_for_target": "Invalid number for target argument, available migrations numbers are 0 or {}",
"migrations_cant_reach_migration_file": "Can't access migrations files at path %s",

View file

@ -16,7 +16,7 @@ logger = getActionLogger('yunohost.migration')
SMALL_PWD_LIST = ["yunohost", "olinux"]
class MyMigration(Migration):
"Migrate password"
"Synchronize admin and root passwords"
def migrate(self):
@ -28,17 +28,21 @@ class MyMigration(Migration):
@property
def mode(self):
if self._is_root_pwd_listed(SMALL_PWD_LIST):
return "auto"
return "manual"
# If the root password is still a "default" value,
# then this is an emergency and migration shall
# be applied automatically
#
# Otherwise, as playing with root password is touchy,
# we set this as a manual migration.
return "auto" if self._is_root_pwd_listed(SMALL_PWD_LIST) else "manual"
@property
def disclaimer(self):
if self._is_root_pwd_listed(SMALL_PWD_LIST):
return None
return m18n.n("migration_0006_root_admin_sync_warning")
return m18n.n("migration_0006_disclaimer")
def _get_admin_hash(self):
"""