diff --git a/rootfs/standard/usr/bin/mynode-manage-apps b/rootfs/standard/usr/bin/mynode-manage-apps index b84afd09..e6f336cb 100755 --- a/rootfs/standard/usr/bin/mynode-manage-apps +++ b/rootfs/standard/usr/bin/mynode-manage-apps @@ -2,9 +2,16 @@ from argparse import ArgumentParser from application_info import * -import json +import logging +from systemd import journal import os +log = logging.getLogger('mynode_manage_apps') +log.addHandler(journal.JournaldLogHandler()) +log.setLevel(logging.INFO) +set_logger(log) + + def main(): parser = ArgumentParser(prog='mynode-manage-apps') action_choices = ( diff --git a/rootfs/standard/usr/bin/mynode_startup.sh b/rootfs/standard/usr/bin/mynode_startup.sh index 62f8b496..cf96bca8 100755 --- a/rootfs/standard/usr/bin/mynode_startup.sh +++ b/rootfs/standard/usr/bin/mynode_startup.sh @@ -506,6 +506,9 @@ cp -f /usr/share/mynode/netdata.conf /opt/mynode/netdata/netdata.conf mkdir -p /opt/mynode/webssh2 cp -f /usr/share/mynode/webssh2_config.json /opt/mynode/webssh2/config.json +# Initialize Dynamic Apps +mynode-manage-apps init || true + # Backup Tor files for f in /var/lib/tor/mynode*; do rsync --ignore-existing -r -avh $f /mnt/hdd/mynode/tor_backup/ || true diff --git a/rootfs/standard/usr/share/mynode_apps/lndg/app.json b/rootfs/standard/usr/share/mynode_apps/lndg/lndg.json similarity index 59% rename from rootfs/standard/usr/share/mynode_apps/lndg/app.json rename to rootfs/standard/usr/share/mynode_apps/lndg/lndg.json index bf8aa6a0..10c67aca 100644 --- a/rootfs/standard/usr/share/mynode_apps/lndg/app.json +++ b/rootfs/standard/usr/share/mynode_apps/lndg/lndg.json @@ -1,13 +1,17 @@ { "name": "LNDg", "short_name": "lndg", + "latest_version": "v0.0.1", "requires_lightning": true, "hide_status_icon": false, "app_tile_default_status_text": "Lightning Tool", + "app_tile_running_status_text": "Running", "app_tile_button_href": "/lndg", "app_tile_button_text": "Info", "can_uninstall": true, - "can_enable_disable": false, - "show_on_homepage": true, + "can_enable_disable": true, + "show_on_application_page": false, + "show_on_homepage": false, + "port": 3000, "homepage_order": 99 } \ No newline at end of file diff --git a/rootfs/standard/usr/share/mynode_apps/lndg/lndg.png b/rootfs/standard/usr/share/mynode_apps/lndg/lndg.png index e69de29b..a39d0cf3 100644 Binary files a/rootfs/standard/usr/share/mynode_apps/lndg/lndg.png and b/rootfs/standard/usr/share/mynode_apps/lndg/lndg.png differ diff --git a/rootfs/standard/usr/share/mynode_apps/lndg/lndg.service b/rootfs/standard/usr/share/mynode_apps/lndg/lndg.service index e69de29b..5ee0319a 100644 --- a/rootfs/standard/usr/share/mynode_apps/lndg/lndg.service +++ b/rootfs/standard/usr/share/mynode_apps/lndg/lndg.service @@ -0,0 +1,28 @@ +# LNDg Service +# /etc/systemd/system/lndg.service + +[Unit] +Description=LNDg +Wants=www.service docker_images.service +After=www.service docker_images.service + +[Service] +ExecStartPre=/usr/bin/is_not_shutting_down.sh +ExecStartPre=/bin/bash -c 'if [ -f /usr/bin/service_pre/pre_lndg.sh ]; then /bin/bash /usr/bin/service_pre/pre_lndg.sh; fi' +ExecStart=/usr/bin/docker run --rm --name webssh2 -p 2222:2222 -v /opt/mynode/webssh2/config.json:/usr/src/config.json webssh2 +ExecStartPost=/bin/bash -c 'if [ -f /usr/bin/service_post/post_lndg.sh ]; then /bin/bash /usr/bin/service_post/post_lndg.sh; fi' +ExecStop=/usr/bin/docker stop -t 2 webssh2 + +# Need new user +User=root +Group=root +Type=simple +TimeoutSec=120 +Restart=always +RestartSec=60 +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=lndg + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/rootfs/standard/var/pynode/application_info.py b/rootfs/standard/var/pynode/application_info.py index dd42a064..acf00703 100644 --- a/rootfs/standard/var/pynode/application_info.py +++ b/rootfs/standard/var/pynode/application_info.py @@ -159,10 +159,21 @@ def initialize_applications(): for index, app in enumerate(apps): apps[index] = initialize_application_defaults(app) - mynode_applications = copy.deepcopy(apps) + # Load dynamic app JSON files + dynamic_app_dir = get_dynamic_app_dir() + dynamic_app_names = get_dynamic_app_names() + for app_name in dynamic_app_names: + try: + app_dir = dynamic_app_dir + "/" + app_name + with open(app_dir + "/" + app_name + ".json", 'r') as app_info_file: + app = json.load(app_info_file) + apps.append(initialize_application_defaults(app)) + + except Exception as e: + log_message("ERROR: Could not initialize dynamic app {} - {}".format(app_name, str(e))) + + mynode_applications = copy.deepcopy(apps) - # TODO: Load all app-specific JSON files - # ... return def update_applications(include_status=False): @@ -470,6 +481,11 @@ def init_dynamic_app(app_info): log_message(" TODO: Build dockerfile???") log_message(" TODO: Install dockerfile???") + # Other init + log_message(" TODO: Other init") + log_message(" TODO: Open Port") + log_message(" TODO: More???") + log_message(" Done.") def init_dynamic_apps(): @@ -488,4 +504,8 @@ def init_dynamic_apps(): except Exception as e: log_message(" ERROR: Error loading app.json file ({})".format(str(e))) - os.system("systemctl daemon-reload") \ No newline at end of file + # Reload systemctl files + os.system("systemctl daemon-reload") + + # Mark app db for needing reload + # TODO: Need to mark this? all json files should be found early \ No newline at end of file diff --git a/rootfs/standard/var/www/mynode/static/images/app_icons/lndg.png b/rootfs/standard/var/www/mynode/static/images/app_icons/lndg.png new file mode 100644 index 00000000..a39d0cf3 Binary files /dev/null and b/rootfs/standard/var/www/mynode/static/images/app_icons/lndg.png differ