diff --git a/local-deploy.py b/local-deploy.py index 7d572b9..e549576 100644 --- a/local-deploy.py +++ b/local-deploy.py @@ -5,7 +5,7 @@ from pyinfra.operations import apt, files, pip, server, systemd # install into .local/lib -def install(unix_user) -> None: +def install(unix_user, enable_linger=True) -> None: remember_package = importlib.resources.files("remember_remember_bot") working_directory = os.getcwd() remote_venv_dir = f"{working_directory}/venv" @@ -13,6 +13,22 @@ def install(unix_user) -> None: # install systemd units fn = "remember-remember-bot" service_file = remember_package / "pyinfra_assets" / f"{fn}.service.j2" + if enable_linger: + server.shell( + name=f"enable {unix_user}'s systemd units to auto-start at boot", + commands=[f"loginctl enable-linger {unix_user}"], + ) + files.line( + name=f"{unix_user} .profile: ensure XDG_RUNTIME_DIR", + path=f"/home/{unix_user}/.profile", + line='export XDG_RUNTIME_DIR="/run/user/$UID"', + ) + files.line( + name=f"{unix_user} .profile: ensure DBUS_SESSION_BUS_ADDRESS", + path=f"/home/{unix_user}/.profile", + line='export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"', + ) + files.template( name=f"Upload {fn}.service", src=service_file,