add systemd -a list

This commit is contained in:
Muayyad alsadi 2022-03-14 14:05:20 +03:00
parent b620311aaf
commit 1a72e1e087

View File

@ -16,6 +16,7 @@ import re
import hashlib import hashlib
import random import random
import json import json
import glob
from threading import Thread from threading import Thread
@ -1726,6 +1727,10 @@ def compose_systemd(compose, args):
f"""later you can use use enable, start, stop, status, cat f"""later you can use use enable, start, stop, status, cat
like this `systemctl --user enable --now podman-compose@{proj_name}`""" like this `systemctl --user enable --now podman-compose@{proj_name}`"""
) )
elif args.action == "list" or args.action == "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": elif args.action == "create-unit":
script = os.path.realpath(sys.argv[0]) script = os.path.realpath(sys.argv[0])
fn = "/usr/lib/systemd/user/podman-compose@.service" fn = "/usr/lib/systemd/user/podman-compose@.service"
@ -2512,7 +2517,7 @@ def compose_systemd_parse(parser):
parser.add_argument( parser.add_argument(
"-a", "-a",
"--action", "--action",
choices=["register", "create-unit"], choices=["register", "create-unit", "list", "ls"],
default="register", default="register",
help="create systemd unit file or register compose stack to it", help="create systemd unit file or register compose stack to it",
) )