From e1065d80a8dbf3f285e1a26dea7cd0e3cf655060 Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Thu, 5 Jul 2018 21:46:24 +0200 Subject: [PATCH] Typos and misc fixes --- README.md | 8 ++++---- scripts/install | 16 ++++++++-------- scripts/restore | 10 +++++----- scripts/upgrade | 18 +++++++++--------- sources/Coturn_config_rotate.sh | 17 +++++++++++------ 5 files changed, 37 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 8f1956d..f86d917 100644 --- a/README.md +++ b/README.md @@ -57,9 +57,9 @@ yunohost app setting synapse turnserver_tls_port yunohost app setting synapse turnserver_alt_tls_port ``` -The turnserver will also chose a port dynamicly when a new call start. The is between 49153 - 49193. +The turnserver will also choose a port dynamically when a new call starts. The range is between 49153 - 49193. -For some security reason the ports range (49153 - 49193) isn't automatically open by default. If you want to use the synapse server for voip or conferencing you will need to open this port range manually. To do this just run this command : +For some security reason the ports range (49153 - 49193) isn't automatically open by default. If you want to use the synapse server for voip or conferencing you will need to open this port range manually. To do this just run this command: ``` yunohost firewall allow Both 49153:49193 @@ -67,9 +67,9 @@ yunohost firewall allow Both 49153:49193 You might also need to open these ports (if it is not automatically done) on your ISP box. -To prevent the situation when the server is behind a NAT, the public IP is written in the turnserver config. By this the turnserver can send his real public IP to the client. For more information see [the coturn example config file](https://github.com/coturn/coturn/blob/master/examples/etc/turnserver.conf#L102-L120). So if your IP change you could run the script `/opt/yunohost/__SYNAPSE_INSTANCE_NAME__/Coturn_config_rotate.sh` to update your config. +To prevent the situation when the server is behind a NAT, the public IP is written in the turnserver config. By this the turnserver can send its real public IP to the client. For more information see [the coturn example config file](https://github.com/coturn/coturn/blob/master/examples/etc/turnserver.conf#L102-L120).So if your IP changes, you could run the script `/opt/yunohost/__SYNAPSE_INSTANCE_NAME__/Coturn_config_rotate.sh` to update your config. -If you have a dynamic ip adresse you also might need to update this config automatically. To do that just edit a file named : `/etc/cron.d/coturn_config_rotate` and add the fooling contenant (just adapt the __SYNAPSE_INSTANCE_NAME__ which could be `synapse` or mybe `synapse__1`). +If you have a dynamic IP address, you also might need to update this config automatically. To do that just edit a file named `/etc/cron.d/coturn_config_rotate` and add the following content (just adapt the __SYNAPSE_INSTANCE_NAME__ which could be `synapse` or maybe `synapse__2`). ``` */15 * * * * root bash /opt/yunohost/__SYNAPSE_INSTANCE_NAME__/Coturn_config_rotate.sh; diff --git a/scripts/install b/scripts/install index 37a798a..f03c4cc 100644 --- a/scripts/install +++ b/scripts/install @@ -151,27 +151,27 @@ else PS1="" cp ../conf/virtualenv_activate $final_path/bin/activate ynh_replace_string __FINAL_PATH__ $final_path $final_path/bin/activate - - # We set all necessary environement variable to create a python virtualenvironnement. + + # We set all necessary environement variable to create a python virtualenvironnement. source $final_path/bin/activate pip install --upgrade pip pip install --upgrade setuptools pip install --upgrade cffi ndg-httpsclient psycopg2 lxml - + # Download and check the checksum for the synapse source src_url=$(grep 'SOURCE_URL=' "$YNH_CWD/../conf/python_source.src" | cut -d= -f2-) src_sum=$(grep 'SOURCE_SUM=' "$YNH_CWD/../conf/python_source.src" | cut -d= -f2-) - + wget -nv -O synapse_source.tar.gz "$src_url" echo "${src_sum} synapse_source.tar.gz" | sha256sum -c --status \ || ynh_die "Corrupt source" pip install --upgrade synapse_source.tar.gz - + # Fix issue with msgpack see https://github.com/YunoHost-Apps/synapse_ynh/issues/29 test -e $final_path/lib/python2.7/site-packages/msgpack/__init__.py || (\ pip uninstall -y msgpack-python msgpack; \ pip install msgpack-python) - + # This fonction was defined while we call "source $final_path/bin/activate". By this fonction de undo what does "$final_path/bin/activate" deactivate fi @@ -262,7 +262,7 @@ else ynh_replace_string '__IPV4__,' "" "$coturn_config_path" fi -if [[ -n "$public_ip6" ]] && ynh_valide_ip6 "$public_ip6" +if [[ -n "$public_ip6" ]] && ynh_validate_ip6 "$public_ip6" then ynh_replace_string '__IPV6__' "$public_ip6" "$coturn_config_path" else @@ -341,7 +341,7 @@ _matrix._tcp.$domain. 3600 IN SRV 10 0 $synapse_tls_port $domain. You also need to open the TCP port $synapse_tls_port on your ISP box if it's not automatically done. -Your synapse server also implements a turnserver (for VoIP), to have this fully functional server it's recommended to read the 'Turnserver' section in the README available here : https://github.com/YunoHost-Apps/synapse_ynh . +Your synapse server also implements a turnserver (for VoIP), to have this fully functional please read the 'Turnserver' section in the README available here: https://github.com/YunoHost-Apps/synapse_ynh . If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/synapse_ynh" diff --git a/scripts/restore b/scripts/restore index 98a0890..2f907a8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -74,15 +74,15 @@ adduser turnserver ssl-cert # RECONFIGURE THE TURNSERVER #================================================= -# To be sure that a the restoration the IP adress in coturn config is same than the real adress we remake the coturn config +# To be sure that at the restoration the IP address in coturn config is the same as the real address we remake the coturn config -# Retrive specific settings +# Retrieve specific settings turnserver_tls_port=$(ynh_app_setting_get $app turnserver_tls_port) turnserver_alt_tls_port=$(ynh_app_setting_get $app turnserver_alt_tls_port) turnserver_pwd=$(ynh_app_setting_get $app turnserver_pwd) cli_port=$(ynh_app_setting_get $app cli_port) -# WARRNING : theses command are used in INSTALL, UPGRADE +# WARNING : these commands are used in INSTALL, UPGRADE # For any update do it in all files coturn_config_path="/etc/matrix-$app/coturn.conf" @@ -170,7 +170,7 @@ ynh_use_logrotate /var/log/matrix-$app # SECURE FILES AND DIRECTORIES #================================================= -# WARRNING : theses command are used in INSTALL, UPGRADE, RESTORE +# WARNING : these commands are used in INSTALL, UPGRADE, RESTORE # For any update do it in all files chown $synapse_user:root -R $final_path chown $synapse_user:root -R /var/lib/matrix-$app @@ -209,7 +209,7 @@ _matrix._tcp.$domain. 3600 IN SRV 10 0 $synapse_tls_port $domain. You also need to open the TCP port $synapse_tls_port on your ISP box if it's not automatically done. -Your synapse server also implements a turnserver (for VoIP), to have this fully functional server it's recommended to read the 'Turnserver' section in the README available here : https://github.com/YunoHost-Apps/synapse_ynh . +Your synapse server also implements a turnserver (for VoIP), to have this fully functional please read the 'Turnserver' section in the README available here: https://github.com/YunoHost-Apps/synapse_ynh . If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/synapse_ynh" diff --git a/scripts/upgrade b/scripts/upgrade index 8d0225d..f50285d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -77,7 +77,7 @@ fi # Install/upgrade synapse in virtualenv -# WARRNING : theses command are used in INSTALL, UPGRADE +# WARNING : these commands are used in INSTALL, UPGRADE # For any update do it in all files if [ -n "$(uname -m | grep arm)" ] @@ -91,26 +91,26 @@ else PS1="" cp ../conf/virtualenv_activate $final_path/bin/activate ynh_replace_string __FINAL_PATH__ $final_path $final_path/bin/activate - - # We set all necessary environement variable to create a python virtualenvironnement. + + # We set all necessary environement variable to create a python virtualenvironnement. source $final_path/bin/activate pip install --upgrade setuptools pip install --upgrade cffi ndg-httpsclient psycopg2 lxml - + # Download and check the checksum for the synapse source src_url=$(grep 'SOURCE_URL=' "$YNH_CWD/../conf/python_source.src" | cut -d= -f2-) src_sum=$(grep 'SOURCE_SUM=' "$YNH_CWD/../conf/python_source.src" | cut -d= -f2-) - + wget -nv -O synapse_source.tar.gz "$src_url" echo "${src_sum} synapse_source.tar.gz" | sha256sum -c --status \ || ynh_die "Corrupt source" pip install --upgrade synapse_source.tar.gz - + # Fix issue with msgpack see https://github.com/YunoHost-Apps/synapse_ynh/issues/29 test -e $final_path/lib/python2.7/site-packages/msgpack/__init__.py || (\ pip uninstall -y msgpack-python msgpack; \ pip install msgpack-python) - + # This fonction was defined while we call "source $final_path/bin/activate". By this fonction de undo what does "$final_path/bin/activate" deactivate fi @@ -172,7 +172,7 @@ then ynh_app_setting_set $app turnserver_alt_tls_port $turnserver_alt_tls_port ynh_app_setting_set $app cli_port $cli_port - + yunohost firewall allow Both $turnserver_alt_tls_port > /dev/null 2>&1 # Configure systemd @@ -242,7 +242,7 @@ else ynh_replace_string '__IPV4__,' "" "$coturn_config_path" fi -if [[ -n "$public_ip6" ]] && ynh_valide_ip6 "$public_ip6" +if [[ -n "$public_ip6" ]] && ynh_validate_ip6 "$public_ip6" then ynh_replace_string '__IPV6__' "$public_ip6" "$coturn_config_path" else diff --git a/sources/Coturn_config_rotate.sh b/sources/Coturn_config_rotate.sh index 6cf0aa4..453011d 100644 --- a/sources/Coturn_config_rotate.sh +++ b/sources/Coturn_config_rotate.sh @@ -2,21 +2,26 @@ app_instance=__APP__ +# Validate an IP address syntax +# +# usage: ynh_validate_ip ip_address_family ip_address +# | arg: ip_address_family - either 4 (for IPv4) or 6 (for IPv6) +# | arg: ip_address - IP address to validate ynh_validate_ip() { # http://stackoverflow.com/questions/319279/how-to-validate-ip-address-in-python#319298 - local IP_ADDRESS_FAMILY=$1 - local IP_ADDRESS=$2 + local ip_address_family=$1 + local ip_address=$2 - [ "$IP_ADDRESS_FAMILY" == "4" ] || [ "$IP_ADDRESS_FAMILY" == "6" ] || return 1 + [ "$ip_address_family" == "4" ] || [ "$ip_address_family" == "6" ] || return 1 python /dev/stdin << EOF import socket import sys family = { "4" : socket.AF_INET, "6" : socket.AF_INET6 } try: - socket.inet_pton(family["$IP_ADDRESS_FAMILY"], "$IP_ADDRESS") + socket.inet_pton(family["$ip_address_family"], "$ip_address") except socket.error: sys.exit(1) sys.exit(0) @@ -35,7 +40,7 @@ else external_IP_line="${external_IP_line/'__IPV4__,'/}" fi -if [[ -n "$public_ip6" ]] && ynh_valide_ip 6 "$public_ip6" +if [[ -n "$public_ip6" ]] && ynh_validate_ip 6 "$public_ip6" then external_IP_line="${external_IP_line/'__IPV6__'/$public_ip6}" else @@ -44,4 +49,4 @@ fi sed --in-place "s@^external-ip=.*\$@$external_IP_line@g" "/etc/matrix-$app_instance/coturn.conf" -exit 0 \ No newline at end of file +exit 0