Commit 57a0ab36 authored by segfault's avatar segfault

Make gobby work inside a container

parent 239056c6
from pathlib import Path
import random
import string
import sh
from onionkit import _
from onionkit import option
......@@ -14,12 +13,17 @@ from onionkit.service import OnionService
from onionkit.data_file import IniLikeConfigFile
from onionkit.mountpoint import MountPoint
from onionkit import STATE_DIR
state_dir = Path(STATE_DIR, "gobby")
data_dir = Path("/var/lib/infinoted")
docs_dir = Path(data_dir, "docs")
log_file = Path(data_dir, "infinoted.log")
class DataDir(MountPoint):
source = Path("data")
target = Path("/var/lib/infinoted")
owner = "infinoted"
group = "infinoted"
mode = 0o700
is_dir = True
data_dir = DataDir()
log_file = Path(data_dir.target, "infinoted.log")
class InfinotedConfigFile(IniLikeConfigFile, MountPoint):
......@@ -31,7 +35,7 @@ class InfinotedConfigFile(IniLikeConfigFile, MountPoint):
[infinoted]
root-directory={}
log-file={}
security-policy=no-tls'''.format(data_dir, log_file)
security-policy=no-tls'''.format(data_dir.target, log_file)
# XXX: Remove once infinoted Debian package ships its own systemd unit file (see Debian bug #810865)
......@@ -108,7 +112,6 @@ class GobbyServer(OnionService):
systemd_service = "infinoted.service"
packages = ["infinoted"]
state_dir = state_dir
port = 6523
group_order = ["connection", "generic-checkbox", "advanced"]
......@@ -125,14 +128,15 @@ class GobbyServer(OnionService):
data_files = [
config_file,
systemd_unit_file,
MountPoint(source=Path("data"), target=data_dir, owner="infinoted", group="infinoted", mode=0o700, is_dir=True)
data_dir
]
user = "infinoted"
def configure_top(self):
sh.adduser("--system", "--group", "--home", data_dir, "--no-create-home", "--shell",
"/bin/false", "--disabled-login", self.user)
# Create user
self.container.execute_command("adduser --system --group --home {home} --no-create-home --shell /bin/false "
"--disabled-login {user}".format(home=data_dir.target, user=self.user))
def configure_bottom(self):
self.set_option("AllowLocalhost", True)
......
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