diff --git a/README.md b/README.md index 02c7240..c6295ab 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Glitch-Soc, a fork of Mastodon, is a free, open-source microblogging social network. It is a decentralized alternative to commercial platforms like Twitter and avoids the risks of a single company monopolizing your communication for commercial purposes. -**Shipped version:** 2022.01.10~ynh2 +**Shipped version:** 2022.01.23~ynh1 diff --git a/README_fr.md b/README_fr.md index 2fe6a8e..1341675 100644 --- a/README_fr.md +++ b/README_fr.md @@ -14,7 +14,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Glitch-Soc, une scission de Mastodon, est un réseau social de microblog auto-hébergé et open source. C'est une alternative décentralisée aux plates-formes commerciales comme Twitter. Glitch-Soc évite ainsi les risques qu'une seule société monopolise votre communication à des fins commerciales. -**Version incluse :** 2022.01.10~ynh2 +**Version incluse :** 2022.01.23~ynh1 diff --git a/check_process b/check_process index 62a2847..5d606e8 100644 --- a/check_process +++ b/check_process @@ -12,13 +12,13 @@ setup_private=1 setup_public=1 upgrade=1 - # 2022.01.10~ynh1 - upgrade=1 from_commit=9fb00be10143ee57685d4c84b21029921b33e159 + # 2022.01.10~ynh2 + upgrade=1 from_commit=325f6befc0d6da2b5102ad9c4ac64a5235ee470e backup_restore=1 multi_instance=0 port_already_use=0 change_url=0 ;;; Options ;;; Upgrade options - ; commit=efbdbb05350b820c6e59a7bbbf70f57cf679fff8 - name=2022.01.10~ynh1 + ; commit=325f6befc0d6da2b5102ad9c4ac64a5235ee470e + name=2022.01.10~ynh2 diff --git a/conf/.env.production.sample b/conf/.env.production.sample index d15d443..b597d2b 100644 --- a/conf/.env.production.sample +++ b/conf/.env.production.sample @@ -254,31 +254,31 @@ LDAP_TLS_NO_VERIFY=true # --------------- # Maximum allowed character count -MAX_TOOT_CHARS=500 +MAX_TOOT_CHARS=__MAX_TOOT_CHARS__ # Maximum number of pinned posts -MAX_PINNED_TOOTS=5 +MAX_PINNED_TOOTS=__MAX_PINNED_TOOTS__ # Maximum allowed bio characters -MAX_BIO_CHARS=500 +MAX_BIO_CHARS=__MAX_BIO_CHARS__ # Maximim number of profile fields allowed -MAX_PROFILE_FIELDS=4 +MAX_PROFILE_FIELDS=__MAX_PROFILE_FIELDS__ # Maximum allowed display name characters -MAX_DISPLAY_NAME_CHARS=30 +MAX_DISPLAY_NAME_CHARS=__MAX_DISPLAY_NAME_CHARS__ # Maximum allowed poll options -MAX_POLL_OPTIONS=5 +MAX_POLL_OPTIONS=__MAX_POLL_OPTIONS__ # Maximum allowed poll option characters -MAX_POLL_OPTION_CHARS=100 +MAX_POLL_OPTION_CHARS=__MAX_POLL_OPTION_CHARS__ # Maximum image and video/audio upload sizes # Units are in bytes # 1048576 bytes equals 1 megabyte -MAX_IMAGE_SIZE=8388608 -MAX_VIDEO_SIZE=41943040 +MAX_IMAGE_SIZE=__MAX_IMAGE_SIZE__ +MAX_VIDEO_SIZE=__MAX_VIDEO_SIZE__ # Maximum search results to display # Only relevant when elasticsearch is installed @@ -288,5 +288,5 @@ MAX_VIDEO_SIZE=41943040 # If undefined or smaller than MAX_EMOJI_SIZE, the value # of MAX_EMOJI_SIZE will be used for MAX_REMOTE_EMOJI_SIZE # Units are in bytes -MAX_EMOJI_SIZE=51200 -MAX_REMOTE_EMOJI_SIZE=204800 +MAX_EMOJI_SIZE=__MAX_EMOJI_SIZE__ +MAX_REMOTE_EMOJI_SIZE=__MAX_REMOTE_EMOJI_SIZE__ diff --git a/conf/app.src b/conf/app.src index a02e340..95c80f7 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,7 +1,7 @@ -SOURCE_URL=https://github.com/glitch-soc/mastodon/archive/07cb948f39464b11959fc506b673a90d9524e519.tar.gz -SOURCE_SUM=5808362e249689029726b79b799aab7382fc6626a142e54638633b08dee13c76 +SOURCE_URL=https://github.com/glitch-soc/mastodon/archive/e58e0eb9aa375b1107b207e8229a2142c4edc0b8.tar.gz +SOURCE_SUM=8ef596033f1278f7a2bfdff76437a2040f494769533b891fa4f83694b0d9f975 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=07cb948f39464b11959fc506b673a90d9524e519.tar.gz +SOURCE_FILENAME=e58e0eb9aa375b1107b207e8229a2142c4edc0b8.tar.gz SOURCE_EXTRACT=true diff --git a/conf/glitchsoc-sidekiq.service b/conf/glitchsoc-sidekiq.service index 7fe2cc9..f91b7b9 100644 --- a/conf/glitchsoc-sidekiq.service +++ b/conf/glitchsoc-sidekiq.service @@ -21,7 +21,7 @@ StandardError=syslog NoNewPrivileges=yes PrivateTmp=yes PrivateDevices=yes -RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 +RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK RestrictNamespaces=yes RestrictRealtime=yes DevicePolicy=closed diff --git a/conf/glitchsoc-streaming.service b/conf/glitchsoc-streaming.service index 19dd472..4122b02 100644 --- a/conf/glitchsoc-streaming.service +++ b/conf/glitchsoc-streaming.service @@ -22,7 +22,7 @@ StandardError=syslog NoNewPrivileges=yes PrivateTmp=yes PrivateDevices=yes -RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 +RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK RestrictNamespaces=yes RestrictRealtime=yes DevicePolicy=closed diff --git a/conf/glitchsoc-web.service b/conf/glitchsoc-web.service index 3285e76..24ab72a 100644 --- a/conf/glitchsoc-web.service +++ b/conf/glitchsoc-web.service @@ -21,7 +21,7 @@ StandardError=syslog NoNewPrivileges=yes PrivateTmp=yes PrivateDevices=yes -RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 +RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK RestrictNamespaces=yes RestrictRealtime=yes DevicePolicy=closed diff --git a/config_panel.toml b/config_panel.toml index 2e570ef..27153ff 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -1,7 +1,7 @@ version = "1.0" [main] -name = "Main configuration" +name = "Glitchsoc configuration" services = ["__APP__-web", "__APP__-sidekiq", "__APP__-streaming"] [main.customization] @@ -10,65 +10,69 @@ services = ["__APP__-web", "__APP__-sidekiq", "__APP__-streaming"] [main.customization.max_toot_chars] ask = "Maximum allowed character count in a toot" type = "number" - bind = ":/var/www/__APP__/live/live/.env.production" - example = 500 + example = "500" + bind = ":__FINALPATH__/live/.env.production" [main.customization.max_pinned_toots] ask = "Maximum number of pinned posts" type = "number" example = "5" - bind = ":/var/www/__APP__/live/.env.production" + bind = ":__FINALPATH__/live/.env.production" [main.customization.max_bio_chars] ask = "Maximum allowed bio characters" type = "number" - accept = "500" - bind = ":/var/www/__APP__/live/.env.production" + example = "500" + bind = ":__FINALPATH__/live/.env.production" [main.customization.max_profile_fields] ask = "Maximim number of profile fields allowed" type = "number" - accept = "4" - bind = ":/var/www/__APP__/live/.env.production" + example = "4" + bind = ":__FINALPATH__/live/.env.production" [main.customization.max_display_name_chars] ask = "Maximum allowed bio characters" type = "number" - accept = "30" - bind = ":/var/www/__APP__/live/.env.production" + example = "30" + bind = ":__FINALPATH__/live/.env.production" [main.customization.max_poll_options] ask = "Maximum allowed poll options" type = "number" - accept = "5" - bind = ":/var/www/__APP__/live/.env.production" + example = "5" + bind = ":__FINALPATH__/live/.env.production" [main.customization.max_poll_option_chars] ask = "Maximum allowed poll option characters" type = "number" - accept = "100" - bind = ":/var/www/__APP__/live/.env.production" + example = "100" + bind = ":__FINALPATH__/live/.env.production" [main.customization.max_image_size] - ask = "Maximum image upload size, in bytes" + ask = "Maximum image upload size" + help = "in bytes" type = "number" - accept = "8388608" - bind = ":/var/www/__APP__/live/.env.production" + example = "8388608" + bind = ":__FINALPATH__/live/.env.production" [main.customization.max_video_size] - ask = "Maximum video and audio upload sizes, in bytes" + ask = "Maximum video and audio upload sizes" + help = "in bytes" type = "number" - accept = "41943040" - bind = ":/var/www/__APP__/live/.env.production" + example = "41943040" + bind = ":__FINALPATH__/live/.env.production" [main.customization.max_emoji_size] ask = "Maximum custom emoji file sizes" + help = "in bytes" type = "number" - accept = "51200" - bind = ":/var/www/__APP__/live/.env.production" + example = "51200" + bind = ":__FINALPATH__/live/.env.production" [main.customization.max_remote_emoji_size] ask = "Maximum remote custom emoji file sizes" + help = "in bytes" type = "number" - accept = "204800" - bind = ":/var/www/__APP__/live/.env.production" + example = "204800" + bind = ":__FINALPATH__/live/.env.production" diff --git a/manifest.json b/manifest.json index ffb2f6b..57fffd1 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Libre and federated social network, fork of Mastodon", "fr": "Réseau social libre et fédéré, scission de Mastodon" }, - "version": "2022.01.10~ynh2", + "version": "2022.01.23~ynh1", "url": "https://github.com/glitch-soc/mastodon", "upstream": { "license": "free", diff --git a/scripts/install b/scripts/install index 82eeebf..14893b0 100644 --- a/scripts/install +++ b/scripts/install @@ -32,10 +32,22 @@ admin_mail=$(ynh_user_get_info $admin 'mail') app=$YNH_APP_INSTANCE_NAME +max_toot_chars="500" +max_pinned_toots="5" +max_bio_chars="500" +max_profile_fields="4" +max_display_name_chars="30" +max_poll_options="5" +max_poll_option_chars="100" +max_image_size="8388608" +max_video_size="41943040" +max_emoji_size="51200" +max_remote_emoji_size="204800" + #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." +ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -46,19 +58,30 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." +ynh_script_progression --message="Storing installation settings..." --weight=1 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=admin --value=$admin ynh_app_setting_set --app=$app --key=language --value=$language +ynh_app_setting_set --app=$app --key=max_toot_chars --value=$max_toot_chars +ynh_app_setting_set --app=$app --key=max_pinned_toots --value=$max_pinned_toots +ynh_app_setting_set --app=$app --key=max_bio_chars --value=$max_bio_chars +ynh_app_setting_set --app=$app --key=max_profile_fields --value=$max_profile_fields +ynh_app_setting_set --app=$app --key=max_display_name_chars--value=$max_display_name_chars +ynh_app_setting_set --app=$app --key=max_poll_options --value=$max_poll_options +ynh_app_setting_set --app=$app --key=max_poll_option_chars --value=$max_poll_option_chars +ynh_app_setting_set --app=$app --key=max_image_size --value=$max_image_size +ynh_app_setting_set --app=$app --key=max_video_size --value=$max_video_size +ynh_app_setting_set --app=$app --key=max_emoji_size --value=$max_emoji_size +ynh_app_setting_set --app=$app --key=max_remote_emoji_size --value=$max_remote_emoji_size #================================================= # STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Finding an available port..." +ynh_script_progression --message="Finding an available port..." --weight=1 # Find an available port port_web=$(ynh_find_port --port=3000) @@ -70,7 +93,7 @@ ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." +ynh_script_progression --message="Installing dependencies..." --weight=60 ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION @@ -80,7 +103,7 @@ ynh_exec_warn_less ynh_install_ruby --ruby_version=$RUBY_VERSION #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." +ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user ynh_system_user_create --username=$app --home_dir=$final_path @@ -88,7 +111,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." +ynh_script_progression --message="Creating a PostgreSQL database..." --weight=14 ynh_psql_test_if_first_run # Create PostgreSQL database @@ -104,7 +127,7 @@ ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +ynh_script_progression --message="Setting up source files..." --weight=5 ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src @@ -117,7 +140,7 @@ chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." +ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config @@ -127,7 +150,7 @@ ynh_add_nginx_config #================================================= # ADD SWAP IF NEEDED #================================================= -ynh_script_progression --message="Adding swap if needed..." +ynh_script_progression --message="Adding swap if needed..." --weight=1 total_memory=$(ynh_get_ram --total) swap_needed=0 @@ -137,24 +160,24 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then swap_needed=$(($MEMORY_NEEDED - $total_memory)) fi -ynh_script_progression --message="Adding $swap_needed Mo to swap..." +ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 ynh_add_swap --size=$swap_needed #================================================= # INSTALLING RUBY AND BUNDLER #================================================= -ynh_script_progression --message="Installing Ruby..." +ynh_script_progression --message="Installing Ruby dependencies..." --weight=6 pushd "$final_path/live" ynh_use_ruby - ynh_gem update --system + ynh_gem update --system --no-document ynh_gem install bundler --no-document popd #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." +ynh_script_progression --message="Adding a configuration file..." --weight=1 config="$final_path/live/.env.production" @@ -188,7 +211,7 @@ chown $app:$app "$final_path/live/config/settings.yml" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." +ynh_script_progression --message="Configuring a systemd service..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config --service="$app-web" --template="glitchsoc-web.service" @@ -198,7 +221,7 @@ ynh_add_systemd_config --service="$app-streaming" --template="glitchsoc-streamin #================================================= # INSTALLING GLITCH-SOC #================================================= -ynh_script_progression --message="Installing Glitch-Soc..." +ynh_script_progression --message="Installing Glitch-Soc..." --weight=30 pushd "$final_path/live" ynh_exec_as $app $ynh_ruby_load_path bin/bundle config deployment 'true' @@ -232,7 +255,7 @@ chown $app:$app "$config" #================================================= # SETUP THE CRON FILE #================================================= -ynh_script_progression --message="Setuping the cron file..." +ynh_script_progression --message="Setuping the cron file..." --weight=1 ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" @@ -241,7 +264,7 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add "$app-web" --description="$app web service" yunohost service add "$app-sidekiq" --description="$app sidekiq service" @@ -250,7 +273,7 @@ yunohost service add "$app-streaming" --description="$app streaming service" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=3 ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on" ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded" @@ -259,7 +282,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." +ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary if [ $is_public -eq 1 ] @@ -273,7 +296,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -281,4 +304,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" +ynh_script_progression --message="Installation of $app completed" --weight=1 diff --git a/scripts/remove b/scripts/remove index 94452af..0d7da1f 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -30,26 +30,26 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # 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-web" >/dev/null then - ynh_script_progression --message="Removing $app-web service integration..." + ynh_script_progression --message="Removing $app-web service integration..." --weight=1 yunohost service remove "$app-web" fi if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null then - ynh_script_progression --message="Removing $app-sidekiq service integration..." + ynh_script_progression --message="Removing $app-sidekiq service integration..." --weight=1 yunohost service remove "$app-sidekiq" fi if ynh_exec_warn_less yunohost service status "$app-streaming" >/dev/null then - ynh_script_progression --message="Removing $app-streaming service integration..." + ynh_script_progression --message="Removing $app-streaming service integration..." --weight=1 yunohost service remove "$app-streaming" fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." +ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 # Remove the dedicated systemd config ynh_remove_systemd_config --service="$app-web" @@ -59,7 +59,7 @@ ynh_remove_systemd_config --service="$app-streaming" #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." +ynh_script_progression --message="Removing the PostgreSQL database..." --weight=10 # Remove a database if it exists, along with the associated user ynh_psql_remove_db --db_user=$db_user --db_name=$db_name @@ -67,7 +67,7 @@ ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." +ynh_script_progression --message="Removing app main directory..." --weight=10 # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -75,7 +75,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." +ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 # Remove the dedicated NGINX config ynh_remove_nginx_config @@ -83,7 +83,7 @@ ynh_remove_nginx_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." +ynh_script_progression --message="Removing dependencies..." --weight=30 # Remove metapackage and its dependencies ynh_remove_ruby @@ -96,7 +96,7 @@ ynh_remove_extra_repo #================================================= # REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing various files..." +ynh_script_progression --message="Removing various files..." --weight=1 # Remove a cron file ynh_secure_remove --file="/etc/cron.d/$app" @@ -109,7 +109,7 @@ ynh_del_swap #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." +ynh_script_progression --message="Removing the dedicated system user..." --weight=1 # Delete a system user ynh_system_user_delete --username=$app @@ -118,4 +118,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" +ynh_script_progression --message="Removal of $app completed" --weight=1 diff --git a/scripts/restore b/scripts/restore index 2183806..386825a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -23,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -37,7 +37,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." +ynh_script_progression --message="Validating restoration parameters..." --weight=1 test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " @@ -47,14 +47,14 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." +ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." +ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir=$final_path @@ -62,7 +62,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." --weight=10 ynh_restore_file --origin_path="$final_path" @@ -75,7 +75,7 @@ chown -R $app:www-data "$final_path" #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." +ynh_script_progression --message="Reinstalling dependencies..." --weight=60 # Define and install dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies @@ -86,7 +86,7 @@ ynh_install_ruby --ruby_version=$RUBY_VERSION #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=10 ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd @@ -96,7 +96,7 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" #================================================= # ADD SWAP IF NEEDED #================================================= -ynh_script_progression --message="Adding swap if needed..." +ynh_script_progression --message="Adding swap if needed..." --weight=1 total_memory=$(ynh_get_ram --total) swap_needed=0 @@ -106,31 +106,31 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then swap_needed=$(($MEMORY_NEEDED - $total_memory)) fi -ynh_script_progression --message="Adding $swap_needed Mo to swap..." +ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 ynh_add_swap --size=$swap_needed #================================================= # INSTALLING RUBY AND BUNDLER #================================================= -ynh_script_progression --message="Installing Ruby..." +ynh_script_progression --message="Installing Ruby dependencies..." --weight=30 pushd "$final_path/live" ynh_use_ruby - ynh_gem update --system + ynh_gem update --system --no-document ynh_gem install bundler --no-document popd #================================================= # RESTORE VARIOUS FILES #================================================= -ynh_script_progression --message="Restoring various files..." +ynh_script_progression --message="Restoring various files..." --weight=1 ynh_restore_file --origin_path="/etc/cron.d/$app" #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." +ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service" @@ -140,7 +140,7 @@ systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" --quiet #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add "$app-web" --description="$app web service" yunohost service add "$app-sidekiq" --description="$app sidekiq service" @@ -149,7 +149,7 @@ yunohost service add "$app-streaming" --description="$app streaming service" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on" ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded" @@ -160,7 +160,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -168,4 +168,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" +ynh_script_progression --message="Restoration completed for $app" --weight=1 diff --git a/scripts/upgrade b/scripts/upgrade index 434a140..692a6d2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -36,17 +36,29 @@ vapid_public_key=$(ynh_app_setting_get --app=$app --key=vapid_public_key) config="$final_path/live/.env.production" +max_toot_chars=$(ynh_app_setting_get --app=$app --key=max_toot_chars) +max_pinned_toots=$(ynh_app_setting_get --app=$app --key=max_pinned_toots) +max_bio_chars=$(ynh_app_setting_get --app=$app --key=max_bio_chars) +max_profile_fields=$(ynh_app_setting_get --app=$app --key=max_profile_fields) +max_display_name_chars=$(ynh_app_setting_get --app=$app --key=max_display_name_chars) +max_poll_options=$(ynh_app_setting_get --app=$app --key=max_poll_options) +max_poll_option_chars=$(ynh_app_setting_get --app=$app --key=max_poll_option_chars) +max_image_size=$(ynh_app_setting_get --app=$app --key=max_image_size) +max_video_size=$(ynh_app_setting_get --app=$app --key=max_video_size) +max_emoji_size=$(ynh_app_setting_get --app=$app --key=max_emoji_size) +max_remote_emoji_size=$(ynh_app_setting_get --app=$app --key=max_remote_emoji_size) + #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." +ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 # Backup the current version of the app ynh_backup_before_upgrade @@ -63,7 +75,7 @@ ynh_abort_if_errors #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." +ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=${app}-web --action="stop" --log_path=systemd --line_match="Stopped" ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=systemd --line_match="Stopped" @@ -72,7 +84,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=sy #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # Cleaning legacy permissions if ynh_legacy_permissions_exists; then @@ -148,13 +160,68 @@ if [[ -z "$redis_namespace" ]]; then ynh_app_setting_set --app=$app --key=redis_namespace --value=$redis_namespace fi +if [ -z "$max_toot_chars" ]; then + max_toot_chars="500" + ynh_app_setting_set --app=$app --key=max_toot_chars --value=$max_toot_chars +fi + +if [ -z "$max_pinned_toots" ]; then + max_pinned_toots="5" + ynh_app_setting_set --app=$app --key=max_pinned_toots --value=$max_pinned_toots +fi + +if [ -z "$max_bio_chars" ]; then + max_bio_chars="500" + ynh_app_setting_set --app=$app --key=max_bio_chars --value=$max_bio_chars +fi + +if [ -z "$max_profile_fields" ]; then + max_profile_fields="4" + ynh_app_setting_set --app=$app --key=max_profile_fields --value=$max_profile_fields +fi + +if [ -z "$max_display_name_chars" ]; then + max_display_name_chars="30" + ynh_app_setting_set --app=$app --key=max_display_name_chars --value=$max_display_name_chars +fi + +if [ -z "$max_poll_options" ]; then + max_poll_options="5" + ynh_app_setting_set --app=$app --key=max_poll_options --value=$max_poll_options +fi + +if [ -z "$max_poll_option_chars" ]; then + max_poll_option_chars="100" + ynh_app_setting_set --app=$app --key=max_poll_option_chars --value=$max_poll_option_chars +fi + +if [ -z "$max_image_size" ]; then + max_image_size="8388608" + ynh_app_setting_set --app=$app --key=max_image_size --value=$max_image_size +fi + +if [ -z "$max_video_size" ]; then + max_video_size="41943040" + ynh_app_setting_set --app=$app --key=max_video_size --value=$max_video_size +fi + +if [ -z "$max_emoji_size" ]; then + max_emoji_size="51200" + ynh_app_setting_set --app=$app --key=max_emoji_size --value=$max_emoji_size +fi + +if [ -z "$max_remote_emoji_size" ]; then + max_remote_emoji_size="204800" + ynh_app_setting_set --app=$app --key=max_remote_emoji_size --value=$max_remote_emoji_size +fi + #Remove previous added repository ynh_remove_extra_repo #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # Create a dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir=$final_path @@ -165,7 +232,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." + ynh_script_progression --message="Upgrading source files..." --weight=1 # Download Glitch-Soc tmpdir="$(mktemp -d)" @@ -187,16 +254,16 @@ then # Clean files which are not needed anymore ynh_secure_remove --file="$final_path/live/config/initializers/timeout.rb" -fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" + chmod 750 "$final_path" + chmod -R o-rwx "$final_path" + chown -R $app:www-data "$final_path" +fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config @@ -204,7 +271,7 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." +ynh_script_progression --message="Upgrading dependencies..." --weight=60 ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION @@ -216,7 +283,7 @@ ynh_exec_warn_less ynh_install_ruby --ruby_version=$RUBY_VERSION #================================================= # ADD SWAP IF NEEDED #================================================= -ynh_script_progression --message="Adding swap if needed..." +ynh_script_progression --message="Adding swap if needed..." --weight=1 total_memory=$(ynh_get_ram --total) swap_needed=0 @@ -226,24 +293,24 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then swap_needed=$(($MEMORY_NEEDED - $total_memory)) fi -ynh_script_progression --message="Adding $swap_needed Mo to swap..." +ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 ynh_add_swap --size=$swap_needed #================================================= # INSTALLING RUBY AND BUNDLER #================================================= -ynh_script_progression --message="Installing Ruby..." +ynh_script_progression --message="Installing Ruby dependencies..." --weight=6 pushd "$final_path/live" ynh_use_ruby - ynh_gem update --system + ynh_gem update --system --no-document ynh_gem install bundler --no-document popd #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a config file..." +ynh_script_progression --message="Updating a config file..." --weight=1 language="$(echo $language | head -c 2)" @@ -255,7 +322,7 @@ chown $app:$app "$config" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." +ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config --service="$app-web" --template="glitchsoc-web.service" @@ -265,24 +332,27 @@ ynh_add_systemd_config --service="$app-streaming" --template="glitchsoc-streamin #================================================= # UPGRADE GLITCH-SOC #================================================= -ynh_script_progression --message="Upgrading Glitch-Soc..." +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading Glitch-Soc..." --weight=30 -pushd "$final_path/live" - ynh_exec_as $app $ynh_ruby_load_path bin/bundle config deployment 'true' - ynh_exec_as $app $ynh_ruby_load_path bin/bundle config without 'development test' - ynh_exec_as $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN) - ynh_use_nodejs - ynh_exec_as $app $ynh_node_load_PATH yarn install --pure-lockfile - ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:clean - ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile - ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:migrate - ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl cache clear -popd + pushd "$final_path/live" + ynh_exec_as $app $ynh_ruby_load_path bin/bundle config deployment 'true' + ynh_exec_as $app $ynh_ruby_load_path bin/bundle config without 'development test' + ynh_exec_as $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN) + ynh_use_nodejs + ynh_exec_as $app $ynh_node_load_PATH yarn install --pure-lockfile + ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:clean + ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile + ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:migrate + ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl cache clear + popd +fi #================================================= # SETUP THE CRON FILE #================================================= -ynh_script_progression --message="Setuping the cron file..." +ynh_script_progression --message="Setuping the cron file..." --weight=1 ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" @@ -291,7 +361,7 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add "$app-web" --description="$app web service" yunohost service add "$app-sidekiq" --description="$app sidekiq service" @@ -300,7 +370,7 @@ yunohost service add "$app-streaming" --description="$app streaming service" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on" ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded" @@ -309,7 +379,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -317,4 +387,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" +ynh_script_progression --message="Upgrade of $app completed" --weight=1