mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Avoid to revert migrations without backward routine
This commit is contained in:
parent
74b5ea5982
commit
fc426cff69
11 changed files with 10 additions and 32 deletions
|
@ -19,10 +19,6 @@ class MyMigration(Migration):
|
||||||
|
|
||||||
"Migrate Dyndns stuff from MD5 TSIG to SHA512 TSIG"
|
"Migrate Dyndns stuff from MD5 TSIG to SHA512 TSIG"
|
||||||
|
|
||||||
def backward(self):
|
|
||||||
# Not possible because that's a non-reversible operation ?
|
|
||||||
pass
|
|
||||||
|
|
||||||
def migrate(self, dyn_host="dyndns.yunohost.org", domain=None, private_key_path=None):
|
def migrate(self, dyn_host="dyndns.yunohost.org", domain=None, private_key_path=None):
|
||||||
|
|
||||||
if domain is None or private_key_path is None:
|
if domain is None or private_key_path is None:
|
||||||
|
|
|
@ -29,11 +29,7 @@ class MyMigration(Migration):
|
||||||
|
|
||||||
mode = "manual"
|
mode = "manual"
|
||||||
|
|
||||||
def backward(self):
|
def forward(self):
|
||||||
|
|
||||||
raise YunohostError("migration_backward_impossible", name=self.name)
|
|
||||||
|
|
||||||
def migrate(self):
|
|
||||||
|
|
||||||
self.logfile = "/var/log/yunohost/{}.log".format(self.name)
|
self.logfile = "/var/log/yunohost/{}.log".format(self.name)
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ class MyMigration(Migration):
|
||||||
|
|
||||||
dependencies = ["migrate_to_stretch"]
|
dependencies = ["migrate_to_stretch"]
|
||||||
|
|
||||||
def migrate(self):
|
def forward(self):
|
||||||
|
|
||||||
# Get list of php5 pool files
|
# Get list of php5 pool files
|
||||||
php5_pool_files = glob.glob("{}/*.conf".format(PHP5_POOLS))
|
php5_pool_files = glob.glob("{}/*.conf".format(PHP5_POOLS))
|
||||||
|
|
|
@ -16,7 +16,7 @@ class MyMigration(Migration):
|
||||||
|
|
||||||
dependencies = ["migrate_to_stretch"]
|
dependencies = ["migrate_to_stretch"]
|
||||||
|
|
||||||
def migrate(self):
|
def forward(self):
|
||||||
|
|
||||||
if not self.package_is_installed("postgresql-9.4"):
|
if not self.package_is_installed("postgresql-9.4"):
|
||||||
logger.warning(m18n.n("migration_0005_postgresql_94_not_installed"))
|
logger.warning(m18n.n("migration_0005_postgresql_94_not_installed"))
|
||||||
|
@ -34,10 +34,6 @@ class MyMigration(Migration):
|
||||||
subprocess.check_call("pg_dropcluster --stop 9.4 main", shell=True)
|
subprocess.check_call("pg_dropcluster --stop 9.4 main", shell=True)
|
||||||
subprocess.check_call("service postgresql start", shell=True)
|
subprocess.check_call("service postgresql start", shell=True)
|
||||||
|
|
||||||
def backward(self):
|
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
def package_is_installed(self, package_name):
|
def package_is_installed(self, package_name):
|
||||||
|
|
||||||
p = subprocess.Popen("dpkg --list | grep '^ii ' | grep -q -w {}".format(package_name), shell=True)
|
p = subprocess.Popen("dpkg --list | grep '^ii ' | grep -q -w {}".format(package_name), shell=True)
|
||||||
|
|
|
@ -20,16 +20,13 @@ class MyMigration(Migration):
|
||||||
|
|
||||||
"Synchronize admin and root passwords"
|
"Synchronize admin and root passwords"
|
||||||
|
|
||||||
def migrate(self):
|
def forward(self):
|
||||||
|
|
||||||
new_hash = self._get_admin_hash()
|
new_hash = self._get_admin_hash()
|
||||||
self._replace_root_hash(new_hash)
|
self._replace_root_hash(new_hash)
|
||||||
|
|
||||||
logger.info(m18n.n("root_password_replaced_by_admin_password"))
|
logger.info(m18n.n("root_password_replaced_by_admin_password"))
|
||||||
|
|
||||||
def backward(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mode(self):
|
def mode(self):
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ class MyMigration(Migration):
|
||||||
use the recommended configuration, with an appropriate disclaimer.
|
use the recommended configuration, with an appropriate disclaimer.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def migrate(self):
|
def forward(self):
|
||||||
|
|
||||||
# Check if deprecated DSA Host Key is in config
|
# Check if deprecated DSA Host Key is in config
|
||||||
dsa_rgx = r'^[ \t]*HostKey[ \t]+/etc/ssh/ssh_host_dsa_key[ \t]*(?:#.*)?$'
|
dsa_rgx = r'^[ \t]*HostKey[ \t]+/etc/ssh/ssh_host_dsa_key[ \t]*(?:#.*)?$'
|
||||||
|
|
|
@ -35,7 +35,7 @@ class MyMigration(Migration):
|
||||||
|
|
||||||
dependencies = ["ssh_conf_managed_by_yunohost_step1"]
|
dependencies = ["ssh_conf_managed_by_yunohost_step1"]
|
||||||
|
|
||||||
def migrate(self):
|
def forward(self):
|
||||||
settings_set("service.ssh.allow_deprecated_dsa_hostkey", False)
|
settings_set("service.ssh.allow_deprecated_dsa_hostkey", False)
|
||||||
regen_conf(names=['ssh'], force=True)
|
regen_conf(names=['ssh'], force=True)
|
||||||
|
|
||||||
|
@ -44,10 +44,6 @@ class MyMigration(Migration):
|
||||||
if os.path.isdir(ARCHIVES_PATH):
|
if os.path.isdir(ARCHIVES_PATH):
|
||||||
chown(ARCHIVES_PATH, uid="admin", gid="root")
|
chown(ARCHIVES_PATH, uid="admin", gid="root")
|
||||||
|
|
||||||
def backward(self):
|
|
||||||
|
|
||||||
raise YunohostError("migration_backward_impossible", name=self.name)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mode(self):
|
def mode(self):
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ class MyMigration(Migration):
|
||||||
Decouple the regen conf mechanism from the concept of services
|
Decouple the regen conf mechanism from the concept of services
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def migrate(self):
|
def forward(self):
|
||||||
|
|
||||||
if "conffiles" not in read_file("/etc/yunohost/services.yml") \
|
if "conffiles" not in read_file("/etc/yunohost/services.yml") \
|
||||||
or os.path.exists(REGEN_CONF_FILE):
|
or os.path.exists(REGEN_CONF_FILE):
|
||||||
|
@ -37,6 +37,3 @@ class MyMigration(Migration):
|
||||||
# (Actually save the modification of services)
|
# (Actually save the modification of services)
|
||||||
_save_services(services)
|
_save_services(services)
|
||||||
|
|
||||||
def backward(self):
|
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class MyMigration(Migration):
|
||||||
|
|
||||||
"Migrate from official.json to apps.json"
|
"Migrate from official.json to apps.json"
|
||||||
|
|
||||||
def migrate(self):
|
def forward(self):
|
||||||
|
|
||||||
# Backup current app list json
|
# Backup current app list json
|
||||||
os.system("cp %s %s" % (APPSLISTS_JSON, APPSLISTS_BACKUP))
|
os.system("cp %s %s" % (APPSLISTS_JSON, APPSLISTS_BACKUP))
|
||||||
|
|
|
@ -92,7 +92,7 @@ class MyMigration(Migration):
|
||||||
app_setting(app, 'allowed_users', delete=True)
|
app_setting(app, 'allowed_users', delete=True)
|
||||||
|
|
||||||
|
|
||||||
def migrate(self):
|
def forward(self):
|
||||||
# Check if the migration can be processed
|
# Check if the migration can be processed
|
||||||
ldap_regen_conf_status = regen_conf(names=['slapd'], dry_run=True)
|
ldap_regen_conf_status = regen_conf(names=['slapd'], dry_run=True)
|
||||||
# By this we check if the have been customized
|
# By this we check if the have been customized
|
||||||
|
|
|
@ -1316,7 +1316,7 @@ class Migration(object):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def backward(self):
|
def backward(self):
|
||||||
pass
|
raise YunohostError("migration_backward_impossible", name=self.name)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def disclaimer(self):
|
def disclaimer(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue