#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # INITIALIZE AND STORE SETTINGS #================================================= focus_user="focus" focus_password=$(ynh_string_random --length=8) ynh_app_setting_set --app="$app" --key=focus_user --value="$focus_user" ynh_app_setting_set --app="$app" --key=focus_password --value="$focus_password" videobridge_user="jvb" videobridge_secret=$(ynh_string_random --length=8) ynh_app_setting_set --app="$app" --key=videobridge_user --value="$videobridge_user" ynh_app_setting_set --app="$app" --key=videobridge_secret --value="$videobridge_secret" focus_secret=$(ynh_string_random --length=8) turn_secret=$(ynh_string_random --length=8) ynh_app_setting_set --app="$app" --key=focus_secret --value="$focus_secret" ynh_app_setting_set --app="$app" --key=turn_secret --value="$turn_secret" max_memory=200 #125 mib with no user +1,5*50 users=75 mib ynh_app_setting_set --app="$app" --key=max_memory --value="$max_memory" muc_nickname=$(uuidgen) ynh_app_setting_set --app="$app" --key=muc_nickname --value="$muc_nickname" #================================================= # CREATE DEDICATED USER #================================================= ynh_script_progression --message="Configuring system user..." --weight=1 gpasswd --add prosody "$app" gpasswd --add www-data "$app" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 _setup_sources chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R "$app:$app" "$install_dir" #================================================= # REPLACE JNIWRAPPER FOR ARMHF ARCHITECTURE IN JITSI-VIDEOBRIDGE #================================================= if [ "$YNH_ARCH" == "armhf" ]; then ynh_script_progression --message="Configuring jniwrapper for armhf ..." --weight=1 ynh_jniwrapper_armhf fi #================================================= # SPECIFIC SETUP #================================================= # CONFIGURE PROSODY #================================================= ynh_script_progression --message="Configuring prosody..." --weight=1 ynh_add_config --template="prosody.cfg.lua" --destination="/etc/prosody/conf.avail/$domain.cfg.lua" chmod 644 "/etc/prosody/conf.avail/$domain.cfg.lua" ln -s "/etc/prosody/conf.avail/$domain.cfg.lua" "/etc/prosody/conf.d/$domain.cfg.lua" prosodyctl cert generate "$domain" ln -sf "/var/lib/prosody/$domain.key" "/etc/prosody/certs/$domain.key" ln -sf "/var/lib/prosody/$domain.crt" "/etc/prosody/certs/$domain.crt" ln -sf "/var/lib/prosody/$domain.crt" "/usr/local/share/ca-certificates/$domain.crt" ynh_script_progression --message="Configuring prosody 2..." --weight=1 prosodyctl cert generate "auth.$domain" ln -sf "/var/lib/prosody/auth.$domain.key" "/etc/prosody/certs/auth.$domain.key" ln -sf "/var/lib/prosody/auth.$domain.crt" "/etc/prosody/certs/auth.$domain.crt" ln -sf "/var/lib/prosody/auth.$domain.crt" "/usr/local/share/ca-certificates/auth.$domain.crt" ynh_script_progression --message="Updating ca-certificates..." --weight=1 update-ca-certificates -f ynh_script_progression --message="Restarting prosody..." --weight=1 ynh_systemd_action --service_name="prosody" --action="restart" ynh_script_progression --message="prosodyctl register..." --weight=1 prosodyctl register "$focus_user" "auth.$domain" "$focus_password" ynh_script_progression --message="prosodyctl register..." --weight=1 prosodyctl register "$videobridge_user" "auth.$domain" "$videobridge_secret" ynh_script_progression --message="prosodyctl mod_roster_command..." --weight=1 prosodyctl mod_roster_command subscribe "$focus_user.$domain" "$focus_user@auth.$domain" #================================================= # CONFIGURE JITSI-VIDEOBRIDGE #================================================= ynh_script_progression --message="Configuring Jitsi-Videobridge..." --weight=1 public_ipv4="$(curl ip.yunohost.org)" || true private_ipv4="$(ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$/\1/p')" || true mkdir -p "/etc/$app/videobridge" ynh_add_config --template="jitsi-videobridge-callstats-java-sdk.properties" --destination="/etc/$app/videobridge/callstats-java-sdk.properties" ynh_add_config --template="jitsi-videobridge-jvb.conf" --destination="/etc/$app/videobridge/jvb.conf" ynh_add_config --template="jitsi-videobridge-logging.properties" --destination="/etc/$app/videobridge/logging.properties" ynh_add_config --template="jitsi-videobridge-sip-communicator.properties" --destination="/etc/$app/videobridge/sip-communicator.properties" ynh_add_config --template="jitsi-videobridge.config" --destination="/etc/$app/videobridge/config" #================================================= # CONFIGURE JITSI-JICOFO #================================================= ynh_script_progression --message="Configuring Jitsi-Jicofo..." --weight=1 mkdir -p "/etc/$app/jicofo" ynh_add_config --template="jitsi-jicofo-config" --destination="/etc/$app/jicofo/config" ynh_add_config --template="jitsi-jicofo-jicofo.conf" --destination="/etc/$app/jicofo/jicofo.conf" ynh_add_config --template="jitsi-jicofo-logging.properties" --destination="/etc/$app/jicofo/logging.properties" #================================================= # CONFIGURE JITSI-MEET #================================================= ynh_script_progression --message="Configuring Jitsi-Meet..." --weight=1 mkdir -p "/etc/$app/meet" ynh_add_config --template="jitsi-meet-config.js" --destination="/etc/$app/meet/$domain-config.js" chmod 644 "/etc/$app/meet/$domain-config.js" #================================================= # SECURE FILES AND DIRECTORIES #================================================= ynh_script_progression --message="Securing files and directories..." --weight=1 # Set permissions to app files chown -R "$app:" "/etc/$app" #================================================= # SYSTEM CONFIGURATION #================================================= ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config --service="$app-videobridge" --template="jitsi-videobridge.service" yunohost service add "$app-videobridge" --log "/var/log/$app/$app-videobridge.log" --needs_exposed_ports "$port" "$port_videobridge" ynh_add_systemd_config --service="$app-jicofo" --template="jitsi-jicofo.service" yunohost service add "$app-jicofo" --log "/var/log/$app/$app-jicofo.log" # Use logrotate to manage application logfile(s) ynh_use_logrotate chown -R "$app:" "/var/log/$app" chmod -R 770 "/var/log/$app" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service ynh_systemd_action --service_name="$app-jicofo" --action="start" --log_path="/var/log/$app/$app-jicofo.log" ynh_systemd_action --service_name="$app-videobridge" --action="start" --log_path="/var/log/$app/$app-videobridge.log" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Installation of $app completed" --last