diff --git a/usr/bin/lxchelper b/usr/bin/lxchelper index 3afc20e..c64e9ba 100755 --- a/usr/bin/lxchelper +++ b/usr/bin/lxchelper @@ -65,4 +65,8 @@ parser_extract.add_argument('container', help='Container name') parser_extract.add_argument('source', help='Source file or directory within the container') parser_extract.add_argument('destination', help='Destination file or directory on the host') -main(parser.parse_args()) +args = parser.parse_args() +if hasattr(args, 'action'): + main(args) +else: + parser.print_usage() diff --git a/usr/bin/lxcmgr b/usr/bin/lxcmgr index 8f3827f..89e1582 100755 --- a/usr/bin/lxcmgr +++ b/usr/bin/lxcmgr @@ -105,6 +105,7 @@ parser = argparse.ArgumentParser(description='LXC container and package manager' subparsers = parser.add_subparsers() parser_list = subparsers.add_parser('list') +parser_list.set_defaults(action='list-installed') subparsers_list = parser_list.add_subparsers() parser_list_installed = subparsers_list.add_parser('installed') parser_list_installed.set_defaults(action='list-installed') @@ -125,4 +126,8 @@ parser_uninstall = subparsers.add_parser('uninstall') parser_uninstall.set_defaults(action='uninstall') parser_uninstall.add_argument('app', help='Application to uninstall') -main(parser.parse_args()) +args = parser.parse_args() +if hasattr(args, 'action'): + main(args) +else: + parser.print_usage() diff --git a/usr/bin/vmmgr b/usr/bin/vmmgr index edf411f..6263790 100755 --- a/usr/bin/vmmgr +++ b/usr/bin/vmmgr @@ -6,6 +6,24 @@ import argparse from vmmgr.config import Config from vmmgr.vmmgr import VMMgr +def main(args): + vmmgr = VMMgr(Config()) + if args.action == 'register-app': + # Used by package install.sh script + vmmgr.register_app(args.app, args.host, args.login, args.password) + elif args.action == 'unregister-app': + # Used by package uninstall.sh script + vmmgr.unregister_app(args.app) + elif args.action == 'rebuild-issue': + # Used by inittab on VM startup + vmmgr.rebuild_issue() + elif args.action == 'register-proxy': + # Used in init scripts on application startup + vmmgr.register_proxy(args.app) + elif args.action == 'unregister-proxy': + # Used in init scripts on application stop + vmmgr.unregister_proxy(args.app) + parser = argparse.ArgumentParser(description='VM application manager') subparsers = parser.add_subparsers() @@ -32,19 +50,7 @@ parser_unregister_proxy.set_defaults(action='unregister-proxy') parser_unregister_proxy.add_argument('app', help='Application name') args = parser.parse_args() -vmmgr = VMMgr(Config()) -if args.action == 'register-app': - # Used by package install.sh script - vmmgr.register_app(args.app, args.host, args.login, args.password) -elif args.action == 'unregister-app': - # Used by package uninstall.sh script - vmmgr.unregister_app(args.app) -elif args.action == 'rebuild-issue': - # Used by inittab on VM startup - vmmgr.rebuild_issue() -elif args.action == 'register-proxy': - # Used in init scripts on application startup - vmmgr.register_proxy(args.app) -elif args.action == 'unregister-proxy': - # Used in init scripts on application stop - vmmgr.unregister_proxy(args.app) +if hasattr(args, 'action'): + main(args) +else: + parser.print_usage()