diff --git a/config.default.json b/etc/vmmgr/config.default.json similarity index 100% rename from config.default.json rename to etc/vmmgr/config.default.json diff --git a/packages.pub b/etc/vmmgr/packages.pub similarity index 100% rename from packages.pub rename to etc/vmmgr/packages.pub diff --git a/usr/bin/vmmgr b/usr/bin/vmmgr new file mode 100755 index 0000000..d607a8a --- /dev/null +++ b/usr/bin/vmmgr @@ -0,0 +1,62 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +import argparse +import sys +from vmmgr import VMMgr + +parser = argparse.ArgumentParser(description='VM application manager') +subparsers = parser.add_subparsers() + +parser_update_login = subparsers.add_parser('update-login') +parser_update_login.set_defaults(action='update-login') +parser_update_login.add_argument('app', help='Application name') +parser_update_login.add_argument('login', help='Administrative login') +parser_update_login.add_argument('password', help='Administrative password') + +parser_rebuild_issue = subparsers.add_parser('rebuild-issue') +parser_rebuild_issue.set_defaults(action='rebuild-issue') + +parser_prepare_container = subparsers.add_parser('prepare-container') +parser_prepare_container.add_argument('lxc', nargs=argparse.REMAINDER) +parser_prepare_container.set_defaults(action='prepare-container') + +parser_register_container = subparsers.add_parser('register-container') +parser_register_container.add_argument('lxc', nargs=argparse.REMAINDER) +parser_register_container.set_defaults(action='register-container') + +parser_unregister_container = subparsers.add_parser('unregister-container') +parser_unregister_container.add_argument('lxc', nargs=argparse.REMAINDER) +parser_unregister_container.set_defaults(action='unregister-container') + +parser_register_proxy = subparsers.add_parser('register-proxy') +parser_register_proxy.set_defaults(action='register-proxy') +parser_register_proxy.add_argument('app', help='Application name') + +parser_unregister_proxy = subparsers.add_parser('unregister-proxy') +parser_unregister_proxy.set_defaults(action='unregister-proxy') +parser_unregister_proxy.add_argument('app', help='Application name') + +args = parser.parse_args() +mgr = VMMgr() +if args.action == 'update-login': + # Used by app install scripts + mgr.update_login(args.app, args.login, args.password) +elif args.action == 'rebuild-issue': + # Used on VM startup + mgr.rebuild_issue() +elif args.action == 'prepare-container': + # Used with LXC hooks + mgr.prepare_container() +elif args.action == 'register-container': + # Used with LXC hooks + mgr.register_container() +elif args.action == 'unregister-container': + # Used with LXC hooks + mgr.unregister_container() +elif args.action == 'register-proxy': + # Used in init scripts + mgr.register_proxy(args.app) +elif args.action == 'unregister-proxy': + # Used in init scripts + mgr.unregister_proxy(args.app) diff --git a/mgr/__init__.py b/usr/lib/python3.6/vmmgr/__init__.py similarity index 99% rename from mgr/__init__.py rename to usr/lib/python3.6/vmmgr/__init__.py index 36326f5..33a332b 100644 --- a/mgr/__init__.py +++ b/usr/lib/python3.6/vmmgr/__init__.py @@ -30,7 +30,7 @@ NGINX_TEMPLATE = '''server {{ error_page 502 /502.html; location = /502.html {{ - root /srv/vm/templates; + root /usr/share/vmmgr/templates; }} location = /vm-ping {{ @@ -65,12 +65,12 @@ server {{ }} location /static {{ - root /srv/vm; + root /usr/share/vmmgr; }} error_page 502 /502.html; location = /502.html {{ - root /srv/vm/templates; + root /usr/share/vmmgr/templates; }} location = /vm-ping {{ diff --git a/mgr/appmgr.py b/usr/lib/python3.6/vmmgr/appmgr.py similarity index 99% rename from mgr/appmgr.py rename to usr/lib/python3.6/vmmgr/appmgr.py index 5338097..01af399 100644 --- a/mgr/appmgr.py +++ b/usr/lib/python3.6/vmmgr/appmgr.py @@ -18,7 +18,7 @@ from threading import Lock from . import tools -PUB_FILE = '/srv/vm/packages.pub' +PUB_FILE = '/etc/vmmgr/packages.pub' LXC_ROOT = '/var/lib/lxc' class ActionItem: diff --git a/mgr/config.py b/usr/lib/python3.6/vmmgr/config.py similarity index 93% rename from mgr/config.py rename to usr/lib/python3.6/vmmgr/config.py index 1bf0752..4aa0355 100644 --- a/mgr/config.py +++ b/usr/lib/python3.6/vmmgr/config.py @@ -3,7 +3,7 @@ import json from threading import Lock -CONF_FILE = '/srv/vm/config.json' +CONF_FILE = '/etc/vmmgr/config.json' class Config: def __init__(self): diff --git a/mgr/tools.py b/usr/lib/python3.6/vmmgr/tools.py similarity index 100% rename from mgr/tools.py rename to usr/lib/python3.6/vmmgr/tools.py diff --git a/mgr/validator.py b/usr/lib/python3.6/vmmgr/validator.py similarity index 100% rename from mgr/validator.py rename to usr/lib/python3.6/vmmgr/validator.py diff --git a/mgr/wsgiapp.py b/usr/lib/python3.6/vmmgr/wsgiapp.py similarity index 99% rename from mgr/wsgiapp.py rename to usr/lib/python3.6/vmmgr/wsgiapp.py index f39fca1..032f7f8 100644 --- a/mgr/wsgiapp.py +++ b/usr/lib/python3.6/vmmgr/wsgiapp.py @@ -24,7 +24,7 @@ class WSGIApp(object): self.vmmgr = VMMgr() self.appmgr = AppMgr(self.vmmgr) self.conf = self.vmmgr.conf - self.jinja_env = Environment(loader=FileSystemLoader('/srv/vm/templates'), autoescape=True, lstrip_blocks=True, trim_blocks=True) + self.jinja_env = Environment(loader=FileSystemLoader('/usr/share/vmmgr/templates'), autoescape=True, lstrip_blocks=True, trim_blocks=True) self.jinja_env.globals.update(is_app_visible=self.is_app_visible) self.jinja_env.globals.update(is_service_autostarted=tools.is_service_autostarted) self.jinja_env.globals.update(is_service_started=tools.is_service_started) diff --git a/mgr/wsgilang.py b/usr/lib/python3.6/vmmgr/wsgilang.py similarity index 100% rename from mgr/wsgilang.py rename to usr/lib/python3.6/vmmgr/wsgilang.py diff --git a/mgr/wsgisession.py b/usr/lib/python3.6/vmmgr/wsgisession.py similarity index 100% rename from mgr/wsgisession.py rename to usr/lib/python3.6/vmmgr/wsgisession.py diff --git a/static/css/style.css b/usr/share/vmmgr/static/css/style.css similarity index 100% rename from static/css/style.css rename to usr/share/vmmgr/static/css/style.css diff --git a/static/img/CAP.png b/usr/share/vmmgr/static/img/CAP.png similarity index 100% rename from static/img/CAP.png rename to usr/share/vmmgr/static/img/CAP.png diff --git a/static/img/CKAN.png b/usr/share/vmmgr/static/img/CKAN.png similarity index 100% rename from static/img/CKAN.png rename to usr/share/vmmgr/static/img/CKAN.png diff --git a/static/img/CTS.png b/usr/share/vmmgr/static/img/CTS.png similarity index 100% rename from static/img/CTS.png rename to usr/share/vmmgr/static/img/CTS.png diff --git a/static/img/Cluster_Spotter.png b/usr/share/vmmgr/static/img/Cluster_Spotter.png similarity index 100% rename from static/img/Cluster_Spotter.png rename to usr/share/vmmgr/static/img/Cluster_Spotter.png diff --git a/static/img/Crisis_Cleanup.png b/usr/share/vmmgr/static/img/Crisis_Cleanup.png similarity index 100% rename from static/img/Crisis_Cleanup.png rename to usr/share/vmmgr/static/img/Crisis_Cleanup.png diff --git a/static/img/Diaspora.png b/usr/share/vmmgr/static/img/Diaspora.png similarity index 100% rename from static/img/Diaspora.png rename to usr/share/vmmgr/static/img/Diaspora.png diff --git a/static/img/EDEN.png b/usr/share/vmmgr/static/img/EDEN.png similarity index 100% rename from static/img/EDEN.png rename to usr/share/vmmgr/static/img/EDEN.png diff --git a/static/img/FrontlineSMS.png b/usr/share/vmmgr/static/img/FrontlineSMS.png similarity index 100% rename from static/img/FrontlineSMS.png rename to usr/share/vmmgr/static/img/FrontlineSMS.png diff --git a/static/img/FrontlineSync.png b/usr/share/vmmgr/static/img/FrontlineSync.png similarity index 100% rename from static/img/FrontlineSync.png rename to usr/share/vmmgr/static/img/FrontlineSync.png diff --git a/static/img/GNU_Health.png b/usr/share/vmmgr/static/img/GNU_Health.png similarity index 100% rename from static/img/GNU_Health.png rename to usr/share/vmmgr/static/img/GNU_Health.png diff --git a/static/img/GeoODK_Collect.png b/usr/share/vmmgr/static/img/GeoODK_Collect.png similarity index 100% rename from static/img/GeoODK_Collect.png rename to usr/share/vmmgr/static/img/GeoODK_Collect.png diff --git a/static/img/Kanboard.png b/usr/share/vmmgr/static/img/Kanboard.png similarity index 100% rename from static/img/Kanboard.png rename to usr/share/vmmgr/static/img/Kanboard.png diff --git a/static/img/MifosX.png b/usr/share/vmmgr/static/img/MifosX.png similarity index 100% rename from static/img/MifosX.png rename to usr/share/vmmgr/static/img/MifosX.png diff --git a/static/img/MifosX_Mobile.png b/usr/share/vmmgr/static/img/MifosX_Mobile.png similarity index 100% rename from static/img/MifosX_Mobile.png rename to usr/share/vmmgr/static/img/MifosX_Mobile.png diff --git a/static/img/Motech.png b/usr/share/vmmgr/static/img/Motech.png similarity index 100% rename from static/img/Motech.png rename to usr/share/vmmgr/static/img/Motech.png diff --git a/static/img/ODK.png b/usr/share/vmmgr/static/img/ODK.png similarity index 100% rename from static/img/ODK.png rename to usr/share/vmmgr/static/img/ODK.png diff --git a/static/img/ODK_Collect.png b/usr/share/vmmgr/static/img/ODK_Collect.png similarity index 100% rename from static/img/ODK_Collect.png rename to usr/share/vmmgr/static/img/ODK_Collect.png diff --git a/static/img/OMK.png b/usr/share/vmmgr/static/img/OMK.png similarity index 100% rename from static/img/OMK.png rename to usr/share/vmmgr/static/img/OMK.png diff --git a/static/img/OpenID.png b/usr/share/vmmgr/static/img/OpenID.png similarity index 100% rename from static/img/OpenID.png rename to usr/share/vmmgr/static/img/OpenID.png diff --git a/static/img/POSM.png b/usr/share/vmmgr/static/img/POSM.png similarity index 100% rename from static/img/POSM.png rename to usr/share/vmmgr/static/img/POSM.png diff --git a/static/img/Pandora.png b/usr/share/vmmgr/static/img/Pandora.png similarity index 100% rename from static/img/Pandora.png rename to usr/share/vmmgr/static/img/Pandora.png diff --git a/static/img/PostGIS.png b/usr/share/vmmgr/static/img/PostGIS.png similarity index 100% rename from static/img/PostGIS.png rename to usr/share/vmmgr/static/img/PostGIS.png diff --git a/static/img/SMS_Sync.png b/usr/share/vmmgr/static/img/SMS_Sync.png similarity index 100% rename from static/img/SMS_Sync.png rename to usr/share/vmmgr/static/img/SMS_Sync.png diff --git a/static/img/SeedDMS.png b/usr/share/vmmgr/static/img/SeedDMS.png similarity index 100% rename from static/img/SeedDMS.png rename to usr/share/vmmgr/static/img/SeedDMS.png diff --git a/static/img/Sigmah.png b/usr/share/vmmgr/static/img/Sigmah.png similarity index 100% rename from static/img/Sigmah.png rename to usr/share/vmmgr/static/img/Sigmah.png diff --git a/static/img/Ushahidi.png b/usr/share/vmmgr/static/img/Ushahidi.png similarity index 100% rename from static/img/Ushahidi.png rename to usr/share/vmmgr/static/img/Ushahidi.png diff --git a/static/img/Ushahidi_mobile.png b/usr/share/vmmgr/static/img/Ushahidi_mobile.png similarity index 100% rename from static/img/Ushahidi_mobile.png rename to usr/share/vmmgr/static/img/Ushahidi_mobile.png diff --git a/static/img/icons/Android.png b/usr/share/vmmgr/static/img/icons/Android.png similarity index 100% rename from static/img/icons/Android.png rename to usr/share/vmmgr/static/img/icons/Android.png diff --git a/static/img/icons/Java.png b/usr/share/vmmgr/static/img/icons/Java.png similarity index 100% rename from static/img/icons/Java.png rename to usr/share/vmmgr/static/img/icons/Java.png diff --git a/static/img/icons/Linux.png b/usr/share/vmmgr/static/img/icons/Linux.png similarity index 100% rename from static/img/icons/Linux.png rename to usr/share/vmmgr/static/img/icons/Linux.png diff --git a/static/img/icons/MacOS.png b/usr/share/vmmgr/static/img/icons/MacOS.png similarity index 100% rename from static/img/icons/MacOS.png rename to usr/share/vmmgr/static/img/icons/MacOS.png diff --git a/static/img/icons/Windows.png b/usr/share/vmmgr/static/img/icons/Windows.png similarity index 100% rename from static/img/icons/Windows.png rename to usr/share/vmmgr/static/img/icons/Windows.png diff --git a/static/img/icons/iOS.png b/usr/share/vmmgr/static/img/icons/iOS.png similarity index 100% rename from static/img/icons/iOS.png rename to usr/share/vmmgr/static/img/icons/iOS.png diff --git a/static/js/admin.js b/usr/share/vmmgr/static/js/admin.js similarity index 100% rename from static/js/admin.js rename to usr/share/vmmgr/static/js/admin.js diff --git a/static/js/jquery-3.3.1.min.js b/usr/share/vmmgr/static/js/jquery-3.3.1.min.js similarity index 100% rename from static/js/jquery-3.3.1.min.js rename to usr/share/vmmgr/static/js/jquery-3.3.1.min.js diff --git a/static/js/script.js b/usr/share/vmmgr/static/js/script.js similarity index 100% rename from static/js/script.js rename to usr/share/vmmgr/static/js/script.js diff --git a/templates/404.html b/usr/share/vmmgr/templates/404.html similarity index 100% rename from templates/404.html rename to usr/share/vmmgr/templates/404.html diff --git a/templates/502.html b/usr/share/vmmgr/templates/502.html similarity index 100% rename from templates/502.html rename to usr/share/vmmgr/templates/502.html diff --git a/templates/layout.html b/usr/share/vmmgr/templates/layout.html similarity index 100% rename from templates/layout.html rename to usr/share/vmmgr/templates/layout.html diff --git a/templates/login.html b/usr/share/vmmgr/templates/login.html similarity index 100% rename from templates/login.html rename to usr/share/vmmgr/templates/login.html diff --git a/templates/portal-admin.html b/usr/share/vmmgr/templates/portal-admin.html similarity index 100% rename from templates/portal-admin.html rename to usr/share/vmmgr/templates/portal-admin.html diff --git a/templates/portal-user.html b/usr/share/vmmgr/templates/portal-user.html similarity index 100% rename from templates/portal-user.html rename to usr/share/vmmgr/templates/portal-user.html diff --git a/templates/setup-apps-row.html b/usr/share/vmmgr/templates/setup-apps-row.html similarity index 100% rename from templates/setup-apps-row.html rename to usr/share/vmmgr/templates/setup-apps-row.html diff --git a/templates/setup-apps.html b/usr/share/vmmgr/templates/setup-apps.html similarity index 100% rename from templates/setup-apps.html rename to usr/share/vmmgr/templates/setup-apps.html diff --git a/templates/setup-host.html b/usr/share/vmmgr/templates/setup-host.html similarity index 100% rename from templates/setup-host.html rename to usr/share/vmmgr/templates/setup-host.html diff --git a/wsgi.py b/usr/share/vmmgr/wsgi.py similarity index 82% rename from wsgi.py rename to usr/share/vmmgr/wsgi.py index 4f5c9a8..a289602 100755 --- a/wsgi.py +++ b/usr/share/vmmgr/wsgi.py @@ -2,9 +2,7 @@ # -*- coding: utf-8 -*- import sys - -sys.path.append('/srv/vm') -from mgr.wsgiapp import WSGIApp +from vmmgr.wsgiapp import WSGIApp application = WSGIApp()