mirror of
https://github.com/YunoHost-Apps/synapse_ynh.git
synced 2024-09-03 20:26:38 +02:00
Add a script to upgrade coturn config easly
This commit is contained in:
parent
50099f786b
commit
f653a017bf
3 changed files with 67 additions and 0 deletions
|
@ -277,6 +277,16 @@ ynh_store_file_checksum "$coturn_config_path"
|
||||||
|
|
||||||
ynh_use_logrotate /var/log/matrix-$app
|
ynh_use_logrotate /var/log/matrix-$app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ADD SCRIPT FOR COTURN CRON
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# WARRNING : theses command are used in INSTALL, UPGRADE
|
||||||
|
# For any update do it in all files
|
||||||
|
|
||||||
|
cp ../sources/Coturn_config_rotate.sh $final_path/
|
||||||
|
ynh_replace_string __APP__ $app "$final_path/Coturn_config_rotate.sh"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -251,6 +251,16 @@ fi
|
||||||
|
|
||||||
ynh_store_file_checksum "$coturn_config_path"
|
ynh_store_file_checksum "$coturn_config_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ADD SCRIPT FOR COTURN CRON
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# WARRNING : theses command are used in INSTALL, UPGRADE
|
||||||
|
# For any update do it in all files
|
||||||
|
|
||||||
|
cp ../sources/Coturn_config_rotate.sh $final_path/
|
||||||
|
ynh_replace_string __APP__ $app "$final_path/Coturn_config_rotate.sh"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
47
sources/Coturn_config_rotate.sh
Normal file
47
sources/Coturn_config_rotate.sh
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
app_instance=__APP__
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
[ "$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")
|
||||||
|
except socket.error:
|
||||||
|
sys.exit(1)
|
||||||
|
sys.exit(0)
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
external_IP_line="external-ip=__IPV4__,__IPV6__"
|
||||||
|
|
||||||
|
public_ip4="$(curl ip.yunohost.org)" || true
|
||||||
|
public_ip6="$(curl ipv6.yunohost.org)" || true
|
||||||
|
|
||||||
|
if [[ -n "$public_ip4" ]] && ynh_validate_ip 4 "$public_ip4"
|
||||||
|
then
|
||||||
|
external_IP_line="${external_IP_line/'__IPV4__'/$public_ip4}"
|
||||||
|
else
|
||||||
|
external_IP_line="${external_IP_line/'__IPV4__,'/}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$public_ip6" ]] && ynh_valide_ip 6 "$public_ip6"
|
||||||
|
then
|
||||||
|
external_IP_line="${external_IP_line/'__IPV6__'/$public_ip6}"
|
||||||
|
else
|
||||||
|
external_IP_line="${external_IP_line/',__IPV6__'/}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sed --in-place "s@^external-ip=.*\$@$external_IP_line@g" "/etc/matrix-$app_instance/coturn.conf"
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Add table
Reference in a new issue