mirror of
https://github.com/YunoHost-Apps/coturn_ynh.git
synced 2024-09-03 18:16:32 +02:00
commit
12bebea2ab
7 changed files with 80 additions and 21 deletions
|
@ -24,7 +24,7 @@ How to configure this app: a plain file with SSH.
|
||||||
|
|
||||||
For testing we can use Trickle-Ice testing tool. Go to [trickle-ice page](https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice) and enter following details.
|
For testing we can use Trickle-Ice testing tool. Go to [trickle-ice page](https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice) and enter following details.
|
||||||
```
|
```
|
||||||
STUN or TURN URI : turn:<YOUR_PUBLIC_IP_ADDRESS>:5349
|
TURN URI : turn:<YOUR_PUBLIC_IP_ADDRESS>:5349
|
||||||
TURN username: <YOUR_USERNAME>
|
TURN username: <YOUR_USERNAME>
|
||||||
TURN password: <YOUR_PASSWORD>
|
TURN password: <YOUR_PASSWORD>
|
||||||
```
|
```
|
||||||
|
|
2
conf/cron_coturn
Normal file
2
conf/cron_coturn
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# Check if the IP as not changed at every 15th minute
|
||||||
|
*/15 * * * * root bash /__DATA_PATH__/Coturn_config_rotate.sh;
|
|
@ -8,7 +8,7 @@
|
||||||
},
|
},
|
||||||
"version": "4.5.1.1~ynh1",
|
"version": "4.5.1.1~ynh1",
|
||||||
"url": "https://github.com/coturn/coturn",
|
"url": "https://github.com/coturn/coturn",
|
||||||
"license": "MIT",
|
"license": "",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": "",
|
"name": "",
|
||||||
"email": ""
|
"email": ""
|
||||||
|
|
|
@ -15,7 +15,6 @@ pkg_dependencies="sqlite3 libsqlite3-dev coturn acl"
|
||||||
# EXPERIMENTAL HELPERS
|
# EXPERIMENTAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
|
||||||
# Send an email to inform the administrator
|
# Send an email to inform the administrator
|
||||||
#
|
#
|
||||||
# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type]
|
# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type]
|
||||||
|
@ -152,4 +151,3 @@ __PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/service
|
||||||
# Send the email to the recipients
|
# Send the email to the recipients
|
||||||
cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients"
|
cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ ynh_abort_if_errors
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url="/"
|
path_url="/"
|
||||||
#admin=$YNH_APP_ARG_ADMIN
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -36,7 +35,7 @@ ynh_script_progression --message="Storing installation settings..." --weight=4
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
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=no_sso --value true
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A DH FILE
|
# CREATE A DH FILE
|
||||||
|
@ -146,12 +145,30 @@ fi
|
||||||
|
|
||||||
ynh_store_file_checksum --file="$coturn_config_path"
|
ynh_store_file_checksum --file="$coturn_config_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ADD SCRIPT FOR COTURN CRON
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# WARNING : theses command are used in INSTALL, UPGRADE
|
||||||
|
# For any update do it in all files
|
||||||
|
data_path="/home/yunohost.app/$app"
|
||||||
|
mkdir -p $data_path
|
||||||
|
cp -f ../sources/Coturn_config_rotate.sh $data_path/
|
||||||
|
chmod +x $data_path/Coturn_config_rotate.sh
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SET COTURN CRON
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
cp -f ../conf/cron_coturn /etc/cron.d/$app
|
||||||
|
ynh_replace_string --match_string="__DATA_PATH__" --replace_string=$data_path --target_file=/etc/cron.d/$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring log rotation..." --weight=1
|
ynh_script_progression --message="Configuring log rotation..." --weight=1
|
||||||
|
|
||||||
ynh_use_logrotate
|
ynh_use_logrotate --logfile "/var/log/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
|
@ -160,11 +177,9 @@ ynh_use_logrotate
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
#chown -R root /var/log/$app
|
chown root: -R $data_path
|
||||||
#hown -R root /etc/$app
|
chown -R turnserver:root /var/log/$app
|
||||||
#chmod -R u=rwX,g=rX,o= /etc/$app
|
setfacl -R -m user:turnserver:rwX /var/log/$app
|
||||||
#setfacl -R -m user:turnserver:rX /etc/$app
|
|
||||||
#setfacl -R -m user:turnserver:rwX /var/log/$app
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
|
|
|
@ -17,11 +17,8 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
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)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
||||||
turnserver_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_tls_port)
|
turnserver_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_tls_port)
|
||||||
turnserver_alt_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_alt_tls_port)
|
turnserver_alt_tls_port=$(ynh_app_setting_get --app=$app --key=turnserver_alt_tls_port)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
||||||
db_user=$db_name
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
|
@ -42,7 +39,6 @@ fi
|
||||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
||||||
|
|
||||||
# Remove the dedicated systemd config
|
# Remove the dedicated systemd config
|
||||||
#ynh_remove_systemd_config
|
|
||||||
ynh_remove_systemd_config
|
ynh_remove_systemd_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -56,11 +52,9 @@ ynh_remove_app_dependencies
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing Coturn main directory..." --weight=2
|
ynh_script_progression --message="Removing Coturn configuration file..." --weight=2
|
||||||
|
|
||||||
ynh_secure_remove --file=/var/log/$app
|
ynh_secure_remove --file="/etc/turnserver.conf"
|
||||||
|
|
||||||
ynh_secure_remove --file=/etc/turnserver.conf
|
|
||||||
mv /etc/turnserver.conf.orig /etc/turnserver.conf
|
mv /etc/turnserver.conf.orig /etc/turnserver.conf
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -71,6 +65,25 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight=
|
||||||
# Remove the app-specific logrotate config
|
# Remove the app-specific logrotate config
|
||||||
ynh_remove_logrotate
|
ynh_remove_logrotate
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Remove coturn/Coturn_config_rotate.sh
|
||||||
|
ynh_secure_remove --file="/home/yunohost.app/$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE CRON JOB
|
||||||
|
#=================================================
|
||||||
|
# Remove a cron file
|
||||||
|
ynh_secure_remove --file="/etc/cron.d/$app"
|
||||||
|
|
||||||
|
# Remove the log files
|
||||||
|
ynh_secure_remove --file="/var/log/$app/"
|
||||||
|
|
||||||
|
# Remove the sqlitedb file
|
||||||
|
ynh_secure_remove --file="/var/lib/turn/"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CLOSE A PORT
|
# CLOSE A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -96,7 +109,7 @@ closeport() {
|
||||||
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
|
||||||
|
|
||||||
# Delete a system user
|
# Delete a system user
|
||||||
deluser turnserver ssl-cert
|
ynh_system_user_delete --username=turnserver
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
|
|
31
sources/Coturn_config_rotate.sh
Normal file
31
sources/Coturn_config_rotate.sh
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
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_ip4 --ip_address="$public_ip4"
|
||||||
|
then
|
||||||
|
echo "external-ip=$public_ip4" >> "$coturn_config_path"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$public_ip6" ] && ynh_validate_ip6 --ip_address="$public_ip6"
|
||||||
|
then
|
||||||
|
echo "external-ip=$public_ip6" >> "$coturn_config_path"
|
||||||
|
fi
|
||||||
|
|
||||||
|
old_config_line=$(egrep "^external-ip=.*\$" "/etc/turnserver.conf")
|
||||||
|
ynh_replace_string "^external-ip=.*\$" "$external_IP_line" "/etc/turnserver.conf"
|
||||||
|
new_config_line=$(egrep "^external-ip=.*\$" "/etc/turnserver.conf")
|
||||||
|
|
||||||
|
#setfacl -R -m user:turnserver:rX /etc/$app_instance
|
||||||
|
|
||||||
|
if [ "$old_config_line" != "$new_config_line" ]
|
||||||
|
then
|
||||||
|
systemctl restart $app.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Add table
Reference in a new issue