mirror of
https://github.com/YunoHost-Apps/coturn_ynh.git
synced 2024-09-03 18:16:32 +02:00
Add cron
This commit is contained in:
parent
8263d64ec7
commit
e81269e2ed
6 changed files with 70 additions and 4 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>
|
||||||
```
|
```
|
||||||
|
|
3
conf/cron_coturn
Normal file
3
conf/cron_coturn
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Check if the IP as not changed at every 15th minute
|
||||||
|
# */15 * * * * root bash /__SCRIPT_PATH__/Coturn_config_rotate.sh;
|
||||||
|
*/15 * * * * __USER__ bash /__SCRIPT_PATH__/Coturn_config_rotate.sh;
|
|
@ -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"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,6 +146,27 @@ 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
|
||||||
|
script_path=/opt/yunohost/coturn
|
||||||
|
ynh_app_setting_set --app=$app --key=script_path --value=$script_path
|
||||||
|
mkdir $script_path
|
||||||
|
cp ../sources/Coturn_config_rotate.sh $script_path/Coturn_config_rotate.sh
|
||||||
|
chmod +x $script_path/Coturn_config_rotate.sh
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SET COTURN CRON
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
cp ../conf/cron_coturn /etc/cron.d/$app
|
||||||
|
ynh_replace_string --match_string="__USER__" --replace_string=turnserver --target_file=/etc/cron.d/$app
|
||||||
|
ynh_replace_string --match_string="__SCRIPT_PATH__" --replace_string=$script_path --target_file=/etc/cron.d/$app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -22,6 +22,7 @@ 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_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$db_name
|
db_user=$db_name
|
||||||
|
script_path=$(ynh_app_setting_get --app=$app --key=script_path)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# STANDARD REMOVE
|
||||||
|
@ -42,7 +43,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
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -71,6 +71,19 @@ 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=$script_path
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE CRON JOB
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_secure_remove --file="/etc/cron.d/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CLOSE A PORT
|
# CLOSE A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
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 coturn.service
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Add table
Reference in a new issue