Add app_data and tor service to dynamic apps

This commit is contained in:
Taylor Helsper 2022-05-10 21:07:29 -05:00
parent acfa819319
commit 1634a3007d
6 changed files with 31 additions and 6 deletions

View File

@ -292,3 +292,7 @@ HiddenServicePort 49393 127.0.0.1:49393
HiddenServiceDir /var/lib/tor/mynode_sphinx/ HiddenServiceDir /var/lib/tor/mynode_sphinx/
HiddenServiceVersion 3 HiddenServiceVersion 3
HiddenServicePort 53001 127.0.0.1:53001 HiddenServicePort 53001 127.0.0.1:53001
# Include tor settings for other apps
%include /etc/torrc.d/

View File

@ -33,6 +33,9 @@ fi
# Skip base upgrades if we are doing an app install / uninstall # Skip base upgrades if we are doing an app install / uninstall
if ! skip_base_upgrades ; then if ! skip_base_upgrades ; then
# Update SD card
mkdir -p /etc/torrc.d
# Create any necessary users # Create any necessary users
useradd -m -s /bin/bash joinmarket || true useradd -m -s /bin/bash joinmarket || true

View File

@ -72,6 +72,7 @@ mkdir -p /run/tor
mkdir -p /var/run/tor mkdir -p /var/run/tor
mkdir -p /home/bitcoin/.mynode/ mkdir -p /home/bitcoin/.mynode/
mkdir -p /home/admin/.bitcoin/ mkdir -p /home/admin/.bitcoin/
mkdir -p /etc/torrc.d
chown admin:admin /home/admin/.bitcoin/ chown admin:admin /home/admin/.bitcoin/
rm -rf /etc/motd # Remove simple motd for update-motd.d rm -rf /etc/motd # Remove simple motd for update-motd.d

View File

@ -497,6 +497,20 @@ def create_application_folders(app_data):
run_linux_cmd("chown -R {}:{} {}".format(app_data["linux_user"], app_data["linux_user"], app_folder)) run_linux_cmd("chown -R {}:{} {}".format(app_data["linux_user"], app_data["linux_user"], app_folder))
run_linux_cmd("chown -R {}:{} {}".format(app_data["linux_user"], app_data["linux_user"], data_folder)) run_linux_cmd("chown -R {}:{} {}".format(app_data["linux_user"], app_data["linux_user"], data_folder))
def create_application_tor_service(app_data):
run_linux_cmd("mkdir -p /etc/torrc.d")
torrc_file = "/etc/torrc.d/"+app_data["short_name"]
with open(torrc_file, "w") as f:
f.write("# Hidden Service for {}".format(app_data["short_name"]))
f.write("HiddenServiceDir /var/lib/tor/{}/".format(app_data["short_name"]))
f.write("HiddenServiceVersion 3")
if "http_port" in app_data and app_data["http_port"] != None:
f.write("HiddenServicePort 80 127.0.0.1:{}".format(app_data["http_port"]))
if "http_port" in app_data and app_data["http_port"] != None:
f.write("HiddenServicePort 443 127.0.0.1:{}".format(app_data["https_port"]))
if "extra_ports" in app_data and app_data["extra_ports"] != None:
for p in app_data["extra_ports"]:
f.write("HiddenServicePort {} 127.0.0.1:{}".format(p, p))
def install_application_tarball(app_data): def install_application_tarball(app_data):
log_message(" Running install_application_tarball...") log_message(" Running install_application_tarball...")
@ -522,9 +536,14 @@ def install_application_tarball(app_data):
run_linux_cmd("sudo -u {} tar -xvf /tmp/mynode_dynamic_app_download/app.tar.gz -C /tmp/mynode_dynamic_app_extract/".format(app_data["linux_user"])) run_linux_cmd("sudo -u {} tar -xvf /tmp/mynode_dynamic_app_download/app.tar.gz -C /tmp/mynode_dynamic_app_extract/".format(app_data["linux_user"]))
run_linux_cmd("mv /tmp/mynode_dynamic_app_extract/* /tmp/mynode_dynamic_app_extract/app") run_linux_cmd("mv /tmp/mynode_dynamic_app_extract/* /tmp/mynode_dynamic_app_extract/app")
# Move contents to app folder # Move tarball contents to app folder
run_linux_cmd("rsync -var --delete-after /tmp/mynode_dynamic_app_extract/app/* {}/".format(app_data["install_folder"])) run_linux_cmd("rsync -var --delete-after /tmp/mynode_dynamic_app_extract/app/* {}/".format(app_data["install_folder"]))
# Move app data to app folder
app_data_source = get_dynamic_app_dir() + "/" + app_data["short_name"] + "/app_data"
run_linux_cmd("rm -rf {}/app_data".format(app_data["install_folder"]))
run_linux_cmd("cp -r -f {} {}/app_data".format(app_data_source, app_data["install_folder"]))
def clear_installed_version(short_name): def clear_installed_version(short_name):
run_linux_cmd("rm -rf /home/bitcoin/.mynode/{}_version".format(short_name)) run_linux_cmd("rm -rf /home/bitcoin/.mynode/{}_version".format(short_name))
run_linux_cmd("rm -rf /mnt/hdd/mynode/settings/{}_version".format(short_name)) run_linux_cmd("rm -rf /mnt/hdd/mynode/settings/{}_version".format(short_name))
@ -592,9 +611,6 @@ def init_dynamic_app(app_info):
if (os.path.isfile(app_dir+"/nginx/https_"+app_name+".conf")): if (os.path.isfile(app_dir+"/nginx/https_"+app_name+".conf")):
os.system("cp -f {} {}".format(app_dir+"/nginx/https_"+app_name+".conf", "/etc/nginx/sites-enabled/https_"+app_name+".conf")) os.system("cp -f {} {}".format(app_dir+"/nginx/https_"+app_name+".conf", "/etc/nginx/sites-enabled/https_"+app_name+".conf"))
log_message(" TODO: Install data files???")
# For "node" type apps # For "node" type apps
log_message(" TODO: Need node special files???") log_message(" TODO: Need node special files???")
@ -606,7 +622,7 @@ def init_dynamic_app(app_info):
log_message(" TODO: Install dockerfile???") log_message(" TODO: Install dockerfile???")
# Setup tor hidden service # Setup tor hidden service
log_message(" TODO: Setup Tor Hidden service") create_application_tor_service(app_info)
log_message(" Done.") log_message(" Done.")

View File

@ -183,7 +183,6 @@
{% if not app.is_enabled %} {% if not app.is_enabled %}
{% set display = 0 %} {% set display = 0 %}
{% endif %} {% endif %}
{% if display %} {% if display %}
<div class="settings_block_subheader">{{app.name}} Status</div> <div class="settings_block_subheader">{{app.name}} Status</div>

View File

@ -122,6 +122,8 @@ TMP_INSTALL_PATH="/tmp/upgrade/out/rootfs_*"
# Source file containing app versions # Source file containing app versions
source /tmp/upgrade/out/rootfs_*/usr/share/mynode/mynode_app_versions.sh source /tmp/upgrade/out/rootfs_*/usr/share/mynode/mynode_app_versions.sh
# Update SD card
mkdir -p /etc/torrc.d
# Create any necessary users # Create any necessary users
useradd -m -s /bin/bash bitcoin || true useradd -m -s /bin/bash bitcoin || true