1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/movim_ynh.git synced 2024-09-03 19:46:19 +02:00

Disable the need of port, add automatic attribution

This commit is contained in:
Jean-Baptiste Holcroft 2018-08-10 17:06:29 +02:00
parent 7178bba198
commit 5836e86f8e
3 changed files with 19 additions and 13 deletions

View file

@ -79,14 +79,6 @@
}, },
"choices": ["Yes", "No"], "choices": ["Yes", "No"],
"default": "Yes" "default": "Yes"
},
{
"name": "port",
"ask": {
"en": "Movim daemon port (internal only)",
"fr": "Port du daemon Movim (interne uniquement)"
},
"default": "9537"
} }
] ]
} }

View file

@ -26,7 +26,6 @@ admin=$YNH_APP_ARG_ADMIN
password=$YNH_APP_ARG_PASSWORD password=$YNH_APP_ARG_PASSWORD
language=$YNH_APP_ARG_LANGUAGE language=$YNH_APP_ARG_LANGUAGE
ssoenabled=$YNH_APP_ARG_SSOENABLED ssoenabled=$YNH_APP_ARG_SSOENABLED
port=$YNH_APP_ARG_PORT
timezone=$(cat /etc/timezone) timezone=$(cat /etc/timezone)
### If it's a multi-instance app, meaning it can be installed several times independently ### If it's a multi-instance app, meaning it can be installed several times independently
@ -56,9 +55,6 @@ ynh_webpath_available $domain $path_url
# Register (book) web path # Register (book) web path
ynh_webpath_register $app $domain $path_url ynh_webpath_register $app $domain $path_url
# Check port availability
yunohost app checkport "$port" \
|| ynh_die "This port is already used"
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
@ -67,13 +63,20 @@ yunohost app checkport "$port" \
# Save app settings # Save app settings
ynh_app_setting_set "$app" admin "$admin" ynh_app_setting_set "$app" admin "$admin"
ynh_app_setting_set "$app" ssoenabled "$ssoenabled" ynh_app_setting_set "$app" ssoenabled "$ssoenabled"
ynh_app_setting_set "$app" port "$port"
ynh_app_setting_set "$app" path "$path_url" ynh_app_setting_set "$app" path "$path_url"
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
# FIND AND OPEN A PORT
#=================================================
# Find a free port
port=$(ynh_find_port 9537)
# Open this port
yunohost firewall allow --no-upnp TCP "$port" 2>&1
ynh_app_setting_set "$app" port "$port"
#================================================= #=================================================
# CREATE A MYSQL DATABASE # CREATE A MYSQL DATABASE

View file

@ -18,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME
# Retrieve app settings # Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain) domain=$(ynh_app_setting_get "$app" domain)
final_path=$(ynh_app_setting_get "$app" final_path) final_path=$(ynh_app_setting_get "$app" final_path)
port=$(ynh_app_setting_get "$app" port)
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
@ -69,6 +70,16 @@ ynh_mysql_drop_user "$db_user" || true
ynh_secure_remove "$final_path" ynh_secure_remove "$final_path"
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- $port$"
then
echo "Close port $port" >&2
yunohost firewall disallow TCP $port 2>&1
fi
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================