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

312 lines
11 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
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
2019-08-06 21:18:00 +02:00
ynh_clean_check_starting
2019-06-06 06:04:22 +02:00
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
2019-07-13 14:18:06 +02:00
app=$YNH_APP_INSTANCE_NAME
2019-06-06 06:04:22 +02:00
#YOURSECRET3
focus_password=$(ynh_string_random --length=8)
#YOURSECRET1
videobridge_secret=$(ynh_string_random --length=8)
#YOURSECRET2
focus_secret=$(ynh_string_random --length=8)
#OTHER SECRET
turn_secret=$(ynh_string_random --length=8)
2020-04-13 17:16:38 +02:00
focus_user="focus"
2019-06-06 06:04:22 +02:00
2020-04-13 17:16:38 +02:00
videobridge_user="jvb"
2020-04-10 05:21:33 +02:00
2019-06-06 06:04:22 +02:00
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
2020-06-18 02:03:31 +02:00
ynh_script_progression --message="Validating installation parameters..."
2019-06-06 06:04:22 +02:00
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
2020-06-18 02:03:31 +02:00
ynh_script_progression --message="Storing installation settings..."
2019-06-06 06:04:22 +02:00
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
2022-02-07 01:14:21 +01:00
ynh_app_setting_set --app=$app --key=focus_user --value=$focus_user
2019-06-06 06:04:22 +02:00
ynh_app_setting_set --app=$app --key=focus_password --value=$focus_password
ynh_app_setting_set --app=$app --key=focus_secret --value=$focus_secret
2020-04-13 17:16:38 +02:00
ynh_app_setting_set --app=$app --key=videobridge_user --value=$videobridge_user
2022-02-07 01:14:21 +01:00
ynh_app_setting_set --app=$app --key=videobridge_secret --value=$videobridge_secret
ynh_app_setting_set --app=$app --key=turn_secret --value=$turn_secret
2019-06-06 06:04:22 +02:00
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
2022-02-03 03:00:20 +01:00
ynh_script_progression --message="Finding an available port..."
2019-06-06 06:04:22 +02:00
2020-01-15 21:40:17 +01:00
# Find an available port
2022-02-03 03:00:20 +01:00
port=4443
2019-06-06 06:04:22 +02:00
# Open this port
2022-02-12 23:52:11 +01:00
ynh_exec_warn_less yunohost firewall allow TCP $port
2019-06-06 06:04:22 +02:00
ynh_app_setting_set --app=$app --key=port --value=$port
2020-01-15 21:40:17 +01:00
# Find an available port
2022-02-03 03:00:20 +01:00
port_videobridge=10000
2019-07-13 14:18:06 +02:00
# Open this port
2022-02-12 23:52:11 +01:00
ynh_exec_warn_less yunohost firewall allow UDP $port_videobridge
2019-07-13 14:18:06 +02:00
ynh_app_setting_set --app=$app --key=port_videobridge --value=$port_videobridge
2020-01-15 21:40:17 +01:00
# Find an available port
2022-02-03 03:00:20 +01:00
port_component=5347
2019-07-14 01:17:46 +02:00
ynh_app_setting_set --app=$app --key=port_component --value=$port_component
2019-06-06 06:04:22 +02:00
#=================================================
# INSTALL DEPENDENCIES
#=================================================
2020-06-18 02:03:31 +02:00
ynh_script_progression --message="Installing dependencies..."
2019-06-06 06:04:22 +02:00
ynh_install_app_dependencies $pkg_dependencies
2022-02-03 03:00:20 +01:00
if ! yunohost app list | grep -q "prosody"
then
2022-02-06 15:30:08 +01:00
yunohost tools update
yunohost app install prosody
2022-02-06 01:57:11 +01:00
else
2022-02-06 15:30:08 +01:00
yunohost tools update
yunohost app upgrade prosody
2022-02-03 03:00:20 +01:00
fi
2022-02-06 01:57:11 +01:00
ynh_app_setting_set --app=$app --key=require_prosody --value="1"
2022-02-03 03:00:20 +01:00
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
2022-02-08 22:42:11 +01:00
gpasswd --add prosody $app
gpasswd --add www-data $app
2019-06-06 06:04:22 +02:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
2020-06-18 02:03:31 +02:00
ynh_script_progression --message="Setting up source files..."
2019-06-06 06:04:22 +02:00
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
2020-04-10 05:21:33 +02:00
declare -A packages
2022-02-03 03:00:20 +01:00
packages[jitsi-jicofo]="jicofo"
2020-04-10 05:21:33 +02:00
packages[jitsi-meet-prosody]="jitsi-meet/prosody-plugins"
packages[jitsi-meet-web]="jitsi-meet"
packages[jitsi-videobridge]="jitsi-videobridge"
for package in "${!packages[@]}"
do
ynh_setup_source --dest_dir="$final_path/${package}_temp" --source_id=$package
pushd "$final_path/${package}_temp"
ar x $package.deb data.tar.xz
tar xf data.tar.xz
popd
mv "$final_path/${package}_temp/usr/share/${packages[$package]}/" "$final_path/${package}/"
2020-06-18 02:55:00 +02:00
ynh_secure_remove --file="$final_path/${package}_temp"
2020-04-13 21:08:04 +02:00
done
2022-02-11 00:47:00 +01:00
ynh_setup_source --dest_dir="$final_path/jitsi-meet-prosody" --source_id=mod_auth_ldap
2022-02-08 22:42:11 +01:00
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
2019-06-06 06:04:22 +02:00
#=================================================
# NGINX CONFIGURATION
#=================================================
2022-02-03 03:00:20 +01:00
ynh_script_progression --message="Configuring NGINX web server..."
2019-06-06 06:04:22 +02:00
2022-02-03 03:00:20 +01:00
# Create a dedicated NGINX config
2019-06-06 06:04:22 +02:00
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
2022-02-03 03:00:20 +01:00
# CONFIGURE PROSODY
2019-06-06 06:04:22 +02:00
#=================================================
2022-02-03 03:00:20 +01:00
ynh_script_progression --message="Configuring prosody..."
ynh_add_config --template="../conf/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"
2019-06-06 06:04:22 +02:00
2022-02-03 03:00:20 +01:00
echo | 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"
2019-06-06 06:04:22 +02:00
2022-02-03 03:00:20 +01:00
echo | 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"
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"
2019-08-25 03:40:54 +02:00
2022-02-03 03:00:20 +01:00
prosodyctl register "$videobridge_user" "auth.$domain" "$videobridge_secret"
2019-06-06 06:04:22 +02:00
2022-02-03 03:00:20 +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
#=================================================
2020-06-18 02:03:31 +02:00
ynh_script_progression --message="Configuring Jitsi-Videobridge..."
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-05-01 09:56:02 +02:00
muc_nickname=$(uuidgen)
ynh_app_setting_set --app=$app --key=muc_nickname --value=$muc_nickname
2020-04-11 21:55:05 +02:00
mkdir -p "/etc/$app/videobridge"
2022-02-03 03:00:20 +01:00
ynh_add_config --template="../conf/jitsi-videobridge-callstats-java-sdk.properties" --destination="/etc/$app/videobridge/callstats-java-sdk.properties"
2020-04-11 21:55:05 +02:00
2022-02-03 03:00:20 +01:00
ynh_add_config --template="../conf/jitsi-videobridge-jvb.conf" --destination="/etc/$app/videobridge/jvb.conf"
2020-04-11 21:55:05 +02:00
2022-02-03 03:00:20 +01:00
ynh_add_config --template="../conf/jitsi-videobridge-logging.properties" --destination="/etc/$app/videobridge/logging.properties"
2020-04-11 21:55:05 +02:00
2022-02-03 03:00:20 +01:00
ynh_add_config --template="../conf/jitsi-videobridge-sip-communicator.properties" --destination="/etc/$app/videobridge/sip-communicator.properties"
2020-04-15 08:50:39 +02:00
2022-02-03 03:00:20 +01:00
ynh_add_config --template="../conf/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
#=================================================
2020-06-18 02:03:31 +02:00
ynh_script_progression --message="Configuring Jitsi-Jicofo..."
2020-04-11 21:55:05 +02:00
mkdir -p "/etc/$app/jicofo"
2022-02-03 03:00:20 +01:00
ynh_add_config --template="../conf/jitsi-jicofo-config" --destination="/etc/$app/jicofo/config"
2020-04-11 21:55:05 +02:00
2022-02-03 03:00:20 +01:00
ynh_add_config --template="../conf/jitsi-jicofo-jicofo.conf" --destination="/etc/$app/jicofo/jicofo.conf"
2020-04-11 21:55:05 +02:00
2022-02-03 03:00:20 +01:00
ynh_add_config --template="../conf/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
#=================================================
2020-06-18 02:03:31 +02:00
ynh_script_progression --message="Configuring Jitsi-Meet..."
2019-07-13 23:45:40 +02:00
2020-04-11 21:55:05 +02:00
mkdir -p "/etc/$app/meet"
2022-02-03 03:00:20 +01:00
ynh_add_config --template="../conf/jitsi-meet-config.js" --destination="/etc/$app/meet/$domain-config.js"
chmod 644 "/etc/$app/meet/$domain-config.js"
2020-04-11 21:55:05 +02:00
#=================================================
# CREATE LOG DIR
#=================================================
2020-06-18 02:03:31 +02:00
ynh_script_progression --message="Creating log dir..."
2020-04-11 21:55:05 +02:00
mkdir -p "/var/log/$app"
2022-02-03 03:00:20 +01:00
chown -R $app: /var/log/$app
chmod -R 770 /var/log/$app
2019-06-06 06:04:22 +02:00
#=================================================
# SETUP SYSTEMD
#=================================================
2020-06-18 02:03:31 +02:00
ynh_script_progression --message="Configuring a systemd service..."
2019-06-06 06:04:22 +02:00
# Create a dedicated systemd config
2019-07-13 14:18:06 +02:00
ynh_add_systemd_config --service=$app-videobridge --template="jitsi-videobridge.service"
ynh_add_systemd_config --service=$app-jicofo --template="jitsi-jicofo.service"
2019-06-06 06:04:22 +02:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
2020-06-18 02:03:31 +02:00
ynh_script_progression --message="Securing files and directories..."
2019-06-06 06:04:22 +02:00
# Set permissions to app files
2020-04-11 21:55:05 +02:00
chown -R $app: /etc/$app
2019-06-06 06:04:22 +02:00
2022-02-03 03:00:20 +01:00
#=================================================
# GENERIC FINALIZATION
2019-06-06 06:04:22 +02:00
#=================================================
# SETUP LOGROTATE
#=================================================
2020-06-18 02:03:31 +02:00
ynh_script_progression --message="Configuring log rotation..."
2019-06-06 06:04:22 +02:00
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
2020-01-15 21:40:17 +01:00
# INTEGRATE SERVICE IN YUNOHOST
2019-06-06 06:04:22 +02:00
#=================================================
2020-06-18 02:03:31 +02:00
ynh_script_progression --message="Integrating service in YunoHost..."
2019-06-06 06:04:22 +02:00
2022-02-06 15:37:16 +01:00
yunohost service add $app-videobridge --log "/var/log/$app/$app-videobridge.log" --needs_exposed_ports $port $port_videobridge
yunohost service add $app-jicofo --log "/var/log/$app/$app-jicofo.log"
2019-06-06 06:04:22 +02:00
#=================================================
# START SYSTEMD SERVICE
#=================================================
2020-06-18 02:03:31 +02:00
ynh_script_progression --message="Starting a systemd service..."
2019-06-06 06:04:22 +02:00
# Start a systemd service
2019-07-13 14:18:06 +02: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
#=================================================
# SETUP SSOWAT
#=================================================
2022-02-03 03:00:20 +01:00
ynh_script_progression --message="Configuring permissions..."
2019-06-06 06:04:22 +02:00
# Make app public
2022-02-03 03:00:20 +01:00
ynh_permission_update --permission="main" --add="visitors"
2019-06-06 06:04:22 +02:00
#=================================================
# RELOAD NGINX
#=================================================
2022-02-03 03:00:20 +01:00
ynh_script_progression --message="Reloading NGINX web server..."
2019-06-06 06:04:22 +02:00
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
2020-06-18 02:03:31 +02:00
ynh_script_progression --message="Installation of $app completed"