Add vmmgr init method and all files managed by vmmgr
This commit is contained in:
parent
3b9cbe61b3
commit
c2207195cc
@ -1,6 +1,16 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
command=/usr/share/vmmgr/wsgi.py
|
||||
command="/usr/share/vmmgr/wsgi.py"
|
||||
description="VM manager"
|
||||
pidfile=/var/run/vmmgr.pid
|
||||
pidfile="/var/run/vmmgr.pid"
|
||||
start_stop_daemon_args="--background --make-pidfile --stdout /var/log/vmmgr.log --stderr /var/log/vmmgr.log"
|
||||
|
||||
depend() {
|
||||
before nginx
|
||||
}
|
||||
|
||||
start_pre() {
|
||||
if [ ! -f /etc/ssl/services.pem ]; then
|
||||
/usr/bin/vmmgr init
|
||||
fi
|
||||
}
|
||||
|
14
etc/nginx/vmmgr_common
Normal file
14
etc/nginx/vmmgr_common
Normal file
@ -0,0 +1,14 @@
|
||||
error_page 502 /502.html;
|
||||
location = /502.html {
|
||||
root /usr/share/vmmgr/templates;
|
||||
}
|
||||
|
||||
error_page 503 /503.html;
|
||||
location = /503.html {
|
||||
root /usr/share/vmmgr/templates;
|
||||
}
|
||||
|
||||
location = /vm-ping {
|
||||
add_header Content-Type text/plain;
|
||||
return 200 "vm-pong";
|
||||
}
|
5
etc/periodic/daily/acme.sh
Normal file
5
etc/periodic/daily/acme.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Sleep randomly up to 1hr to avoid peak on ACME server
|
||||
/bin/sleep $(/usr/bin/shuf -i 60-3600 -n 1)
|
||||
/usr/bin/acme.sh --home /etc/acme.sh.d --cron >/dev/null
|
4
etc/wireguard/wg0.conf.disabled
Normal file
4
etc/wireguard/wg0.conf.disabled
Normal file
@ -0,0 +1,4 @@
|
||||
[Interface]
|
||||
ListenPort = 51820
|
||||
PrivateKey = None
|
||||
|
8
sbin/vmtty
Executable file
8
sbin/vmtty
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Rebuild /etc/issue
|
||||
/usr/bin/vmmgr rebuild-issue
|
||||
# Print /etc/issue
|
||||
/bin/cat /etc/issue
|
||||
# Wait for key press
|
||||
read a
|
@ -17,6 +17,12 @@ def rebuild_issue():
|
||||
# Used by inittab on VM startup
|
||||
vmmgr.rebuild_issue()
|
||||
|
||||
def init()
|
||||
# Used during the very first vmmgr service startup
|
||||
vmmgr.create_selfsigned_cert()
|
||||
host = config.get_host()
|
||||
vmmgr.update_host(host['domain'], host['port'])
|
||||
|
||||
parser = argparse.ArgumentParser(description='VM application manager')
|
||||
parser.set_defaults(action=None)
|
||||
subparsers = parser.add_subparsers()
|
||||
@ -35,6 +41,9 @@ parser_unregister_app.add_argument('app', help='Application name')
|
||||
parser_rebuild_issue = subparsers.add_parser('rebuild-issue')
|
||||
parser_rebuild_issue.set_defaults(action=rebuild_issue)
|
||||
|
||||
parser_init = subparsers.add_parser('init')
|
||||
parser_init.set_defaults(action=init)
|
||||
|
||||
args = parser.parse_args()
|
||||
if args.action is register_app:
|
||||
register_app(args.app, args.host, args.login, args.password)
|
||||
@ -42,5 +51,7 @@ elif args.action is unregister_app:
|
||||
unregister_app(args.app)
|
||||
elif args.action is rebuild_issue:
|
||||
rebuild_issue()
|
||||
elif args.action is init:
|
||||
init()
|
||||
else:
|
||||
parser.print_usage()
|
||||
|
@ -11,15 +11,7 @@ NGINX = '''server {{
|
||||
proxy_pass http://{ip}:8080;
|
||||
}}
|
||||
|
||||
error_page 502 /502.html;
|
||||
location = /502.html {{
|
||||
root /usr/share/vmmgr/templates;
|
||||
}}
|
||||
|
||||
location = /vm-ping {{
|
||||
add_header Content-Type text/plain;
|
||||
return 200 "vm-pong";
|
||||
}}
|
||||
include vmmgr_common;
|
||||
}}
|
||||
'''
|
||||
|
||||
@ -34,10 +26,7 @@ NGINX_DEFAULT = '''server {{
|
||||
root /etc/acme.sh.d;
|
||||
}}
|
||||
|
||||
location = /vm-ping {{
|
||||
add_header Content-Type text/plain;
|
||||
return 200 "vm-pong";
|
||||
}}
|
||||
include vmmgr_common;
|
||||
}}
|
||||
|
||||
server {{
|
||||
@ -51,38 +40,18 @@ server {{
|
||||
root /usr/share/vmmgr;
|
||||
}}
|
||||
|
||||
error_page 502 /502.html;
|
||||
location = /502.html {{
|
||||
root /usr/share/vmmgr/templates;
|
||||
}}
|
||||
|
||||
location = /vm-ping {{
|
||||
add_header Content-Type text/plain;
|
||||
return 200 "vm-pong";
|
||||
}}
|
||||
include vmmgr_common;
|
||||
}}
|
||||
|
||||
server {{
|
||||
listen [::]:{port} ssl http2;
|
||||
server_name ~^(.*)\\.{domain_esc}$;
|
||||
server_name *.{domain};
|
||||
|
||||
location / {{
|
||||
return 503;
|
||||
}}
|
||||
|
||||
location /static {{
|
||||
root /usr/share/vmmgr;
|
||||
}}
|
||||
|
||||
error_page 503 /503.html;
|
||||
location = /503.html {{
|
||||
root /usr/share/vmmgr/templates;
|
||||
}}
|
||||
|
||||
location = /vm-ping {{
|
||||
add_header Content-Type text/plain;
|
||||
return 200 "vm-pong";
|
||||
}}
|
||||
include vmmgr_common;
|
||||
}}
|
||||
'''
|
||||
|
||||
|
@ -51,7 +51,7 @@ def update_host(domain, port):
|
||||
config.set_host('port', port)
|
||||
# Rebuild nginx config for the portal and existing apps. Web interface calls restart_nginx() in WSGI close handler
|
||||
with open(os.path.join(paths.NGINX_DIR, 'default.conf'), 'w') as f:
|
||||
f.write(templates.NGINX_DEFAULT.format(port=port, domain_esc=domain.replace('.', '\\.')))
|
||||
f.write(templates.NGINX_DEFAULT.format(port=port, domain=domain))
|
||||
for app in config.get_apps().keys():
|
||||
register_proxy(app)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user