Commit 239056c6 authored by segfault's avatar segfault

Change the points at which the two configuration functions are called

Also rename the functions to configure_top() and configure_bottom()
parent 18e6fea4
......@@ -130,19 +130,17 @@ class OnionService(DBusObject, metaclass=abc.ABCMeta):
self.container.install_packages(self.packages)
self.TransactionStatus = _("Configuring service")
self.configure_top()
self.create_state_dir()
self.create_data_files()
# Some services use the onion address during configuration, so set it before
self.Address = self.private_key.derive_onion_address()
# Some services configure files in the mount points, so mount them before
self.mount()
self.configure()
self.TransactionStatus = _("Initializing options")
self.initialize_options()
self.TransactionStatus = _("Configuring options")
self.configure_options()
# Some services configure files in the mount points, so mount them before running configure_bottom()
self.mount()
self.configure_bottom()
self.Status = Status.STOPPED
self.IsInstalled = True
......@@ -461,13 +459,13 @@ class OnionService(DBusObject, metaclass=abc.ABCMeta):
self.emit_signal("org.freedesktop.DBus.Properties", "PropertiesChanged",
{"ConnectionInfo": self.ConnectionInfo}, "a{ss}")
def configure(self):
def configure_top(self):
"""Initial configuration after installing the service.
This is called *before* the options are initialized. To
configure the service's options, use configure_options()"""
pass
def configure_options(self):
def configure_bottom(self):
"""Configuration that must be done after options are initialized"""
pass
......
......@@ -130,12 +130,11 @@ class GobbyServer(OnionService):
user = "infinoted"
def configure(self):
def configure_top(self):
sh.adduser("--system", "--group", "--home", data_dir, "--no-create-home", "--shell",
"/bin/false", "--disabled-login", self.user)
def configure_options(self):
# SystemdManager(self).daemon_reload()
def configure_bottom(self):
self.set_option("AllowLocalhost", True)
@property
......
......@@ -146,7 +146,7 @@ class ProsodyServer(OnionService):
s += _("\nChatroom: %s") % chatroom
return s
def configure(self):
def configure_bottom(self):
self.set_virtual_host(self.Address)
def update_config(self, *args, count=1):
......
......@@ -163,7 +163,7 @@ ChrootDirectory {}
s += _("SSH Public Key: %s") % self.public_key
return s
def configure(self):
def configure_bottom(self):
# Create chroot directory
logger.debug("Creating directory %s", self.chroot_dir)
......@@ -176,7 +176,5 @@ ChrootDirectory {}
raise FileExistsError("Secret key file %s already exists. Aborting" % secret_key_file)
sh.ssh_keygen(sh.echo("n"), "-N", "", "-t", "ed25519", "-C", "", "-f", str(secret_key_file))
super().configure()
service_class = SFTPServer
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment