mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] Execute backup hook, and avoid dyndns domain subscription when specifically asked at postinstall
This commit is contained in:
parent
b0735af6ce
commit
0608461482
5 changed files with 27 additions and 30 deletions
|
@ -559,12 +559,8 @@ backup:
|
||||||
|
|
||||||
### backup_init()
|
### backup_init()
|
||||||
init:
|
init:
|
||||||
action_help: Init Tahoe-LAFS configuration
|
action_help: Create an encrypted backup tarball
|
||||||
# api: POST /backup/init
|
api: POST /backup
|
||||||
arguments:
|
|
||||||
--helper:
|
|
||||||
help: Init as a helper node rather than a "helped" one
|
|
||||||
action: store_true
|
|
||||||
|
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
|
@ -1025,8 +1021,8 @@ tools:
|
||||||
pattern:
|
pattern:
|
||||||
- '^.{3,}$'
|
- '^.{3,}$'
|
||||||
- pattern_password
|
- pattern_password
|
||||||
--dyndns:
|
--ignore-dyndns:
|
||||||
help: Subscribe domain to a DynDNS service
|
help: Do not subscribe domain to a DynDNS service
|
||||||
action: store_true
|
action: store_true
|
||||||
|
|
||||||
### tools_update()
|
### tools_update()
|
||||||
|
|
34
backup.py
34
backup.py
|
@ -26,27 +26,27 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
import yaml
|
import time
|
||||||
import glob
|
|
||||||
|
|
||||||
from moulinette.core import MoulinetteError
|
from moulinette.core import MoulinetteError
|
||||||
|
|
||||||
def backup_init(helper=False):
|
def backup():
|
||||||
"""
|
"""
|
||||||
Init Tahoe-LAFS configuration
|
Create an encrypted backup tarball
|
||||||
|
|
||||||
Keyword argument:
|
|
||||||
helper -- Init as a helper node rather than a "helped" one
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
tahoe_cfg_dir = '/usr/share/yunohost/yunohost-config/backup'
|
from yunohost.hook import hook_callback
|
||||||
if helper:
|
|
||||||
configure_cmd = '/configure_tahoe.sh helper'
|
|
||||||
else:
|
|
||||||
configure_cmd = '/configure_tahoe.sh'
|
|
||||||
|
|
||||||
os.system('tahoe create-client /home/yunohost.backup/tahoe')
|
backup_dirname = int(time.time())
|
||||||
os.system('/bin/bash %s%s' % (tahoe_cfg_dir, configure_cmd))
|
backup_dir = "/home/yunohost.backup/tmp/%s" % backup_dirname
|
||||||
os.system('cp %s/tahoe.cfg /home/yunohost.backup/tahoe/' % tahoe_cfg_dir)
|
|
||||||
#os.system('update-rc.d tahoe-lafs defaults')
|
# Create directory
|
||||||
#os.system('service tahoe-lafs restart')
|
try: os.listdir(backup_dir)
|
||||||
|
except OSError: os.makedirs(backup_dir)
|
||||||
|
|
||||||
|
# Run hook
|
||||||
|
hook_callback('backup', [backup_dir])
|
||||||
|
|
||||||
|
#TODO: Compress & encrypt
|
||||||
|
|
||||||
|
msignals.display(m18n.n('backup_completed'), 'success')
|
||||||
|
|
|
@ -128,6 +128,8 @@
|
||||||
"packages_upgrade_failed" : "Unable to upgrade all packages",
|
"packages_upgrade_failed" : "Unable to upgrade all packages",
|
||||||
"system_upgraded" : "System successfully upgraded",
|
"system_upgraded" : "System successfully upgraded",
|
||||||
|
|
||||||
|
"backup_complete" : "Backup complete",
|
||||||
|
|
||||||
"field_invalid" : "Invalid field '{:s}'",
|
"field_invalid" : "Invalid field '{:s}'",
|
||||||
"mail_domain_unknown" : "Unknown mail address domain '{:s}'",
|
"mail_domain_unknown" : "Unknown mail address domain '{:s}'",
|
||||||
"mail_alias_remove_failed" : "Unable to remove mail alias '{:s}'",
|
"mail_alias_remove_failed" : "Unable to remove mail alias '{:s}'",
|
||||||
|
|
|
@ -128,6 +128,8 @@
|
||||||
"packages_upgrade_failed" : "Impossible de mettre à jour tous les paquets",
|
"packages_upgrade_failed" : "Impossible de mettre à jour tous les paquets",
|
||||||
"system_upgraded" : "Système mis à jour avec succès",
|
"system_upgraded" : "Système mis à jour avec succès",
|
||||||
|
|
||||||
|
"backup_complete" : "Sauvegarde terminée",
|
||||||
|
|
||||||
"field_invalid" : "Champ incorrect : {:s}",
|
"field_invalid" : "Champ incorrect : {:s}",
|
||||||
"mail_domain_unknown" : "Domaine '{:s}' de l'adresse mail inconnu",
|
"mail_domain_unknown" : "Domaine '{:s}' de l'adresse mail inconnu",
|
||||||
"mail_alias_remove_failed" : "Impossible de supprimer l'adresse mail supplémentaire '{:s}'",
|
"mail_alias_remove_failed" : "Impossible de supprimer l'adresse mail supplémentaire '{:s}'",
|
||||||
|
|
7
tools.py
7
tools.py
|
@ -207,7 +207,7 @@ def tools_maindomain(auth, old_domain=None, new_domain=None, dyndns=False):
|
||||||
msignals.display(m18n.n('maindomain_changed'), 'success')
|
msignals.display(m18n.n('maindomain_changed'), 'success')
|
||||||
|
|
||||||
|
|
||||||
def tools_postinstall(domain, password, dyndns=False):
|
def tools_postinstall(domain, password, ignore_dyndns=False):
|
||||||
"""
|
"""
|
||||||
YunoHost post-install
|
YunoHost post-install
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ def tools_postinstall(domain, password, dyndns=False):
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(errno.EPERM, m18n.n('yunohost_already_installed'))
|
raise MoulinetteError(errno.EPERM, m18n.n('yunohost_already_installed'))
|
||||||
|
|
||||||
if len(domain.split('.')) >= 3:
|
if len(domain.split('.')) >= 3 and not ignore_dyndns:
|
||||||
try:
|
try:
|
||||||
r = requests.get('http://dyndns.yunohost.org/domains')
|
r = requests.get('http://dyndns.yunohost.org/domains')
|
||||||
except ConnectionError:
|
except ConnectionError:
|
||||||
|
@ -310,9 +310,6 @@ def tools_postinstall(domain, password, dyndns=False):
|
||||||
# Initialize YunoHost LDAP base
|
# Initialize YunoHost LDAP base
|
||||||
tools_ldapinit(auth)
|
tools_ldapinit(auth)
|
||||||
|
|
||||||
# Initialize backup system
|
|
||||||
backup_init()
|
|
||||||
|
|
||||||
# New domain config
|
# New domain config
|
||||||
tools_maindomain(auth, old_domain='yunohost.org', new_domain=domain, dyndns=dyndns)
|
tools_maindomain(auth, old_domain='yunohost.org', new_domain=domain, dyndns=dyndns)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue