mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
bind: Bump version and handle upgrade
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
3f0642109c
commit
c78d96984b
11
actions/bind
11
actions/bind
@ -31,7 +31,10 @@ def parse_arguments():
|
|||||||
"""Return parsed command line arguments as dictionary"""
|
"""Return parsed command line arguments as dictionary"""
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
|
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
|
||||||
subparsers.add_parser('setup', help='Setup for BIND')
|
setup = subparsers.add_parser('setup', help='Setup for BIND')
|
||||||
|
setup.add_argument(
|
||||||
|
'--old-version', type=int, required=True,
|
||||||
|
help='Earlier version of the app that is already setup.')
|
||||||
|
|
||||||
configure = subparsers.add_parser('configure', help='Configure BIND')
|
configure = subparsers.add_parser('configure', help='Configure BIND')
|
||||||
configure.add_argument('--forwarders',
|
configure.add_argument('--forwarders',
|
||||||
@ -43,11 +46,11 @@ def parse_arguments():
|
|||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def subcommand_setup(_):
|
def subcommand_setup(arguments):
|
||||||
"""Setup BIND configuration."""
|
"""Setup BIND configuration."""
|
||||||
conf_file = open(CONFIG_FILE, "w")
|
if arguments.old_version == 0:
|
||||||
|
with open(CONFIG_FILE, "w") as conf_file:
|
||||||
conf_file.write(DEFAULT_CONFIG)
|
conf_file.write(DEFAULT_CONFIG)
|
||||||
conf_file.close()
|
|
||||||
|
|
||||||
Path(ZONES_DIR).mkdir(exist_ok=True, parents=True)
|
Path(ZONES_DIR).mkdir(exist_ok=True, parents=True)
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,7 @@ from plinth.utils import format_lazy
|
|||||||
|
|
||||||
from .manifest import backup # noqa, pylint: disable=unused-import
|
from .manifest import backup # noqa, pylint: disable=unused-import
|
||||||
|
|
||||||
version = 1
|
version = 2
|
||||||
|
|
||||||
name = _('BIND')
|
name = _('BIND')
|
||||||
|
|
||||||
@ -127,7 +127,9 @@ def init():
|
|||||||
def setup(helper, old_version=None):
|
def setup(helper, old_version=None):
|
||||||
"""Install and configure the module."""
|
"""Install and configure the module."""
|
||||||
helper.install(managed_packages)
|
helper.install(managed_packages)
|
||||||
helper.call('post', actions.superuser_run, 'bind', ['setup'])
|
helper.call(
|
||||||
|
'post', actions.superuser_run, 'bind',
|
||||||
|
['setup', '--old-version', str(old_version)])
|
||||||
helper.call('post', app.enable)
|
helper.call('post', app.enable)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user