#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= ynh_script_progression --message="Loading settings..." --weight=1 #REMOVEME? app=$YNH_APP_INSTANCE_NAME #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) #REMOVEME? max_memory=$(ynh_app_setting_get --app=$app --key=max_memory) #REMOVEME? focus_user=$(ynh_app_setting_get --app=$app --key=focus_user) #REMOVEME? focus_password=$(ynh_app_setting_get --app=$app --key=focus_password) #REMOVEME? focus_secret=$(ynh_app_setting_get --app=$app --key=focus_secret) #REMOVEME? videobridge_user=$(ynh_app_setting_get --app=$app --key=videobridge_user) #REMOVEME? videobridge_secret=$(ynh_app_setting_get --app=$app --key=videobridge_secret) #REMOVEME? turn_secret=$(ynh_app_setting_get --app=$app --key=turn_secret) #REMOVEME? muc_nickname=$(ynh_app_setting_get --app=$app --key=muc_nickname) #REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) #REMOVEME? port_videobridge=$(ynh_app_setting_get --app=$app --key=port_videobridge) #REMOVEME? port_component=$(ynh_app_setting_get --app=$app --key=port_component) #================================================= # CHECK VERSION #================================================= ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$app/manifest.json" --manifest_key="version" || echo 1.0) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= #REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app #REMOVEME? ynh_backup_before_upgrade #REMOVEME? ynh_clean_setup () { # Restore it if the upgrade fails #REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script #REMOVEME? ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app-videobridge --action="stop" --log_path="/var/log/$app/$app-videobridge.log" ynh_systemd_action --service_name=$app-jicofo --action="stop" --log_path="/var/log/$app/$app-jicofo.log" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # If install_dir doesn't exist, create it if [ -z "$install_dir" ]; then #REMOVEME? install_dir=/var/www/$app #REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir fi # If max_memory doesn't exist, create it and set to default 75 mb value if [ -z "$max_memory" ]; then max_memory=200 ynh_app_setting_set --app=$app --key=max_memory --value=$max_memory fi #================================================= # CREATE DEDICATED USER #================================================= #REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # Create a dedicated user (if not existing) #REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir" gpasswd --add www-data $app #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src declare -A packages packages[jitsi-jicofo]="jicofo" packages[jitsi-meet-prosody]="jitsi-meet/prosody-plugins" packages[jitsi-meet-web]="jitsi-meet" packages[jitsi-videobridge]="jitsi-videobridge" for package in "${!packages[@]}" do #REMOVEME? ynh_secure_remove --file="$install_dir/${package}" ynh_setup_source --dest_dir="$install_dir/${package}_temp" --source_id=$package pushd "$install_dir/${package}_temp" ar x $package.deb data.tar.xz tar xf data.tar.xz popd mv "$install_dir/${package}_temp/usr/share/${packages[$package]}/" "$install_dir/${package}/" #REMOVEME? ynh_secure_remove --file="$install_dir/${package}_temp" done ynh_setup_source --dest_dir="$install_dir/jitsi-meet-prosody" --source_id=mod_auth_ldap fi chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:$app "$install_dir" #================================================= # UPGRADE DEPENDENCIES #================================================= #REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1 ynh_install_apps --apps="$ynh_app_dependencies" #REMOVEME? ynh_install_app_dependencies $pkg_dependencies if [ $YNH_ARCH == "armhf" ] then #REMOVEME? ynh_script_progression --message="Installing specific arm dependencies..." --weight=1 #REMOVEME? ynh_install_extra_app_dependencies --repo="deb http://security.debian.org/debian-security stretch/updates main" --package="$pkg_extra_depedencies_arm" --key="https://ftp-master.debian.org/keys/archive-key-9-security.asc" fi gpasswd --add prosody $app #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config #================================================= # SPECIFIC UPGRADE #================================================= # CONFIGURE FIREWALL #================================================= ynh_script_progression --message="Configuring firewall..." --weight=1 # Open this port ynh_exec_warn_less yunohost firewall allow TCP $port ynh_exec_warn_less yunohost firewall allow UDP $port_videobridge #================================================= # CONFIGURE PROSODY #================================================= ynh_script_progression --message="Configuring Prosody..." --weight=1 if [ "$upgrade_type" == "UPGRADE_APP" ] then 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" fi #================================================= # CONFIGURE JITSI-VIDEOBRIDGE #================================================= ynh_script_progression --message="Configuring Jitsi-Videobridge..." --weight=1 if [ "$upgrade_type" == "UPGRADE_APP" ] then public_ipv4="$(curl ip.yunohost.org)" || true private_ipv4="$(ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$/\1/p')" || true ynh_add_config --template="../conf/jitsi-videobridge-callstats-java-sdk.properties" --destination="/etc/$app/videobridge/callstats-java-sdk.properties" ynh_add_config --template="../conf/jitsi-videobridge-jvb.conf" --destination="/etc/$app/videobridge/jvb.conf" ynh_add_config --template="../conf/jitsi-videobridge-logging.properties" --destination="/etc/$app/videobridge/logging.properties" ynh_add_config --template="../conf/jitsi-videobridge-sip-communicator.properties" --destination="/etc/$app/videobridge/sip-communicator.properties" ynh_add_config --template="../conf/jitsi-videobridge.config" --destination="/etc/$app/videobridge/config" fi #================================================= # 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 #================================================= # CONFIGURE JITSI-JICOFO #================================================= ynh_script_progression --message="configuring Jitsi-Jicofo..." --weight=1 if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_add_config --template="../conf/jitsi-jicofo-config" --destination="/etc/$app/jicofo/config" ynh_add_config --template="../conf/jitsi-jicofo-jicofo.conf" --destination="/etc/$app/jicofo/jicofo.conf" ynh_add_config --template="../conf/jitsi-jicofo-logging.properties" --destination="/etc/$app/jicofo/logging.properties" fi #================================================= # CONFIGURE JITSI-MEET #================================================= ynh_script_progression --message="Configuring Jitsi-Meet..." --weight=1 if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_add_config --template="../conf/jitsi-meet-config.js" --destination="/etc/$app/meet/$domain-config.js" chmod 644 "/etc/$app/meet/$domain-config.js" fi #================================================= # CREATE LOG DIR #================================================= ynh_script_progression --message="Creating log dir..." --weight=1 mkdir -p "/var/log/$app" chown -R $app: /var/log/$app chmod -R 770 /var/log/$app #================================================= # SECURE FILES AND DIRECTORIES #================================================= ynh_script_progression --message="Securing files and directories..." --weight=1 # Set permissions on app files chown -R $app: /etc/$app #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config --service=$app-videobridge --template="jitsi-videobridge.service" ynh_add_systemd_config --service=$app-jicofo --template="jitsi-jicofo.service" #================================================= # GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 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" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 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" #================================================= # RELOAD NGINX #================================================= #REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Upgrade of $app completed" --last