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)
|
|
|
|
|
2019-07-14 01:17:46 +02:00
|
|
|
focus_user="svc${app}focus"
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
|
|
#=================================================
|
2019-07-18 22:00:55 +02:00
|
|
|
ynh_print_info --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
|
|
|
|
#=================================================
|
2019-07-18 22:00:55 +02:00
|
|
|
ynh_print_info --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
|
|
|
|
ynh_app_setting_set --app=$app --key=focus_password --value=$focus_password
|
|
|
|
ynh_app_setting_set --app=$app --key=videobridge_secret --value=$videobridge_secret
|
|
|
|
ynh_app_setting_set --app=$app --key=focus_secret --value=$focus_secret
|
2019-07-13 14:18:06 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=focus_user --value=$focus_user
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
|
|
|
# FIND AND OPEN A PORT
|
|
|
|
#=================================================
|
2019-07-18 22:00:55 +02:00
|
|
|
ynh_print_info --message="Configuring firewall..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
# Find a free port
|
|
|
|
port=$(ynh_find_port --port=4443)
|
|
|
|
# Open this port
|
|
|
|
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
|
|
|
|
ynh_app_setting_set --app=$app --key=port --value=$port
|
|
|
|
|
2019-07-13 14:18:06 +02:00
|
|
|
# Find a free port
|
2019-07-14 01:17:46 +02:00
|
|
|
port_videobridge=$(ynh_find_port --port=10000)
|
2019-07-13 14:18:06 +02:00
|
|
|
# Open this port
|
2019-07-14 01:17:46 +02:00
|
|
|
ynh_exec_warn_less yunohost firewall allow --no-upnp UDP $port_videobridge
|
2019-07-13 14:18:06 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=port_videobridge --value=$port_videobridge
|
|
|
|
|
2019-07-14 01:17:46 +02:00
|
|
|
# Find a free port
|
|
|
|
port_component=$(ynh_find_port --port=5347)
|
|
|
|
# Open this port
|
|
|
|
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port_component
|
|
|
|
ynh_app_setting_set --app=$app --key=port_component --value=$port_component
|
|
|
|
|
2019-06-06 06:04:22 +02:00
|
|
|
#=================================================
|
|
|
|
# INSTALL DEPENDENCIES
|
|
|
|
#=================================================
|
2019-07-18 22:00:55 +02:00
|
|
|
ynh_print_info --message="Installing dependencies..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
|
|
|
|
|
|
|
ynh_install_nodejs --nodejs_version=10
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2019-07-18 22:00:55 +02:00
|
|
|
ynh_print_info --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
|
|
|
|
ynh_setup_source --dest_dir="$final_path/jitsi-videobridge" --source_id=jitsi-videobridge
|
2019-07-13 14:18:06 +02:00
|
|
|
ynh_setup_source --dest_dir="$final_path/jitsi-jicofo-build" --source_id=jitsi-jicofo
|
2019-07-13 23:45:40 +02:00
|
|
|
ynh_setup_source --dest_dir="$final_path/jitsi-meet_temp" --source_id=jitsi-meet
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2019-07-18 22:00:55 +02:00
|
|
|
ynh_print_info --message="Configuring nginx web server..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
# Create a dedicated nginx config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
2019-07-18 22:00:55 +02:00
|
|
|
ynh_print_info --message="Configuring system user..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
# Create a system user
|
|
|
|
ynh_system_user_create --username=$app --home_dir=$final_path
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
2019-08-13 01:00:37 +02:00
|
|
|
#=================================================
|
|
|
|
# SET UP CONF_REGEN HOOK
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
cp ../conf/metronome_regenconf_hook /usr/share/yunohost/hooks/conf_regen/50-metronome_$app
|
|
|
|
|
2019-06-06 06:04:22 +02:00
|
|
|
#=================================================
|
|
|
|
# CONFIGURE METRONOME
|
|
|
|
#=================================================
|
2019-07-18 22:00:55 +02:00
|
|
|
ynh_print_info --message="Configuring metronome..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
# Create additional domains
|
2019-07-18 23:10:27 +02:00
|
|
|
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
2019-08-13 01:25:28 +02:00
|
|
|
ynh_print_info --message="Creating additional domains for package_check..."
|
2019-07-14 11:41:52 +02:00
|
|
|
yunohost domain add auth.$domain
|
|
|
|
yunohost domain add conference.$domain
|
|
|
|
yunohost domain add jitsi-videobridge.$domain
|
|
|
|
yunohost domain add focus.$domain
|
|
|
|
fi
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
# Create focus user
|
2019-07-13 14:18:06 +02:00
|
|
|
yunohost user create $focus_user -f $focus_user -l $focus_user -m ${focus_user}@auth.$domain -p $focus_password -q 0
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
# Configure metronome
|
|
|
|
mv /etc/metronome/conf.d/$domain.cfg.lua /etc/metronome/conf.d/$domain.cfg.lua.back
|
|
|
|
mv /etc/metronome/conf.d/auth.$domain.cfg.lua /etc/metronome/conf.d/auth.$domain.cfg.lua.back
|
2019-07-13 14:18:06 +02:00
|
|
|
mv /etc/metronome/conf.d/conference.$domain.cfg.lua /etc/metronome/conf.d/conference.$domain.cfg.lua.back
|
|
|
|
mv /etc/metronome/conf.d/jitsi-videobridge.$domain.cfg.lua /etc/metronome/conf.d/jitsi-videobridge.$domain.cfg.lua.back
|
|
|
|
mv /etc/metronome/conf.d/focus.$domain.cfg.lua /etc/metronome/conf.d/focus.$domain.cfg.lua.back
|
|
|
|
|
2019-06-06 06:04:22 +02:00
|
|
|
metronome="/etc/metronome/conf.d/$domain.cfg.lua"
|
|
|
|
cp ../conf/metronome.cfg.lua "$metronome"
|
|
|
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$metronome"
|
|
|
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$metronome"
|
|
|
|
ynh_replace_string --match_string="__VIDEOBRIDGE_SECRET__" --replace_string="$videobridge_secret" --target_file="$metronome"
|
|
|
|
ynh_replace_string --match_string="__FOCUS_SECRET__" --replace_string="$focus_secret" --target_file="$metronome"
|
2019-07-14 01:17:46 +02:00
|
|
|
ynh_replace_string --match_string="__PORT_COMPONENT__" --replace_string="$port_component" --target_file="$metronome"
|
2019-07-13 14:18:06 +02:00
|
|
|
chown -R metronome:metronome "/etc/metronome/conf.d/"
|
|
|
|
|
|
|
|
cp ../conf/mod_carbons.lua /usr/lib/metronome/modules/mod_carbons.lua
|
|
|
|
cp ../conf/mod_http_altconnect.lua /usr/lib/metronome/modules/mod_http_altconnect.lua
|
2019-07-14 03:12:25 +02:00
|
|
|
cp ../conf/mod_smacks.lua /usr/lib/metronome/modules/mod_smacks.lua
|
2019-07-13 14:18:06 +02:00
|
|
|
|
|
|
|
ynh_systemd_action --service_name=metronome --action=restart
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BUILD JITSI-VIDEOBRIDGE
|
|
|
|
#=================================================
|
2019-07-18 22:00:55 +02:00
|
|
|
ynh_print_info --message="Building Jitsi-Videobridge..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
2019-07-13 14:18:06 +02:00
|
|
|
mkdir -p "$final_path/.sip-communicator"
|
2019-07-14 03:12:25 +02:00
|
|
|
cp ../conf/sip-communicator.properties "$final_path/.sip-communicator/sip-communicator.properties"
|
2019-07-18 21:18:39 +02:00
|
|
|
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/.sip-communicator/sip-communicator.properties"
|
2019-07-13 14:18:06 +02:00
|
|
|
chown -R $app: $final_path
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BUILD JITSI-JICOFO
|
|
|
|
#=================================================
|
2019-07-18 22:00:55 +02:00
|
|
|
ynh_print_info --message="Building Jitsi-Jicofo..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
2019-07-13 14:18:06 +02:00
|
|
|
pushd "$final_path/jitsi-jicofo-build"
|
2019-06-06 06:04:22 +02:00
|
|
|
mvn package -DskipTests -Dassembly.skipAssembly=false
|
|
|
|
popd
|
|
|
|
|
2019-07-13 14:18:06 +02:00
|
|
|
unzip $final_path/jitsi-jicofo-build/target/jicofo-linux-x64-1.1-SNAPSHOT.zip -d $final_path
|
|
|
|
|
|
|
|
mv $final_path/jicofo-linux-x64-1.1-SNAPSHOT/ $final_path/jitsi-jicofo/
|
|
|
|
|
2019-07-14 01:17:46 +02:00
|
|
|
ynh_secure_remove --file="$final_path/jitsi-jicofo-build"
|
|
|
|
|
2019-06-06 06:04:22 +02:00
|
|
|
#=================================================
|
|
|
|
# BUILD JITSI-MEET
|
|
|
|
#=================================================
|
2019-07-18 22:00:55 +02:00
|
|
|
ynh_print_info --message="Building Jitsi-Meet..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
2019-07-13 23:45:40 +02:00
|
|
|
pushd "$final_path/jitsi-meet_temp"
|
|
|
|
ar x jitsi-meet-web.deb data.tar.xz
|
|
|
|
tar xf data.tar.xz
|
2019-06-06 06:04:22 +02:00
|
|
|
popd
|
|
|
|
|
2019-07-13 23:45:40 +02:00
|
|
|
mv "$final_path/jitsi-meet_temp/usr/share/jitsi-meet/" "$final_path/jitsi-meet/"
|
|
|
|
ynh_secure_remove --file="$final_path/jitsi-meet_temp"
|
|
|
|
|
2019-06-06 06:04:22 +02:00
|
|
|
config="$final_path/jitsi-meet/config.js"
|
|
|
|
cp ../conf/config.js "$config"
|
|
|
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP SYSTEMD
|
|
|
|
#=================================================
|
2019-07-18 22:00:55 +02:00
|
|
|
ynh_print_info --message="Configuring a systemd service..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
|
|
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/jitsi-videobridge.service"
|
|
|
|
ynh_replace_string --match_string="__VIDEOBRIDGE_SECRET__" --replace_string="$videobridge_secret" --target_file="../conf/jitsi-videobridge.service"
|
2019-07-14 01:17:46 +02:00
|
|
|
ynh_replace_string --match_string="__PORT_COMPONENT__" --replace_string="$port_component" --target_file="../conf/jitsi-videobridge.service"
|
2019-07-13 14:18:06 +02:00
|
|
|
ynh_add_systemd_config --service=$app-videobridge --template="jitsi-videobridge.service"
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/jitsi-jicofo.service"
|
|
|
|
ynh_replace_string --match_string="__FOCUS_SECRET__" --replace_string="$focus_secret" --target_file="../conf/jitsi-jicofo.service"
|
2019-07-13 14:18:06 +02:00
|
|
|
ynh_replace_string --match_string="__FOCUS_USER__" --replace_string="$focus_user" --target_file="../conf/jitsi-jicofo.service"
|
2019-06-06 06:04:22 +02:00
|
|
|
ynh_replace_string --match_string="__FOCUS_PASSWORD__" --replace_string="$focus_password" --target_file="../conf/jitsi-jicofo.service"
|
2019-07-13 14:18:06 +02:00
|
|
|
ynh_add_systemd_config --service=$app-jicofo --template="jitsi-jicofo.service"
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STORE THE CONFIG FILE CHECKSUM
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Calculate and store the config file checksum into the app settings
|
|
|
|
ynh_store_file_checksum --file="$config"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# SECURE FILES AND DIRECTORIES
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Set permissions to app files
|
2019-07-13 14:18:06 +02:00
|
|
|
chown -R $app: $final_path
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP LOGROTATE
|
|
|
|
#=================================================
|
2019-07-18 22:00:55 +02:00
|
|
|
ynh_print_info --message="Configuring log rotation..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
# Use logrotate to manage application logfile(s)
|
|
|
|
ynh_use_logrotate
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# if using yunohost version 3.2 or more in the 'manifest.json', a description can be added
|
2019-07-13 14:18:06 +02:00
|
|
|
yunohost service add $app-videobridge --description "$app jitsi-videobridge for jitsi" --log "/var/log/$app/$app-videobridge.log"
|
|
|
|
yunohost service add $app-jicofo --description "$app jitsi-jicofo for jitsi" --log "/var/log/$app/$app-jicofo.log"
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2019-07-18 22:00:55 +02:00
|
|
|
ynh_print_info --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-videobridge --action="start" --log_path="/var/log/$app/$app-videobridge.log"
|
|
|
|
ynh_systemd_action --service_name=$app-jicofo --action="start" --log_path="/var/log/$app/$app-jicofo.log"
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
2019-07-18 22:00:55 +02:00
|
|
|
ynh_print_info --message="Configuring SSOwat..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
# Make app public
|
|
|
|
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2019-07-18 22:00:55 +02:00
|
|
|
ynh_print_info --message="Reloading nginx web server..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2019-07-18 22:00:55 +02:00
|
|
|
ynh_print_info --message="Installation of $app completed"
|