diff --git a/conf/nginx.conf b/conf/nginx.conf index f19975c..7abd93b 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -11,7 +11,7 @@ index index.html index.htm; error_page 404 /static/404.html; location = /config.js { - alias /etc/__NAME__/meet/__DOMAIN__-config.js; + alias /etc/__APP__/meet/__DOMAIN__-config.js; } location = /external_api.js { @@ -69,7 +69,7 @@ location ~ ^/([^/?&:'"]+)/config.js$ set $subdomain "$1."; set $subdir "$1/"; - alias /etc/__NAME__/meet/__DOMAIN__-config.js; + alias /etc/__APP__/meet/__DOMAIN__-config.js; } # BOSH for subdomains diff --git a/manifest.toml b/manifest.toml index aabfa00..d9acc9e 100644 --- a/manifest.toml +++ b/manifest.toml @@ -19,7 +19,8 @@ userdoc = "https://jitsi.org/user-faq/" code = "https://github.com/jitsi/jitsi-meet" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.29" +helpers_version = "2.1" architectures = "all" multi_instance = false @@ -87,6 +88,7 @@ ram.runtime = "50M" [resources.system_user] [resources.install_dir] + group = "www-data:r-x" [resources.ports] main.default = 4443 diff --git a/scripts/_common.sh b/scripts/_common.sh index f3cb8e5..0ad5731 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,11 +1,7 @@ #!/bin/bash #================================================= -# COMMON VARIABLES -#================================================= - -#================================================= -# PERSONAL HELPERS +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= _setup_sources() { @@ -25,13 +21,12 @@ _setup_sources() { popd mv "$install_dir/temp/usr/share/${packages[$package]}/" "$install_dir/$package/" - ynh_secure_remove --file="$install_dir/temp" + ynh_safe_rm "$install_dir/temp" done ynh_setup_source --dest_dir="$install_dir/jitsi-meet-prosody" --source_id=mod_auth_ldap } - ynh_jniwrapper_armhf () { @@ -62,20 +57,12 @@ ynh_jniwrapper_armhf () # rm official jniwrapper to copy original_jniwrapper=$(ls $install_dir/jitsi-videobridge/lib/jniwrapper-native-*.jar) - ynh_secure_remove --file="$original_jniwrapper" + ynh_safe_rm "$original_jniwrapper" mv "$tempdir/jitsi-sctp/jniwrapper/native/target/jniwrapper-native-1.0-SNAPSHOT.jar" "$install_dir/jitsi-videobridge/lib/" chmod 640 "$install_dir/jitsi-videobridge/lib/jniwrapper-native-1.0-SNAPSHOT.jar" chown -R $app:$app "$install_dir/jitsi-videobridge/lib/jniwrapper-native-1.0-SNAPSHOT.jar" - ynh_secure_remove --file="$tempdir" + ynh_safe_rm "$tempdir" } - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/backup b/scripts/backup index e024300..15b4729 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,56 +1,47 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= # SYSTEM CONFIGURATION #================================================= # Backup the nginx configuration -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" # Backup the systemd service units -ynh_backup --src_path="/etc/systemd/system/$app-videobridge.service" -ynh_backup --src_path="/etc/systemd/system/$app-jicofo.service" +ynh_backup "/etc/systemd/system/$app-videobridge.service" +ynh_backup "/etc/systemd/system/$app-jicofo.service" # Backup the logrotate configuration -ynh_backup --src_path="/etc/logrotate.d/$app" +ynh_backup "/etc/logrotate.d/$app" # Backup the Fail2Ban config -ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" -ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" +ynh_backup "/etc/fail2ban/jail.d/$app.conf" +ynh_backup "/etc/fail2ban/filter.d/$app.conf" #================================================= # BACKUP VARIOUS FILES #================================================= -ynh_backup --src_path="/etc/$app/" +ynh_backup "/etc/$app/" -ynh_backup --src_path="/etc/prosody/conf.avail/$domain.cfg.lua" +ynh_backup "/etc/prosody/conf.avail/$domain.cfg.lua" -ynh_backup --src_path="/var/log/$app/" +ynh_backup "/var/log/$app/" #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/config b/scripts/config index c4baffc..4b83238 100644 --- a/scripts/config +++ b/scripts/config @@ -1,34 +1,27 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS #================================================= - #================================================= # SPECIFIC GETTERS FOR TOML SHORT KEY #================================================= get__max_memory(){ - local max_memory=$(ynh_app_setting_get --app=$app --key=max_memory) - + local max_memory=$(ynh_app_setting_get --key=max_memory) + # If max_memory doesn't exist, create it and set to default 75 mb value if [ -z "$max_memory" ]; then max_memory=75 - ynh_app_setting_set --app=$app --key=max_memory --value=$max_memory + ynh_app_setting_set --key=max_memory --value=$max_memory fi - + cat << EOF value: $max_memory EOF @@ -48,41 +41,39 @@ set__max_memory(){ # LOAD SETTINGS #================================================= - ynh_script_progression --message="Loading installation settings..." + ynh_script_progression "Loading installation settings..." - domain=$(ynh_app_setting_get --app=$app --key=domain) - path_url=$(ynh_app_setting_get --app=$app --key=path) - final_path=$(ynh_app_setting_get --app=$app --key=final_path) + domain=$(ynh_app_setting_get --key=domain) + path_url=$(ynh_app_setting_get --key=path) + final_path=$(ynh_app_setting_get --key=final_path) - focus_user=$(ynh_app_setting_get --app=$app --key=focus_user) - focus_password=$(ynh_app_setting_get --app=$app --key=focus_password) - focus_secret=$(ynh_app_setting_get --app=$app --key=focus_secret) + focus_user=$(ynh_app_setting_get --key=focus_user) + focus_password=$(ynh_app_setting_get --key=focus_password) + focus_secret=$(ynh_app_setting_get --key=focus_secret) - videobridge_user=$(ynh_app_setting_get --app=$app --key=videobridge_user) - videobridge_secret=$(ynh_app_setting_get --app=$app --key=videobridge_secret) + videobridge_user=$(ynh_app_setting_get --key=videobridge_user) + videobridge_secret=$(ynh_app_setting_get --key=videobridge_secret) - port=$(ynh_app_setting_get --app=$app --key=port) - port_videobridge=$(ynh_app_setting_get --app=$app --key=port_videobridge) - port_component=$(ynh_app_setting_get --app=$app --key=port_component) + port=$(ynh_app_setting_get --key=port) + port_videobridge=$(ynh_app_setting_get --key=port_videobridge) + port_component=$(ynh_app_setting_get --key=port_component) #================================================= # SET SETTINGS #================================================= - - ynh_app_setting_set --app=$app --key=max_memory --value=$max_memory - + + ynh_app_setting_set --key=max_memory --value=$max_memory + #================================================= # UPDATE CONFIG FILES #================================================= - - ynh_add_config --template="../conf/jitsi-videobridge.config" --destination="/etc/$app/videobridge/config" - ynh_add_config --template="../conf/jitsi-jicofo-config" --destination="/etc/$app/jicofo/config" - - ynh_script_progression -l --message="Configuration of $app updated" + + ynh_config_add --template="jitsi-videobridge.config" --destination="/etc/$app/videobridge/config" + ynh_config_add --template="jitsi-jicofo-config" --destination="/etc/$app/jicofo/config" + + ynh_script_progression -l "Configuration of $app updated" } -#================================================= -# GENERIC FINALIZATION #================================================= ynh_app_config_run $1 diff --git a/scripts/install b/scripts/install index 96472cd..42baa5e 100644 --- a/scripts/install +++ b/scripts/install @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -15,29 +9,29 @@ source /usr/share/yunohost/helpers 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" +ynh_app_setting_set --key=focus_user --value="$focus_user" +ynh_app_setting_set --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" +ynh_app_setting_set --key=videobridge_user --value="$videobridge_user" +ynh_app_setting_set --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" +ynh_app_setting_set --key=focus_secret --value="$focus_secret" +ynh_app_setting_set --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" +ynh_app_setting_set --key=max_memory --value="$max_memory" muc_nickname=$(uuidgen) -ynh_app_setting_set --app="$app" --key=muc_nickname --value="$muc_nickname" +ynh_app_setting_set --key=muc_nickname --value="$muc_nickname" #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 +ynh_script_progression "Configuring system user..." gpasswd --add prosody "$app" gpasswd --add www-data "$app" @@ -45,20 +39,16 @@ gpasswd --add www-data "$app" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression "Setting up source files..." _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_script_progression "Configuring jniwrapper for armhf ..." ynh_jniwrapper_armhf fi @@ -67,25 +57,25 @@ fi #================================================= # CONFIGURE PROSODY #================================================= -ynh_script_progression --message="Configuring prosody..." --weight=1 +ynh_script_progression "Configuring prosody..." -ynh_add_config --template="prosody.cfg.lua" --destination="/etc/prosody/conf.avail/$domain.cfg.lua" +ynh_config_add --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" -echo | ynh_exec_warn_less prosodyctl cert generate "$domain" +echo | ynh_hide_warnings 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" -echo | ynh_exec_warn_less prosodyctl cert generate "auth.$domain" +echo | ynh_hide_warnings 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" update-ca-certificates -f -ynh_systemd_action --service_name="prosody" --action="restart" +ynh_systemctl --service="prosody" --action="restart" prosodyctl register "$focus_user" "auth.$domain" "$focus_password" prosodyctl register "$videobridge_user" "auth.$domain" "$videobridge_secret" @@ -94,44 +84,43 @@ prosodyctl mod_roster_command subscribe "$focus_user.$domain" "$focus_user@auth. #================================================= # CONFIGURE JITSI-VIDEOBRIDGE #================================================= -ynh_script_progression --message="Configuring Jitsi-Videobridge..." --weight=1 +ynh_script_progression "Configuring Jitsi-Videobridge..." public_ipv4="$(curl --no-progress-meter 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" +ynh_config_add --template="jitsi-videobridge-callstats-java-sdk.properties" --destination="/etc/$app/videobridge/callstats-java-sdk.properties" +ynh_config_add --template="jitsi-videobridge-jvb.conf" --destination="/etc/$app/videobridge/jvb.conf" +ynh_config_add --template="jitsi-videobridge-logging.properties" --destination="/etc/$app/videobridge/logging.properties" +ynh_config_add --template="jitsi-videobridge-sip-communicator.properties" --destination="/etc/$app/videobridge/sip-communicator.properties" +ynh_config_add --template="jitsi-videobridge.config" --destination="/etc/$app/videobridge/config" #================================================= # CONFIGURE JITSI-JICOFO #================================================= -ynh_script_progression --message="Configuring Jitsi-Jicofo..." --weight=1 +ynh_script_progression "Configuring Jitsi-Jicofo..." 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" +ynh_config_add --template="jitsi-jicofo-config" --destination="/etc/$app/jicofo/config" +ynh_config_add --template="jitsi-jicofo-jicofo.conf" --destination="/etc/$app/jicofo/jicofo.conf" +ynh_config_add --template="jitsi-jicofo-logging.properties" --destination="/etc/$app/jicofo/logging.properties" #================================================= # CONFIGURE JITSI-MEET #================================================= -ynh_script_progression --message="Configuring Jitsi-Meet..." --weight=1 +ynh_script_progression "Configuring Jitsi-Meet..." 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" +ynh_config_add --template="jitsi-meet-config.js" --destination="/etc/$app/meet/$domain-config.js" #================================================= # SECURE FILES AND DIRECTORIES #================================================= -ynh_script_progression --message="Securing files and directories..." --weight=1 +ynh_script_progression "Securing files and directories..." # Set permissions to app files chown -R "$app:" "/etc/$app" @@ -139,35 +128,32 @@ chown -R "$app:" "/etc/$app" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated systemd config -ynh_add_systemd_config --service="$app-videobridge" --template="jitsi-videobridge.service" +ynh_config_add_systemd --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" +ynh_config_add_systemd --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" +ynh_config_add_logrotate #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." # 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" +ynh_systemctl --service="$app-jicofo" --action="start" --log_path="/var/log/$app/$app-jicofo.log" +ynh_systemctl --service="$app-videobridge" --action="start" --log_path="/var/log/$app/$app-videobridge.log" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index a28a1b9..d15cb58 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,73 +1,67 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 +ynh_script_progression "Removing system configurations related to $app..." # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status "$app-videobridge" >/dev/null; then +if ynh_hide_warnings yunohost service status "$app-videobridge" >/dev/null; then yunohost service remove "$app-videobridge" fi -if ynh_exec_warn_less yunohost service status "$app-jicofo" >/dev/null; then +if ynh_hide_warnings yunohost service status "$app-jicofo" >/dev/null; then yunohost service remove "$app-jicofo" fi # Remove the dedicated systemd config -ynh_remove_systemd_config --service="$app-videobridge" -ynh_remove_systemd_config --service="$app-jicofo" +ynh_config_remove_systemd"$app-videobridge" +ynh_config_remove_systemd"$app-jicofo" # Remove the app-specific logrotate config -ynh_remove_logrotate +ynh_config_remove_logrotate # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx #================================================= # RECONFIGURE PROSODY #================================================= -ynh_script_progression --message="Reconfiguring Prosody..." --weight=1 +ynh_script_progression "Reconfiguring Prosody..." prosodyctl deluser "$focus_user@auth.$domain" || true prosodyctl deluser "$videobridge_user@auth.$domain" || true # Remove domain conf template -ynh_secure_remove --file="/etc/prosody/conf.d/$domain.cfg.lua" -ynh_secure_remove --file="/etc/prosody/conf.avail/$domain.cfg.lua" -ynh_secure_remove --file="/etc/prosody/certs/$domain.key" -ynh_secure_remove --file="/etc/prosody/certs/$domain.crt" -ynh_secure_remove --file="/var/lib/prosody/$domain.key" -ynh_secure_remove --file="/var/lib/prosody/$domain.crt" -ynh_secure_remove --file="/var/lib/prosody/$domain.cnf" -ynh_secure_remove --file="/etc/prosody/certs/auth.$domain.key" -ynh_secure_remove --file="/etc/prosody/certs/auth.$domain.crt" -ynh_secure_remove --file="/var/lib/prosody/auth.$domain.key" -ynh_secure_remove --file="/var/lib/prosody/auth.$domain.crt" -ynh_secure_remove --file="/var/lib/prosody/auth.$domain.cnf" -ynh_secure_remove --file="/usr/local/share/ca-certificates/auth.$domain.crt" +ynh_safe_rm "/etc/prosody/conf.d/$domain.cfg.lua" +ynh_safe_rm "/etc/prosody/conf.avail/$domain.cfg.lua" +ynh_safe_rm "/etc/prosody/certs/$domain.key" +ynh_safe_rm "/etc/prosody/certs/$domain.crt" +ynh_safe_rm "/var/lib/prosody/$domain.key" +ynh_safe_rm "/var/lib/prosody/$domain.crt" +ynh_safe_rm "/var/lib/prosody/$domain.cnf" +ynh_safe_rm "/etc/prosody/certs/auth.$domain.key" +ynh_safe_rm "/etc/prosody/certs/auth.$domain.crt" +ynh_safe_rm "/var/lib/prosody/auth.$domain.key" +ynh_safe_rm "/var/lib/prosody/auth.$domain.crt" +ynh_safe_rm "/var/lib/prosody/auth.$domain.cnf" +ynh_safe_rm "/usr/local/share/ca-certificates/auth.$domain.crt" update-ca-certificates -f gpasswd --delete prosody "$app" -ynh_systemd_action --service_name=prosody --action=restart +ynh_systemctl --service=prosody --action=restart #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 +ynh_script_progression "Removing dependencies..." -ynh_app_setting_delete --app="$app" --key=require_prosody +ynh_app_setting_delete --key=require_prosody ynh_remove_apps @@ -76,13 +70,13 @@ ynh_remove_apps #================================================= # REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing various files..." --weight=1 +ynh_script_progression "Removing various files..." # Remove a directory securely -ynh_secure_remove --file="/etc/$app" +ynh_safe_rm "/etc/$app" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 1915a16..aa7ea97 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -15,7 +9,7 @@ source /usr/share/yunohost/helpers #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Reconfiguring the dedicated system user..." --weight=1 +ynh_script_progression "Reconfiguring the dedicated system user..." gpasswd --add prosody "$app" gpasswd --add www-data "$app" @@ -23,35 +17,31 @@ gpasswd --add www-data "$app" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" - -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" -chown -R "$app:$app" "$install_dir" +ynh_restore "$install_dir" #================================================= # CONFIGURE PROSODY #================================================= -ynh_script_progression --message="Configuring prosody..." --weight=1 +ynh_script_progression "Configuring prosody..." -ynh_restore_file --origin_path="/etc/prosody/conf.avail/$domain.cfg.lua" +ynh_restore "/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" -echo | ynh_exec_warn_less prosodyctl cert generate "$domain" +echo | ynh_hide_warnings 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" -echo | ynh_exec_warn_less prosodyctl cert generate "auth.$domain" +echo | ynh_hide_warnings 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" update-ca-certificates -f -ynh_systemd_action --service_name="prosody" --action="restart" +ynh_systemctl --service="prosody" --action="restart" prosodyctl register "$focus_user" "auth.$domain" "$focus_password" prosodyctl register "$videobridge_user" "auth.$domain" "$videobridge_secret" @@ -60,41 +50,40 @@ prosodyctl mod_roster_command subscribe "$focus_user.$domain" "$focus_user@auth. #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_restore_file --origin_path="/etc/systemd/system/$app-videobridge.service" +ynh_restore "/etc/systemd/system/$app-videobridge.service" systemctl enable "$app-videobridge.service" --quiet yunohost service add "$app-videobridge" --log "/var/log/$app/$app-videobridge.log" --needs_exposed_ports $port $port_videobridge -ynh_restore_file --origin_path="/etc/systemd/system/$app-jicofo.service" +ynh_restore "/etc/systemd/system/$app-jicofo.service" systemctl enable "$app-jicofo.service" --quiet yunohost service add "$app-jicofo" --log "/var/log/$app/$app-jicofo.log" -ynh_restore_file --origin_path="/etc/logrotate.d/$app" +ynh_restore "/etc/logrotate.d/$app" #================================================= # RESTORE VARIOUS FILES #================================================= -ynh_restore_file --origin_path="/etc/$app/" -chmod 644 "/etc/$app/meet/$domain-config.js" +ynh_restore "/etc/$app/" -ynh_restore_file --origin_path="/var/log/$app/" +ynh_restore "/var/log/$app/" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 +ynh_script_progression "Reloading NGINX web server and $app's 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" +ynh_systemctl --service="$app-jicofo" --action="start" --log_path="/var/log/$app/$app-jicofo.log" +ynh_systemctl --service="$app-videobridge" --action="start" --log_path="/var/log/$app/$app-videobridge.log" -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 791d617..ab8cc42 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,34 +1,22 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 +ynh_script_progression "Stopping $app's systemd service..." -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" +ynh_systemctl --service="$app-videobridge" --action="stop" --log_path="/var/log/$app/$app-videobridge.log" +ynh_systemctl --service="$app-jicofo" --action="stop" --log_path="/var/log/$app/$app-jicofo.log" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression "Ensuring downward compatibility..." -# 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 +ynh_app_setting_set_default --key=max_memory --value=200 gpasswd --add prosody "$app" gpasswd --add www-data "$app" @@ -36,66 +24,61 @@ gpasswd --add www-data "$app" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." --weight=1 +ynh_script_progression "Upgrading source files..." _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_script_progression "Configuring jniwrapper for armhf ..." ynh_jniwrapper_armhf fi #================================================= # CONFIGURE PROSODY #================================================= -ynh_script_progression --message="Configuring Prosody..." --weight=1 +ynh_script_progression "Configuring Prosody..." -ynh_add_config --template="../conf/prosody.cfg.lua" --destination="/etc/prosody/conf.avail/$domain.cfg.lua" +ynh_config_add --template="prosody.cfg.lua" --destination="/etc/prosody/conf.avail/$domain.cfg.lua" chmod 644 "/etc/prosody/conf.avail/$domain.cfg.lua" #================================================= # CONFIGURE JITSI-VIDEOBRIDGE #================================================= -ynh_script_progression --message="Configuring Jitsi-Videobridge..." --weight=1 +ynh_script_progression "Configuring Jitsi-Videobridge..." public_ipv4="$(curl --no-progress-meter 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" +ynh_config_add --template="jitsi-videobridge-callstats-java-sdk.properties" --destination="/etc/$app/videobridge/callstats-java-sdk.properties" +ynh_config_add --template="jitsi-videobridge-jvb.conf" --destination="/etc/$app/videobridge/jvb.conf" +ynh_config_add --template="jitsi-videobridge-logging.properties" --destination="/etc/$app/videobridge/logging.properties" +ynh_config_add --template="jitsi-videobridge-sip-communicator.properties" --destination="/etc/$app/videobridge/sip-communicator.properties" +ynh_config_add --template="jitsi-videobridge.config" --destination="/etc/$app/videobridge/config" #================================================= # CONFIGURE JITSI-JICOFO #================================================= -ynh_script_progression --message="configuring Jitsi-Jicofo..." --weight=1 +ynh_script_progression "configuring Jitsi-Jicofo..." -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" +ynh_config_add --template="jitsi-jicofo-config" --destination="/etc/$app/jicofo/config" +ynh_config_add --template="jitsi-jicofo-jicofo.conf" --destination="/etc/$app/jicofo/jicofo.conf" +ynh_config_add --template="jitsi-jicofo-logging.properties" --destination="/etc/$app/jicofo/logging.properties" #================================================= # CONFIGURE JITSI-MEET #================================================= -ynh_script_progression --message="Configuring Jitsi-Meet..." --weight=1 +ynh_script_progression "Configuring Jitsi-Meet..." -ynh_add_config --template="../conf/jitsi-meet-config.js" --destination="/etc/$app/meet/$domain-config.js" -chmod 644 "/etc/$app/meet/$domain-config.js" +ynh_config_add --template="jitsi-meet-config.js" --destination="/etc/$app/meet/$domain-config.js" #================================================= # SECURE FILES AND DIRECTORIES #================================================= -ynh_script_progression --message="Securing files and directories..." --weight=1 +ynh_script_progression "Securing files and directories..." # Set permissions on app files chown -R "$app:" "/etc/$app" @@ -103,34 +86,31 @@ chown -R "$app:" "/etc/$app" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated systemd config -ynh_add_systemd_config --service="$app-videobridge" --template="jitsi-videobridge.service" +ynh_config_add_systemd --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" +ynh_config_add_systemd --service="$app-jicofo" --template="jitsi-jicofo.service" yunohost service add "$app-jicofo" --log "/var/log/$app/$app-jicofo.log" # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - -chown -R "$app:" "/var/log/$app" -chmod -R 770 "/var/log/$app" +ynh_config_add_logrotate #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's 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" +ynh_systemctl --service="$app-jicofo" --action="start" --log_path="/var/log/$app/$app-jicofo.log" +ynh_systemctl --service="$app-videobridge" --action="start" --log_path="/var/log/$app/$app-videobridge.log" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed"