mirror of
https://github.com/YunoHost-Apps/coturn_ynh.git
synced 2024-09-03 18:16:32 +02:00
88 lines
3.1 KiB
Bash
88 lines
3.1 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source ../settings/scripts/_common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# RESTORE COTURN CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring Coturn configuration..." --weight=1
|
|
|
|
ynh_restore_file --origin_path="/etc/turnserver.conf"
|
|
|
|
#=================================================
|
|
# RESTORE THE COTURN DATAPATH
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring the data directory..." --weight=1
|
|
|
|
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
|
|
|
# (Same as for install dir)
|
|
chown -R $app:www-data "$data_dir"
|
|
|
|
#=================================================
|
|
# RESTORE LOG
|
|
#=================================================
|
|
|
|
ynh_restore_file --origin_path="/var/log/$app"
|
|
|
|
#=================================================
|
|
# RECREATE THE DEDICATED USER
|
|
#=================================================
|
|
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
|
|
|
|
# Create the dedicated user (if not existing)
|
|
adduser turnserver ssl-cert
|
|
|
|
#=================================================
|
|
# RECREATE A DH FILE
|
|
#=================================================
|
|
ynh_script_progression --message="Creating a dhparam file..." --weight=3
|
|
|
|
# Make dhparam cert for Coturn if it doesn't exist
|
|
if [ ! -e /etc/ssl/private/dh2048.pem ]
|
|
then
|
|
ynh_exec_warn_less openssl dhparam -out /etc/ssl/private/dh2048.pem -outform PEM -dsaparam 2048
|
|
chown root:ssl-cert /etc/ssl/private/dh2048.pem
|
|
chmod 640 /etc/ssl/private/dh2048.pem
|
|
fi
|
|
|
|
#=================================================
|
|
# RESTORE USER RIGHTS
|
|
#=================================================
|
|
|
|
# Restore permissions on app files
|
|
# Set permissions to app files
|
|
chown root: -R /home/yunohost.app/$app
|
|
chown -R turnserver:root /var/log/$app
|
|
chown turnserver:root /etc/turnserver.conf
|
|
setfacl -R -m user:turnserver:rwX /var/log/$app
|
|
|
|
#=================================================
|
|
# RESTORE SYSTEMD
|
|
#=================================================
|
|
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
|
|
|
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
|
systemctl enable $app.service --quiet
|
|
|
|
yunohost service add $app --description="Coturn TURN server" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_turnserver_tls"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|