Updates for app api

This commit is contained in:
Taylor Helsper 2022-03-21 23:36:54 -05:00
parent cc5b3de5b1
commit 04b85ea8f9
9 changed files with 60 additions and 10 deletions

View File

@ -1,6 +1,56 @@
#!/usr/local/bin/python3
from argparse import ArgumentParser
import os
APPLICATIONS_FOLDER = "/usr/share/mynode_apps"
def init_application(app_info):
app_name = app_info["short_name"]
app_dir = APPLICATIONS_FOLDER + "/" + app_name
print(" Loading " + app_name + "...")
os.system("cp -f {} {}".format(app_dir+"/app.service", "/etc/systemd/system/"+app_name+".service"))
os.system("cp -f {} {}".format(app_dir+"/"+app_name+".png", "/var/www/mynode/static/images/app_icons/"+app_name+".png"))
if (os.path.isfile(app_dir+"/scripts/pre_"+app_name+".sh")):
os.system("cp -f {} {}".format(app_dir+"/scripts/pre_"+app_name+".sh", "/usr/bin/service_post/pre_"+app_name+".sh"))
if (os.path.isfile(app_dir+"/scripts/post_"+app_name+".sh")):
os.system("cp -f {} {}".format(app_dir+"/scripts/post_"+app_name+".sh", "/usr/bin/service_pre/post_"+app_name+".sh"))
if (os.path.isfile(app_dir+"/scripts/install"+app_name+".sh")):
os.system("cp -f {} {}".format(app_dir+"/scripts/install_"+app_name+".sh", "/usr/bin/service_install/install_"+app_name+".sh"))
if (os.path.isfile(app_dir+"/scripts/uninstall"+app_name+".sh")):
os.system("cp -f {} {}".format(app_dir+"/scripts/uninstall"+app_name+".sh", "/usr/bin/service_uninstall/uninstall_"+app_name+".sh"))
print(" TODO: Install data files")
# For "node" type apps
print(" TODO: Need node special files???")
# For "python" type apps
print(" TODO: Need python special files???")
# For "docker" type apps
print(" TODO: Build dockerfile???")
print(" TODO: Install dockerfile???")
print(" Done.")
def init_applications():
# Loop over each app
for app_folder_name in os.listdir(APPLICATIONS_FOLDER):
print("Found Application: {}".format(app_folder_name))
app_dir = APPLICATIONS_FOLDER + "/" + app_folder_name
try:
app_json_path = app_dir + "/app.json"
with open(app_json_path, 'r') as fp:
app_info = json.load(fp)
init_application(app_info)
except Exception as e:
print(" ERROR: Error loading app.json file")
os.system("systemctl daemon-reload")
def main():
parser = ArgumentParser(prog='mynode-manage-apps')
@ -12,9 +62,9 @@ def main():
args = parser.parse_args()
if args.action == "createbasefolders":
print("createbasefolders")
print("createbasefolders - not needed?")
elif args.action == "init":
print("init")
init_applications()
else:
print("UNKNOWN BASE ACTION")

View File

@ -65,7 +65,7 @@ def is_installed(short_name):
return True
return False
def get_app_current_version(short_name):
def get_app_current_version_from_file(short_name):
version = "unknown"
filename1 = "/home/bitcoin/.mynode/"+short_name+"_version"
filename2 = "/mnt/hdd/mynode/settings/"+short_name+"_version"
@ -81,7 +81,7 @@ def get_app_current_version(short_name):
return to_string(version)
def get_app_latest_version(app):
def get_app_latest_version_from_file(app):
version = "unknown"
filename1 = "/home/bitcoin/.mynode/"+app+"_version_latest"
filename2 = "/mnt/hdd/mynode/settings/"+app+"_version_latest"
@ -104,8 +104,8 @@ def initialize_application_defaults(app):
if not "screenshots" in app: app["screenshots"] = []
if not "app_tile_name" in app: app["app_tile_name"] = app["name"]
if not "is_premium" in app: app["is_premium"] = False
app["current_version"] = get_app_current_version( app["short_name"] )
app["latest_version"] = get_app_latest_version( app["short_name"] )
if not "current_version" in app: app["current_version"] = get_app_current_version_from_file( app["short_name"] )
if not "latest_version" in app: app["latest_version"] = get_app_latest_version_from_file( app["short_name"] )
if not "is_beta" in app: app["is_beta"] = False
app["is_installed"] = is_installed( app["short_name"] )
if not "can_reinstall" in app: app["can_reinstall"] = True

View File

@ -6,7 +6,7 @@
{% if app.is_installed and app.show_on_homepage and app.homepage_section == "apps" %}
<div class="app_tile">
<div class="app_status_icon {% if app.can_enable_disable %}clear{% endif %}" id="{{app.short_name}}_status_icon"></div>
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/")}}{{app.short_name}}.png"/></div>
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/app_icons/")}}{{app.short_name}}.png"/></div>
{% if app.is_beta %}
<img class="app_beta_tag_image" src="{{ url_for('static', filename="images/beta.png")}}"/>
{% endif %}
@ -60,7 +60,7 @@
{% if app.show_on_homepage and app.homepage_section == "remote_services" %}
<div class="app_tile">
<div class="app_status_icon {% if app.can_enable_disable %}clear{% endif %}" id="{{app.short_name}}_status_icon"></div>
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/")}}{{app.short_name}}.png"/></div>
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/app_icons/")}}{{app.short_name}}.png"/></div>
<div class="app_title">{{app.app_tile_name}}</div>
<div class="app_status"id="{{app.short_name}}_status"></div>
<div class="app_contents">

View File

@ -111,7 +111,7 @@
{% if app.show_on_application_page %}
{% if not product_key_skipped or product_key_skipped and not app.is_premium %}
<tr>
<td><img class="app_logo_icon" style="width: 32px;" src="{{ url_for('static', filename="images/")}}{{app.short_name}}.png"/></td>
<td><img class="app_logo_icon" style="width: 32px;" src="{{ url_for('static', filename="images/app_icons/")}}{{app.short_name}}.png"/></td>
<td>{{ app.name }}</td>
<td>
{% if app.is_installed %}
@ -150,7 +150,7 @@
</tr>
{% else%}
<tr>
<td><img class="app_logo_icon" style="width: 32px;" src="{{ url_for('static', filename="images/")}}{{app.short_name}}.png"/></td>
<td><img class="app_logo_icon" style="width: 32px;" src="{{ url_for('static', filename="images/app_icons/")}}{{app.short_name}}.png"/></td>
<td>{{ app.name }}</td>
<td>&nbsp;</td>
<td>&nbsp;</td>