Development
This commit is contained in:
parent
8766c6c9a2
commit
ee31a18ac6
43 changed files with 54 additions and 48 deletions
90
docker/routlin-dash/app/main.py
Normal file
90
docker/routlin-dash/app/main.py
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
import os, json, sys
|
||||
from flask import Flask
|
||||
from view_page import bp as view_page_bp
|
||||
from action_apply_general import bp as action_apply_general_bp
|
||||
from action_apply_upstream_dns import bp as action_apply_upstream_dns_bp
|
||||
from action_apply_mdns import bp as action_apply_mdns_bp
|
||||
from action_apply_vpn import bp as action_apply_vpn_bp
|
||||
from action_apply_banned_ips import bp as action_apply_banned_ips_bp
|
||||
from action_apply_host_overrides import bp as action_apply_host_overrides_bp
|
||||
from action_apply_blocklists import bp as action_apply_blocklists_bp
|
||||
from action_apply_vlans import bp as action_apply_vlans_bp
|
||||
from action_apply_inter_vlan import bp as action_apply_inter_vlan_bp
|
||||
from action_apply_port_forwarding import bp as action_apply_port_forwarding_bp
|
||||
from action_apply_dhcp_reservations import bp as action_apply_dhcp_reservations_bp
|
||||
from action_create_account import bp as action_create_account_bp
|
||||
from action_log_in import bp as action_log_in_bp
|
||||
from action_log_out import bp as action_log_out_bp
|
||||
from action_verify_email import bp as action_verify_email_bp
|
||||
from action_add_account import bp as action_add_account_bp
|
||||
from action_delete_account import bp as action_delete_account_bp
|
||||
from action_save_preferences import bp as action_save_preferences_bp
|
||||
from action_change_password import bp as action_change_password_bp
|
||||
from action_clear_ddns_log import bp as action_clear_ddns_log_bp
|
||||
from action_apply_ddns_providers import bp as action_apply_ddns_providers_bp
|
||||
from action_apply_interface import bp as action_apply_interface_bp
|
||||
from action_apply_iface_config import bp as action_apply_iface_config_bp
|
||||
from api_apply_status import bp as api_apply_status_bp
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = os.environ.get('SECRET_KEY', os.urandom(24))
|
||||
app.register_blueprint(view_page_bp)
|
||||
app.register_blueprint(action_apply_general_bp)
|
||||
app.register_blueprint(action_apply_upstream_dns_bp)
|
||||
app.register_blueprint(action_apply_mdns_bp)
|
||||
app.register_blueprint(action_apply_vpn_bp)
|
||||
app.register_blueprint(action_apply_banned_ips_bp)
|
||||
app.register_blueprint(action_apply_host_overrides_bp)
|
||||
app.register_blueprint(action_apply_blocklists_bp)
|
||||
app.register_blueprint(action_apply_vlans_bp)
|
||||
app.register_blueprint(action_apply_inter_vlan_bp)
|
||||
app.register_blueprint(action_apply_port_forwarding_bp)
|
||||
app.register_blueprint(action_apply_dhcp_reservations_bp)
|
||||
app.register_blueprint(action_create_account_bp)
|
||||
app.register_blueprint(action_log_in_bp)
|
||||
app.register_blueprint(action_log_out_bp)
|
||||
app.register_blueprint(action_verify_email_bp)
|
||||
app.register_blueprint(action_add_account_bp)
|
||||
app.register_blueprint(action_delete_account_bp)
|
||||
app.register_blueprint(action_save_preferences_bp)
|
||||
app.register_blueprint(action_change_password_bp)
|
||||
app.register_blueprint(action_clear_ddns_log_bp)
|
||||
app.register_blueprint(action_apply_ddns_providers_bp)
|
||||
app.register_blueprint(action_apply_interface_bp)
|
||||
app.register_blueprint(action_apply_iface_config_bp)
|
||||
app.register_blueprint(api_apply_status_bp)
|
||||
|
||||
def _seed_initial_account():
|
||||
email = os.environ.get('INITIAL_MANAGER_EMAIL', '').strip().lower()
|
||||
if not email:
|
||||
try:
|
||||
with open(accounts_file) as f:
|
||||
data = json.load(f)
|
||||
except Exception:
|
||||
data = {'accounts': []}
|
||||
if not data.get('accounts'):
|
||||
print('[main] WARNING: No accounts exist and INITIAL_MANAGER_EMAIL is not set. '
|
||||
'Set it in docker-compose.yml to seed the initial manager account.', file=sys.stderr)
|
||||
return
|
||||
accounts_file = '/data/authorized_accounts.json'
|
||||
try:
|
||||
with open(accounts_file) as f:
|
||||
data = json.load(f)
|
||||
except Exception:
|
||||
data = {'accounts': []}
|
||||
if data.get('accounts'):
|
||||
return
|
||||
data['accounts'] = [{
|
||||
'email_address': email,
|
||||
'access_level': 'manager',
|
||||
'hashed_password': '',
|
||||
'timezone': '',
|
||||
}]
|
||||
with open(accounts_file, 'w') as f:
|
||||
json.dump(data, f, indent=2)
|
||||
print(f'[main] Seeded initial manager account: {email}', file=sys.stderr)
|
||||
|
||||
_seed_initial_account()
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=25327)
|
||||
Loading…
Add table
Add a link
Reference in a new issue