diff --git a/podman_compose.py b/podman_compose.py index c6e7f41..55c1fff 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -9,6 +9,7 @@ import sys import os +import getpass import argparse import subprocess import time @@ -1712,6 +1713,7 @@ def compose_systemd(compose, args): later you can add a compose stack by running `podman-compose -a register` then you can start/stop your stack with `systemctl --user start podman-compose@` """ + script = os.path.realpath(sys.argv[0]) stacks_dir = ".config/containers/compose/projects" if args.action == "register": proj_name = compose.project_name @@ -1723,16 +1725,34 @@ def compose_systemd(compose, args): if k.startswith("COMPOSE_") or k.startswith("PODMAN_"): f.write(f"{k}={v}\n") print(f"writing [{fn}]: done.") - print( - f"""later you can use use enable, start, stop, status, cat -like this `systemctl --user enable --now podman-compose@{proj_name}`""" - ) + print("\n\ncreating the pod without starting it: ...\n\n") + process = subprocess.run([script, "up", "--no-start"]) + print("\nfinal exit code is ", process.returncode) + username = getpass.getuser() + print(f""" +you can use systemd commands like enable, start, stop, status, cat +all without `sudo` like this: + +\t\tsystemctl --user enable --now 'podman-compose@{proj_name}' +\t\tsystemctl --user status 'podman-compose@{proj_name}' +\t\tjournalctl --user -xeu 'podman-compose@{proj_name}' + +and for that to work outside a session +you might need to run the following command *once* + +\t\tsudo loginctl enable-linger '{username}' + +you can use podman commands like: + +\t\tpodman pod ps +\t\tpodman pod stats 'pod_{proj_name}' +\t\tpodman pod logs --tail=10 -f 'pod_{proj_name}' +""") elif args.action in ("list", "ls"): ls = glob.glob(os.path.expanduser(f"~/{stacks_dir}/*.env")) for i in ls: print(os.path.basename(i[:-4])) elif args.action == "create-unit": - script = os.path.realpath(sys.argv[0]) fn = "/usr/lib/systemd/user/podman-compose@.service" out = f"""\ # {fn}