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()
|
||||
init:
|
||||
action_help: Init Tahoe-LAFS configuration
|
||||
# api: POST /backup/init
|
||||
arguments:
|
||||
--helper:
|
||||
help: Init as a helper node rather than a "helped" one
|
||||
action: store_true
|
||||
action_help: Create an encrypted backup tarball
|
||||
api: POST /backup
|
||||
|
||||
|
||||
#############################
|
||||
|
@ -1025,8 +1021,8 @@ tools:
|
|||
pattern:
|
||||
- '^.{3,}$'
|
||||
- pattern_password
|
||||
--dyndns:
|
||||
help: Subscribe domain to a DynDNS service
|
||||
--ignore-dyndns:
|
||||
help: Do not subscribe domain to a DynDNS service
|
||||
action: store_true
|
||||
|
||||
### tools_update()
|
||||
|
|
34
backup.py
34
backup.py
|
@ -26,27 +26,27 @@
|
|||
import os
|
||||
import sys
|
||||
import json
|
||||
import yaml
|
||||
import glob
|
||||
import time
|
||||
|
||||
from moulinette.core import MoulinetteError
|
||||
|
||||
def backup_init(helper=False):
|
||||
def backup():
|
||||
"""
|
||||
Init Tahoe-LAFS configuration
|
||||
|
||||
Keyword argument:
|
||||
helper -- Init as a helper node rather than a "helped" one
|
||||
Create an encrypted backup tarball
|
||||
|
||||
"""
|
||||
tahoe_cfg_dir = '/usr/share/yunohost/yunohost-config/backup'
|
||||
if helper:
|
||||
configure_cmd = '/configure_tahoe.sh helper'
|
||||
else:
|
||||
configure_cmd = '/configure_tahoe.sh'
|
||||
from yunohost.hook import hook_callback
|
||||
|
||||
os.system('tahoe create-client /home/yunohost.backup/tahoe')
|
||||
os.system('/bin/bash %s%s' % (tahoe_cfg_dir, configure_cmd))
|
||||
os.system('cp %s/tahoe.cfg /home/yunohost.backup/tahoe/' % tahoe_cfg_dir)
|
||||
#os.system('update-rc.d tahoe-lafs defaults')
|
||||
#os.system('service tahoe-lafs restart')
|
||||
backup_dirname = int(time.time())
|
||||
backup_dir = "/home/yunohost.backup/tmp/%s" % backup_dirname
|
||||
|
||||
# Create directory
|
||||
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",
|
||||
"system_upgraded" : "System successfully upgraded",
|
||||
|
||||
"backup_complete" : "Backup complete",
|
||||
|
||||
"field_invalid" : "Invalid field '{:s}'",
|
||||
"mail_domain_unknown" : "Unknown mail address domain '{: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",
|
||||
"system_upgraded" : "Système mis à jour avec succès",
|
||||
|
||||
"backup_complete" : "Sauvegarde terminée",
|
||||
|
||||
"field_invalid" : "Champ incorrect : {:s}",
|
||||
"mail_domain_unknown" : "Domaine '{:s}' de l'adresse mail inconnu",
|
||||
"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')
|
||||
|
||||
|
||||
def tools_postinstall(domain, password, dyndns=False):
|
||||
def tools_postinstall(domain, password, ignore_dyndns=False):
|
||||
"""
|
||||
YunoHost post-install
|
||||
|
||||
|
@ -230,7 +230,7 @@ def tools_postinstall(domain, password, dyndns=False):
|
|||
else:
|
||||
raise MoulinetteError(errno.EPERM, m18n.n('yunohost_already_installed'))
|
||||
|
||||
if len(domain.split('.')) >= 3:
|
||||
if len(domain.split('.')) >= 3 and not ignore_dyndns:
|
||||
try:
|
||||
r = requests.get('http://dyndns.yunohost.org/domains')
|
||||
except ConnectionError:
|
||||
|
@ -310,9 +310,6 @@ def tools_postinstall(domain, password, dyndns=False):
|
|||
# Initialize YunoHost LDAP base
|
||||
tools_ldapinit(auth)
|
||||
|
||||
# Initialize backup system
|
||||
backup_init()
|
||||
|
||||
# New domain config
|
||||
tools_maindomain(auth, old_domain='yunohost.org', new_domain=domain, dyndns=dyndns)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue