1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jitsi_ynh.git synced 2024-09-03 19:35:57 +02:00
jitsi_ynh/scripts/install

174 lines
7.1 KiB
Text
Raw Normal View History

2019-06-06 06:04:22 +02:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
2024-01-18 16:39:14 +01:00
# INITIALIZE AND STORE SETTINGS
2019-06-06 06:04:22 +02:00
#=================================================
2024-01-18 16:39:14 +01:00
focus_user="focus"
2019-06-06 06:04:22 +02:00
focus_password=$(ynh_string_random --length=8)
2024-01-18 16:39:14 +01:00
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"
2019-06-06 06:04:22 +02:00
videobridge_secret=$(ynh_string_random --length=8)
2024-01-18 16:39:14 +01:00
ynh_app_setting_set --app="$app" --key=videobridge_user --value="$videobridge_user"
ynh_app_setting_set --app="$app" --key=videobridge_secret --value="$videobridge_secret"
2019-06-06 06:04:22 +02:00
2024-01-18 16:39:14 +01:00
focus_secret=$(ynh_string_random --length=8)
turn_secret=$(ynh_string_random --length=8)
2024-01-18 16:39:14 +01:00
ynh_app_setting_set --app="$app" --key=focus_secret --value="$focus_secret"
ynh_app_setting_set --app="$app" --key=turn_secret --value="$turn_secret"
2020-04-10 05:21:33 +02:00
2022-04-13 06:04:36 +02:00
max_memory=200 #125 mib with no user +1,5*50 users=75 mib
2024-01-18 16:39:14 +01:00
ynh_app_setting_set --app="$app" --key=max_memory --value="$max_memory"
2024-01-18 16:39:14 +01:00
muc_nickname=$(uuidgen)
ynh_app_setting_set --app="$app" --key=muc_nickname --value="$muc_nickname"
2022-04-15 00:59:38 +02:00
2022-02-03 03:00:20 +01:00
#=================================================
# CREATE DEDICATED USER
#=================================================
2024-01-09 19:23:08 +01:00
ynh_script_progression --message="Configuring system user..." --weight=1
2022-02-03 03:00:20 +01:00
2024-01-18 16:39:14 +01:00
gpasswd --add prosody "$app"
gpasswd --add www-data "$app"
2019-06-06 06:04:22 +02:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Setting up source files..." --weight=1
2019-06-06 06:04:22 +02:00
2024-01-18 16:39:14 +01:00
_setup_sources
2022-02-11 00:47:00 +01:00
2024-01-09 19:10:09 +01:00
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
2024-01-18 16:39:14 +01:00
chown -R "$app:$app" "$install_dir"
2019-06-06 06:04:22 +02:00
#=================================================
2024-01-18 16:39:14 +01:00
# REPLACE JNIWRAPPER FOR ARMHF ARCHITECTURE IN JITSI-VIDEOBRIDGE
2019-06-06 06:04:22 +02:00
#=================================================
2024-01-18 16:39:14 +01:00
if [ "$YNH_ARCH" == "armhf" ]; then
ynh_script_progression --message="Configuring jniwrapper for armhf ..." --weight=1
ynh_jniwrapper_armhf
fi
2019-06-06 06:04:22 +02:00
#=================================================
# SPECIFIC SETUP
#=================================================
2022-02-03 03:00:20 +01:00
# CONFIGURE PROSODY
2019-06-06 06:04:22 +02:00
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Configuring prosody..." --weight=1
2022-02-03 03:00:20 +01:00
2024-01-09 19:23:08 +01:00
ynh_add_config --template="prosody.cfg.lua" --destination="/etc/prosody/conf.avail/$domain.cfg.lua"
2022-02-03 03:00:20 +01:00
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"
2019-06-06 06:04:22 +02:00
2024-01-18 18:47:01 +01:00
echo | prosodyctl cert generate "$domain"
2022-02-03 03:00:20 +01:00
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"
2019-06-06 06:04:22 +02:00
2024-01-18 18:47:01 +01:00
echo | prosodyctl cert generate "auth.$domain"
2022-02-03 03:00:20 +01:00
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"
2019-06-06 06:04:22 +02:00
2022-02-03 03:00:20 +01:00
update-ca-certificates -f
2019-08-25 03:40:54 +02:00
2022-02-03 03:00:20 +01:00
ynh_systemd_action --service_name="prosody" --action="restart"
2019-08-25 03:40:54 +02:00
2022-02-03 03:00:20 +01:00
prosodyctl register "$focus_user" "auth.$domain" "$focus_password"
prosodyctl register "$videobridge_user" "auth.$domain" "$videobridge_secret"
2024-01-18 16:39:14 +01:00
prosodyctl mod_roster_command subscribe "$focus_user.$domain" "$focus_user@auth.$domain"
2020-04-15 08:50:39 +02:00
2019-06-06 06:04:22 +02:00
#=================================================
2020-04-10 05:21:33 +02:00
# CONFIGURE JITSI-VIDEOBRIDGE
2019-06-06 06:04:22 +02:00
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Configuring Jitsi-Videobridge..." --weight=1
2019-06-06 06:04:22 +02:00
2020-03-31 19:56:56 +02:00
public_ipv4="$(curl ip.yunohost.org)" || true
private_ipv4="$(ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$/\1/p')" || true
2020-04-11 21:55:05 +02:00
mkdir -p "/etc/$app/videobridge"
2024-01-09 19:23:08 +01:00
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"
2020-04-15 08:50:39 +02:00
2020-04-11 21:55:05 +02:00
#=================================================
# CONFIGURE JITSI-JICOFO
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Configuring Jitsi-Jicofo..." --weight=1
2020-04-11 21:55:05 +02:00
mkdir -p "/etc/$app/jicofo"
2024-01-09 19:23:08 +01:00
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"
2019-06-06 06:04:22 +02:00
#=================================================
2020-04-10 05:21:33 +02:00
# CONFIGURE JITSI-MEET
2019-06-06 06:04:22 +02:00
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Configuring Jitsi-Meet..." --weight=1
2019-07-13 23:45:40 +02:00
2020-04-11 21:55:05 +02:00
mkdir -p "/etc/$app/meet"
2024-01-09 19:23:08 +01:00
ynh_add_config --template="jitsi-meet-config.js" --destination="/etc/$app/meet/$domain-config.js"
2022-02-03 03:00:20 +01:00
chmod 644 "/etc/$app/meet/$domain-config.js"
2020-04-11 21:55:05 +02:00
2022-06-09 01:19:53 +02:00
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Securing files and directories..." --weight=1
2022-06-09 01:19:53 +02:00
# Set permissions to app files
2024-01-18 16:39:14 +01:00
chown -R "$app:" "/etc/$app"
2022-06-09 01:19:53 +02:00
2019-06-06 06:04:22 +02:00
#=================================================
2024-01-18 16:39:14 +01:00
# SYSTEM CONFIGURATION
2019-06-06 06:04:22 +02:00
#=================================================
2024-01-18 16:39:14 +01:00
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
2019-06-06 06:04:22 +02:00
# Create a dedicated systemd config
2024-01-18 16:39:14 +01:00
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"
2019-06-06 06:04:22 +02:00
2024-01-18 16:39:14 +01:00
ynh_add_systemd_config --service="$app-jicofo" --template="jitsi-jicofo.service"
yunohost service add "$app-jicofo" --log "/var/log/$app/$app-jicofo.log"
2019-06-06 06:04:22 +02:00
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
2024-01-18 16:39:14 +01:00
chown -R "$app:" "/var/log/$app"
chmod -R 770 "/var/log/$app"
2019-06-06 06:04:22 +02:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Starting a systemd service..." --weight=1
2019-06-06 06:04:22 +02:00
# Start a systemd service
2024-01-18 16:39:14 +01:00
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"
2019-06-06 06:04:22 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Installation of $app completed" --last