252c5ab163a5 — Alain Leufroy 3 years ago
status: add status command

Simply call the `systemctl status` command for both automount and mount units.
1 files changed, 32 insertions(+), 0 deletions(-)

M overlayctl
M overlayctl +32 -0
@@ 781,6 781,18 @@ def shower(name):
     '''))
 
 
+def statuser(name):
+    layer = build_layer(name)
+    if not layer.is_managed():
+        logger.error('Not found.')
+        return
+    Popen(['systemctl', 'status', layer.automountunit.path.name], stdout=sys.stdout).wait()
+    print('')
+    Popen(['systemctl', 'status', layer.mountunit.path.name], stdout=sys.stdout).wait()
+    # print(layer.mountunit.status())
+
+
+
 def deplacer(oldname, newname, interrupt=False, preserve=False):
     # Checks
     _new = Layer(newname)

          
@@ 1084,6 1096,26 @@ def main():
 
     show.set_defaults(func=_shower)
 
+    # status
+    status = subparser.add_parser(
+        'status',
+        help="Status of the overlay layer",
+        description="Display the effective status of the layer."
+    )
+    status.add_argument(
+        'mountdir',
+        metavar='MOUNTDIR',
+        help=(
+            "overlay mount point. If just a name (without any \"%s\"), "
+            "it is assumed to be %s/{MOUNTDIR}" % (os.path.sep, MOUNTDIR)
+        ),
+    )
+
+    def _statuser(args):
+        statuser(args.mountdir)
+
+    status.set_defaults(func=_statuser)
+
     # edit
     edit = subparser.add_parser(
         'edit',