This repository has been archived by the owner on Jun 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change how portforwarding starts for dapps
- Loading branch information
Laszlo Megyer
committed
Mar 13, 2019
1 parent
36024ae
commit a5b17ad
Showing
5 changed files
with
65 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,14 @@ RDEPENDS_${PN} = " \ | |
python3-fusepy \ | ||
python3-modules \ | ||
python3-misc \ | ||
jq \ | ||
" | ||
|
||
# TODO: move dapp_prepare.sh logic inside systemd | ||
SRC_URI += "file://apps.json \ | ||
file://dapp_prepare.sh \ | ||
file://dapp_register.sh \ | ||
file://dapp_forward_ports.sh \ | ||
file://dapp_pull.sh \ | ||
file://dapp_load.sh \ | ||
file://dapp_version.sh \ | ||
|
@@ -24,15 +26,12 @@ SRC_URI += "file://apps.json \ | |
|
||
inherit systemd | ||
|
||
# TODO: how exactly do we ship nginx? | ||
# Drop-in directory for JSON maybe | ||
FILES_${PN} = "${systemd_unitdir}/system/[email protected] /opt/titania/* ${sysconfdir}/systemd/* /opt/titania/" | ||
|
||
# Systemd recipe doesn't know how to parse things with multiple dots | ||
# openembedded-core `master` branch has the correct code. | ||
# They get replaced in a ROOTFS_POSTPROCESS command (see rpi-titania-image) | ||
# TODO: Either backport or upgrade branch (painful!), remove this hack | ||
# TODO: make latter a .target, use ExecStartPost etc. | ||
SYSTEMD_SERVICE_${PN} = "dapp@world,libertaria,nginx.service \ | ||
dapp-systemd-bridge.service \ | ||
dapp-json-merge.service" | ||
|
56 changes: 56 additions & 0 deletions
56
meta-titania/recipes-titania/dapp/files/dapp_forward_ports.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash | ||
# Open up ports on the router via natpmp for the public ports | ||
|
||
if [[ $1 != "start" && $1 != "stop" ]] | ||
then | ||
echo "Usage: $0 [start|stop] <dapp_name>" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z $2 ]] | ||
then | ||
echo "dapp name must be specified" | ||
exit 1 | ||
fi | ||
|
||
ACTION=$1 | ||
DAPP_ID=$2 | ||
|
||
function public_ports() | ||
{ | ||
local DAPP_ID_=$1 | ||
local PROTOCOL=$2 | ||
|
||
jq ".[] | select(.id == \"$DAPP_ID_\") | .ports | .[] | select(.type == \"public\") | select(.protocol == \"$PROTOCOL\") | .port" /run/apps.json | ||
} | ||
|
||
case $ACTION in | ||
start) | ||
echo "Setting up portforwarding via natpmp for public ports." | ||
for typ in tcp udp | ||
do | ||
for port in $(public_ports $DAPP_ID $typ) | ||
do | ||
echo Setting up $typ portforward on port $port | ||
systemctl start forward-port@${port}-${typ}.service || true # service fails if natpmp is not enabled on router | ||
done | ||
done | ||
;; | ||
|
||
stop) | ||
echo "Removing natpmp portforwards" | ||
for typ in tcp udp | ||
do | ||
for port in $(public_ports $DAPP_ID $typ) | ||
do | ||
echo Removing $typ portforward from port $port | ||
systemctl stop forward-port@${port}-${typ}.service || true # service fails if natpmp is not enabled on router | ||
done | ||
done | ||
;; | ||
|
||
*) | ||
echo "start/stop command must be specified" | ||
exit 1 | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters