1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/duniter_ynh.git synced 2024-09-03 18:26:35 +02:00

[mod] #100: Define clearly ports variable names

Check ports are available locally
Sed port in the Nginx configuration template
This commit is contained in:
Moul 2022-05-05 18:41:42 +02:00
parent 656e78028d
commit 1e6983513a
5 changed files with 31 additions and 19 deletions

View file

@ -4,7 +4,7 @@ location / {
proxy_set_header Host $http_host; proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true; proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:9220; proxy_pass http://localhost:__WEB_ADMIN_PORT__;
proxy_redirect off; proxy_redirect off;
# Socket.io support # Socket.io support
@ -18,18 +18,18 @@ location / {
access_by_lua_file /usr/share/ssowat/access.lua; access_by_lua_file /usr/share/ssowat/access.lua;
location ~ \.(js|css|woff|woff2|ttf|png) { location ~ \.(js|css|woff|woff2|ttf|png) {
proxy_pass http://localhost:9220; proxy_pass http://localhost:__WEB_ADMIN_PORT__;
} }
location ~ /webmin { location ~ /webmin {
proxy_pass http://localhost:9220$uri; proxy_pass http://localhost:__WEB_ADMIN_PORT__$uri;
} }
location ~ ^/bma(.*)$ { location ~ ^/bma(.*)$ {
proxy_pass http://localhost:__PORT__$1$is_args$args; proxy_pass http://localhost:__BMA_LOCAL_PORT__$1$is_args$args;
} }
location /ws2p { location /ws2p {
proxy_pass http://localhost:20901; proxy_pass http://localhost:__WS2P_LOCAL_PORT__;
} }
} }

View file

@ -48,13 +48,19 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=admin --value=$admin
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AVAILABLE PORTS
#================================================= #=================================================
ynh_script_progression --message="Finding an available port…" ynh_script_progression --message="Finding available ports…"
# Find an available port # Find available ports
port=$(ynh_find_port --port=10901) bma_local_port=$(ynh_find_port --port=10901)
ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=bma_local_port --value=$bma_local_port
ws2p_local_port=$(ynh_find_port --port=20901)
ynh_app_setting_set --app=$app --key=ws2p_local_port --value=$ws2p_local_port
web_admin_port=$(ynh_find_port --port=9220)
ynh_app_setting_set --app=$app --key=web_admin_port --value=$web_admin_port
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -103,8 +109,8 @@ chown -R $app:www-data "$datadir"
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file…" ynh_script_progression --message="Adding a configuration file…"
ynh_exec_as duniter duniter config --bma --ipv4 127.0.0.1 --port $port --remoteh $domain --remotep 443 --noupnp ynh_exec_as duniter duniter config --bma --ipv4 127.0.0.1 --port $bma_local_port --remoteh $domain --remotep 443 --noupnp
ynh_exec_as duniter duniter config --ws2p-host 127.0.0.1 --ws2p-port 20901 --ws2p-remote-host $domain --ws2p-remote-port 443 --ws2p-remote-path "/ws2p" --ws2p-noupnp ynh_exec_as duniter duniter config --ws2p-host 127.0.0.1 --ws2p-port $ws2p_local_port --ws2p-remote-host $domain --ws2p-remote-port 443 --ws2p-remote-path "/ws2p" --ws2p-noupnp
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD

View file

@ -17,7 +17,6 @@ ynh_script_progression --message="Loading installation settings…"
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================

View file

@ -30,7 +30,8 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
port=$(ynh_app_setting_get --app=$app --key=port) bma_local_port=$(ynh_app_setting_get --app=$app --key=bma_local_port)
ws2p_local_port=$(ynh_app_setting_get --app=$app --key=ws2p_local_port)
architecture=$YNH_ARCH architecture=$YNH_ARCH
#================================================= #=================================================
@ -80,8 +81,8 @@ ynh_exec_warn_less dpkg -i $tempdir/duniter-server-v1.8.*-linux-*.deb
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file…" ynh_script_progression --message="Adding a configuration file…"
ynh_exec_as duniter duniter --home $datadir config --bma --ipv4 127.0.0.1 --port $port --remoteh $domain --remotep 443 --noupnp ynh_exec_as duniter duniter --home $datadir config --bma --ipv4 127.0.0.1 --port $bma_local_port --remoteh $domain --remotep 443 --noupnp
ynh_exec_as duniter duniter --home $datadir config --ws2p-host 127.0.0.1 --ws2p-port 20901 --ws2p-remote-host $domain --ws2p-remote-port 443 --ws2p-remote-path "/ws2p" --ws2p-noupnp ynh_exec_as duniter duniter --home $datadir config --ws2p-host 127.0.0.1 --ws2p-port $ws2p_local_port --ws2p-remote-host $domain --ws2p-remote-port 443 --ws2p-remote-path "/ws2p" --ws2p-noupnp
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD

View file

@ -20,9 +20,15 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin) admin=$(ynh_app_setting_get --app=$app --key=admin)
datadir=$(ynh_app_setting_get --app=$app --key=datadir) datadir=$(ynh_app_setting_get --app=$app --key=datadir)
port=$(ynh_app_setting_get --app=$app --key=port) bma_local_port=$(ynh_app_setting_get --app=$app --key=bma_local_port)
ws2p_local_port=$(ynh_app_setting_get --app=$app --key=ws2p_local_port)
webadmin_port=$(ynh_app_setting_get --app=$app --key=webadmin_port)
architecture=$YNH_ARCH architecture=$YNH_ARCH
# In case it wasnt defined by previous installation
bma_local_port=${bma_local_port:-10901}
ws2p_local_port=${ws2p_local_port:-20901}
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
@ -113,8 +119,8 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file…" ynh_script_progression --message="Updating a configuration file…"
ynh_exec_as duniter duniter config --bma --ipv4 127.0.0.1 --port $port --remoteh $domain --remotep 443 --noupnp ynh_exec_as duniter duniter config --bma --ipv4 127.0.0.1 --port $bma_local_port --remoteh $domain --remotep 443 --noupnp
ynh_exec_as duniter duniter config --ws2p-host 127.0.0.1 --ws2p-port 20901 --ws2p-remote-host $domain --ws2p-remote-port 443 --ws2p-remote-path "/ws2p" --ws2p-noupnp ynh_exec_as duniter duniter config --ws2p-host 127.0.0.1 --ws2p-port $ws2p_local_port --ws2p-remote-host $domain --ws2p-remote-port 443 --ws2p-remote-path "/ws2p" --ws2p-noupnp
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD