diff --git a/conf/cron b/conf/cron index 2fcdff0..eb881cb 100644 --- a/conf/cron +++ b/conf/cron @@ -1,5 +1,5 @@ -@daily __APP__ cd __FINAL_PATH__/live && __YNH_RUBY_LOAD_PATH__ __LD_PRELOAD__ RAILS_ENV=production bin/tootctl media remove -@monthly __APP__ cd __FINAL_PATH__/live && __YNH_RUBY_LOAD_PATH__ __LD_PRELOAD__ RAILS_ENV=production bin/tootctl media remove-orphans -@monthly __APP__ cd __FINAL_PATH__/live && __YNH_RUBY_LOAD_PATH__ __LD_PRELOAD__ RAILS_ENV=production bin/tootctl accounts cull -@monthly __APP__ cd __FINAL_PATH__/live && __YNH_RUBY_LOAD_PATH__ __LD_PRELOAD__ RAILS_ENV=production bin/tootctl statuses remove -@monthly __APP__ cd __FINAL_PATH__/live && __YNH_RUBY_LOAD_PATH__ __LD_PRELOAD__ RAILS_ENV=production bin/tootctl preview_cards remove +@daily __APP__ cd __INSTALL_DIR__/live && __YNH_RUBY_LOAD_PATH__ __LD_PRELOAD__ RAILS_ENV=production bin/tootctl media remove +@monthly __APP__ cd __INSTALL_DIR__/live && __YNH_RUBY_LOAD_PATH__ __LD_PRELOAD__ RAILS_ENV=production bin/tootctl media remove-orphans +@monthly __APP__ cd __INSTALL_DIR__/live && __YNH_RUBY_LOAD_PATH__ __LD_PRELOAD__ RAILS_ENV=production bin/tootctl accounts cull +@monthly __APP__ cd __INSTALL_DIR__/live && __YNH_RUBY_LOAD_PATH__ __LD_PRELOAD__ RAILS_ENV=production bin/tootctl statuses remove +@monthly __APP__ cd __INSTALL_DIR__/live && __YNH_RUBY_LOAD_PATH__ __LD_PRELOAD__ RAILS_ENV=production bin/tootctl preview_cards remove diff --git a/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 0000000..f4d7d1e --- /dev/null +++ b/doc/ADMIN.md @@ -0,0 +1,36 @@ +## Administrate with tooctl + +`$ (cd /var/www/glitchsoc/live && sudo -u glitchsoc RAILS_ENV=production PATH=/opt/rbenv/versions/glitchsoc/bin bin/tootctl --help)` + +## Update + +**`screen` (or `tmux`) can be used to make sure your session is not interrupted in case of connection problems.** +See [tutorial](https://www.howtogeek.com/662422/how-to-use-linuxs-screen-command/) for more background information. + +``` +$ screen +$ sudo yunohost app upgrade glitchsoc +``` + +## Backups + +First of all: Glitch-Soc uses a local cache to save media (such as posted images, videos etc.). This cache can grow huge. +You could consider cleaning up your local cache first as otherwise your backup will be very big and you might run out of disk space: + +To check your space usage, on a command line run: + +`$ sudo cd /var/www/glitchsoc/live && sudo -u glitchsoc RAILS_ENV=production PATH=/opt/rbenv/versions/glitchsoc/bin bin/tootctl media usage` + +If your cache is too big to backup, you can run the following command to clean up Attachments (the first line). Substitute X by the number of days you want to keep, e.g. 1 day. All older images will be deleted but will be refetched from the original server if necessary. + +First dry-run to see how much space is freed up (without actually removing): + +`$ sudo cd /var/www/glitchsoc/live && sudo -u glitchsoc RAILS_ENV=production PATH=/opt/rbenv/versions/glitchsoc/bin bin/tootctl media remove --days=X --dry-run` + +If all looks good commit the cleanup: + +`$ sudo cd /var/www/glitchsoc/live && sudo -u glitchsoc RAILS_ENV=production PATH=/opt/rbenv/versions/glitchsoc/bin bin/tootctl media remove --days=X ` + +## Known Bugs + +- Log-out from YunoHost's portal doesn't log out from Glitch-Soc. See https://github.com/YunoHost/issues/issues/501 diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md new file mode 100644 index 0000000..49e6312 --- /dev/null +++ b/doc/ADMIN_fr.md @@ -0,0 +1,34 @@ +## Administration avec tooctl + +`$ cd /var/www/glitchsoc/live && sudo -u glitchsoc RAILS_ENV=production PATH=/opt/rbenv/versions/glitchsoc/bin bin/tootctl --help` + +## Mise à jour + +**`screen` (ou `tmux`) peut être utilisé pour vous assurer que votre session n'est pas interrompue en cas de problème de connection.** +Consultez ce [tutoriel](https://www.howtogeek.com/662422/how-to-use-linuxs-screen-command/) pour plus de détails. + +``` +$ screen +$ sudo yunohost app upgrade glitchsoc +``` + +## Sauvegardes + +Tout d'abord : Glitch-Soc utilise un cache local pour sauvegarder les médias (comme les images, vidéos, etc). Ce cache peut devenir énorme. +Vous devriez réfléchir à vider votre cache local avant de faire une sauvegarde, qui pourrait être énorme et vous pourriez manquer d'espace de stockage. + +Pour vérifier l'utilisation du stockage, en ligne de commande utilisez : + +`$ sudo cd /var/www/glitchsoc/live && sudo -u glitchsoc RAILS_ENV=production PATH=/opt/rbenv/versions/glitchsoc/bin bin/tootctl media usage` + +Si le cache est trop gros pour être sauvegardé, vous pouvez lancer la commande suivante pour en supprimer les médias attachés. Changez `X` par le nombre de cache à conserver, par ex. 1 jour. Tous les médias plus anciens seront supprimés, mais ils pourront être rechargé du serveur d'origine si nécessaire. + +En premier faite un essai à blanc pour voir combien de place sera libérée (sans rien supprimer): +`$ sudo cd /var/www/glitchsoc/live && sudo -u glitchsoc RAILS_ENV=production PATH=/opt/rbenv/versions/glitchsoc/bin bin/tootctl media remove --days=X --dry-run` + +Si cela semble bon, effectuez le nettoyage : +`$ sudo cd /var/www/glitchsoc/live && sudo -u glitchsoc RAILS_ENV=production PATH=/opt/rbenv/versions/glitchsoc/bin bin/tootctl media remove --days=X ` + +## Bugs connus + +- Se déconnecter depuis le portail YunoHost ne vous déconnecte pas de Glitch-Soc. Voir https://github.com/YunoHost/issues/issues/501 diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index 908730c..0c487c8 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -1,5 +1,7 @@ `glitch-soc` is a friendly [fork](https://en.wikipedia.org/wiki/Fork_(software_development)) of the open-source social media software [Mastodon](https://joinmastodon.org/), with the aim of providing additional features at the risk of potentially less stable software. +⚠️ `glitch-soc` is beta software, and under active development. Use at your own risk! + ### What's different from Mastodon? `glitch-soc` adds a number of experimental features to Mastodon, such as: diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md index a1c774a..83c21e0 100644 --- a/doc/DESCRIPTION_fr.md +++ b/doc/DESCRIPTION_fr.md @@ -1,5 +1,7 @@ `glitch-soc` est une [scission](https://fr.wikipedia.org/wiki/Fork_(d%C3%A9veloppement_logiciel)) sympa du logiciel de réseau social libre [Mastodon](https://joinmastodon.org/), avec comme objectif de fournir des fonctionnalités supplémentaires, au risque d'un logiciel un peu moins stable. +⚠️ `glitch-soc` est en constant développement, fournis avec les dernières fonctionnalités (incluant les derniers bugs). + ### Quelles sont les différences avec Mastodon? `glitch-soc` ajoute de nombreuses fonctionnalitées expérimentals, comme : diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index 80153db..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,14 +0,0 @@ -⚠️ Glitch-Soc is beta software, and under active development. Use at your own risk! - -### Install - -* This app require a dedicated domain or subdomain. -* The user choosen during the installation is created in Glitch-Soc with admin rights. - -LDAP authentication and SSO are enabled. All YunoHost users can authenticate. - -We invite you to block remote malicious instances from the administration interface. You can also add text on your home page. - -### Known issues - -* When logged in with SSO, log-out from YunoHost's portal don't log-out from Glitch-Soc. See https://github.com/YunoHost/issues/issues/501 diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md deleted file mode 100644 index 49433c3..0000000 --- a/doc/DISCLAIMER_fr.md +++ /dev/null @@ -1,14 +0,0 @@ -Glitch-Soc est en constant développement, fournis avec les dernières fonctionnalités (incluant les derniers bugs). - -### Installation - -* L'application a besoin d'un domaine dédié. -* L'utilisateurice choisie lors de l'installation sera administrateurice de l'instance. Il est possible d'en ajouter d'autre depuis l'application. - -L'authentification par LDAP et le Single-Sign-On sont activés pour les utilisateurices YunoHost. - -Nous vous invitons à bloquer les instances malveillantes depuis l'interface d'administration. Vous pouvez également ajouter du texte sur votre page d'accueil. - -### Problèmes connus - -* En se connectant via le SSO, se déconnecter depuis le portail YunoHost ne vous déconnecte pas de Glitch-Soc. Voir https://github.com/YunoHost/issues/issues/501 diff --git a/doc/PRE_INSTALL.md b/doc/PRE_INSTALL.md new file mode 100644 index 0000000..ed7e17c --- /dev/null +++ b/doc/PRE_INSTALL.md @@ -0,0 +1,20 @@ +## Important points to read before installing + +1. **Glitch-Soc** require a dedicated **root domain**, eg. glitchsoc.domain.tld +1. You can't change the domain once installed. +1. The user choosen during the installation is automatically created in Glitch-Soc with admin rights +1. At the end of the installation a mail is sent to the user with the automatically generated password +1. It seems important to close the inscriptions for your Glitch-Soc, so that it remains a private body. We invite you to block remote malicious instances from the administration interface. You can also add text on your home page. + +## Using *screen* in case of disconnect + +``` +$ sudo apt-get install screen +$ screen +$ sudo yunohost app install https://github.com/YunoHost-Apps/glitchsoc_ynh.git +``` +Recover after disconnect: +``` +$ screen -d +$ screen -r +``` diff --git a/doc/PRE_INSTALL_fr.md b/doc/PRE_INSTALL_fr.md new file mode 100644 index 0000000..8ed9e10 --- /dev/null +++ b/doc/PRE_INSTALL_fr.md @@ -0,0 +1,22 @@ +## Points importants à lire avant l'installation + +1. **Glitch-Soc** nécessite un **nom de domaine** dédié, par exemple : glitchsoc.domain.tld +1. Il est impossible de changer le nom de domaine après l'installation. +1. L'utilisateur sélectionné pendant l'installation sera créé automatiquement dans Glitch-Soc avec des droits d'administration. +1. À la fin de l'installation, un mail est envoyé à cet utilisateur avec un mot de passe généré automatiquement. +1. Pour que votre instance Glitch-Soc reste privée, il est important de fermer les inscriptions. Nous vous invitons à bloquer les instances distantes indésirables depuis l'interface d'administration. Vous pouvez également ajouter un texte sur votre page d'accueil dans l'administration. + +## Utilisation de *screen* en cas de déconnexion + +L'installation de Glitch-Soc peut être longue, selon les performances du serveur. Pour éviter que le processus soit interrompu par une déconnexion, on peut utiliser `screen`. + +``` +$ sudo apt-get install screen +$ screen +$ sudo yunohost app install glitchsoc +``` +Récupérer l'installation après une deconnection : +``` +$ screen -d +$ screen -r +``` diff --git a/doc/screenshots/mastodon.png b/doc/screenshots/mastodon.png new file mode 100644 index 0000000..f248fd5 Binary files /dev/null and b/doc/screenshots/mastodon.png differ diff --git a/manifest.toml b/manifest.toml index 81cfb7d..8fc9091 100644 --- a/manifest.toml +++ b/manifest.toml @@ -13,15 +13,15 @@ maintainers = ["Tagada"] license = "AGPL-3.0-or-later" website = "https://glitch-soc.github.io/docs/" code = "https://github.com/glitch-soc/mastodon" -cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) -fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. +cpe = "???" # XXX: No CPE yet... The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. +fund = "???" # XXX: Nothing yet... [integration] -yunohost = ">= 4.3.0" -architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +yunohost = ">= 11.1" +architectures = "all" multi_instance = true -ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. -sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. +ldap = true +sso = true disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... @@ -37,8 +37,14 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen type = "user" [install.init_main_permission] - help.en = "Needed for federation." - help.fr = "Nécessaire pour la fédération." + help.en = "visitors group is needed for federation." + help.fr = "Le groupe visitors est nécessaire pour la fédération." + type = "group" + default = "visitors" + + [install.init_api_permission] + help.en = "visitors group is needed to be able to use thrid party clients." + help.fr = "Le groupe visitors est nécessaire pour pouvoir utiliser des clients tiers." type = "group" default = "visitors" @@ -54,6 +60,7 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen url = "https://github.com/glitch-soc/mastodon/archive/f08f6d20e607f8af02dcd23afa019ebee7ad36a9.tar.gz" sha256 = "7659cd68254f9c1a99411232665f1846c38c452b82f869437bbbb39d6b111425" + autoupdate.strategy = "latest_github_commit" [resources.system_user] @@ -62,14 +69,20 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen [resources.permissions] main.url = "/" + api.url = "/api" + api.allowed = "visitors" + api.auth_header = false + api.show_tile = false + api.protected = true + [resources.ports] web.default = 3000 stream.default = 4000 [resources.apt] - packages = "imagemagick, ffmpeg, libpq-dev, libxml2-dev, libxslt1-dev, file, git-core, g++, libprotobuf-dev, protobuf-compiler, pkg-config, gcc, autoconf, bison, build-essential, libssl-dev, libyaml-dev, libreadline6-dev, zlib1g-dev, libncurses5-dev, libffi-dev, libgdbm3|libgdbm6, libgdbm-dev, redis-server, redis-tools, postgresql, postgresql-contrib, libidn11-dev, libicu-dev, libjemalloc-dev, curl, apt-transport-https" + packages = "imagemagick, ffmpeg, libpq-dev, libxml2-dev, libxslt1-dev, file, git-core, g++, libprotobuf-dev, protobuf-compiler, pkg-config, gcc, autoconf, bison, build-essential, libssl-dev, libyaml-dev, libreadline6-dev, zlib1g-dev, libncurses5-dev, libffi-dev, libgdbm6, libgdbm-dev, redis-server, redis-tools, postgresql, postgresql-contrib, libidn11-dev, libicu-dev, libjemalloc-dev, curl, apt-transport-https" - [[resources.apt.extras]] + [resources.apt.extras.yarn] repo = "deb https://dl.yarnpkg.com/debian/ stable main" key = "https://dl.yarnpkg.com/debian/pubkey.gpg" packages = "yarn" diff --git a/scripts/backup b/scripts/backup index 8d9ac39..7df8f50 100644 --- a/scripts/backup +++ b/scripts/backup @@ -10,27 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_print_info --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= diff --git a/scripts/install b/scripts/install index 1c39e79..7524d86 100644 --- a/scripts/install +++ b/scripts/install @@ -9,29 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors #================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST +# RETRIEVE SETTINGS #================================================= -#REMOVEME? domain=$YNH_APP_ARG_DOMAIN -path="/" -#REMOVEME? admin=$YNH_APP_ARG_ADMIN -#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC -#REMOVEME? language=$YNH_APP_ARG_LANGUAGE admin_mail=$(ynh_user_get_info $admin 'mail') - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - max_toot_chars="500" max_pinned_toots="5" max_bio_chars="500" @@ -45,24 +28,10 @@ max_emoji_size="51200" max_remote_emoji_size="204800" #================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS +# STORE SETTINGS #================================================= -#REMOVEME? ynh_script_progression --message="Validating installation parameters..." --weight=1 +REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1 -#REMOVEME? install_dir=/var/www/$app -#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -#REMOVEME? ynh_script_progression --message="Storing installation settings..." --weight=1 - -#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain -#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path -#REMOVEME? 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 @@ -78,63 +47,22 @@ ynh_app_setting_set --app=$app --key=max_remote_emoji_size --value=$max_remote_e #================================================= # STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -#REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=1 - -# Find an available port -#REMOVEME? port_web=$(ynh_find_port --port=3000) -#REMOVEME? ynh_app_setting_set --app=$app --key=port_web --value=$port_web - -#REMOVEME? port_stream=$(ynh_find_port --port=4000) -#REMOVEME? ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream - #================================================= # INSTALL DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=10 +REMOVEME? ynh_script_progression --message="Installing Ruby and NodeJS..." --weight=10 -#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION -#REMOVEME? ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_exec_warn_less ynh_install_ruby --ruby_version=$RUBY_VERSION -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -#REMOVEME? ynh_system_user_create --username=$app --home_dir=$install_dir - -#================================================= -# CREATE A POSTGRESQL DATABASE -#================================================= -#REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..." --weight=3 - -#REMOVEME? ynh_psql_test_if_first_run -# Create PostgreSQL database -#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name="${app}_production") -#REMOVEME? db_user=$(ynh_sanitize_dbid --db_name=$app) -#REMOVEME? db_pwd=$(ynh_string_random --length=30) -#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name -#REMOVEME? ynh_app_setting_set --app=$app --key=db_user --value=$db_user -#REMOVEME? ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd -#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=3 -#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir/live" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= @@ -166,7 +94,7 @@ ynh_add_swap --size=$swap_needed #================================================= # INSTALLING RUBY AND BUNDLER #================================================= -#REMOVEME? ynh_script_progression --message="Installing Ruby dependencies..." --weight=3 +ynh_script_progression --message="Installing Ruby dependencies..." --weight=3 pushd "$install_dir/live" ynh_use_ruby @@ -192,6 +120,7 @@ ynh_app_setting_set --app="$app" --key=secret_key_base --value="$secret_key_base otp_secret=$(ynh_string_random --length=128) ynh_app_setting_set --app="$app" --key=otp_secret --value="$otp_secret" +# We need rake to build vapid keys, we generate them later once the app is installed vapid_private_key="" vapid_public_key="" @@ -230,25 +159,23 @@ pushd "$install_dir/live" ynh_use_nodejs ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install --pure-lockfile echo "SAFETY_ASSURED=1">> $config - ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails db:setup --quiet + ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails db:migrate --quiet ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:precompile --quiet + # Generate vapid keys ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role="Owner" > /dev/null ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/tootctl accounts modify "$admin" --approve popd +# Store vapid keys as settings and generate config again vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "$install_dir/live/key.txt") ynh_app_setting_set --app="$app" --key=vapid_private_key --value="$vapid_private_key" - vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" "$install_dir/live/key.txt") ynh_app_setting_set --app="$app" --key=vapid_public_key --value="$vapid_public_key" - -#REMOVEME? ynh_secure_remove --file="$install_dir/live/key.txt" +ynh_secure_remove --file="$install_dir/live/key.txt" ynh_delete_file_checksum --file="$config" - ynh_add_config --template="../conf/.env.production.sample" --destination="$config" - chmod 400 "$config" chown $app:$app "$config" @@ -279,27 +206,6 @@ ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded" ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=systemd --line_match="Worker 1 now listening" -#================================================= -# SETUP SSOWAT -#================================================= -#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 - -# Make app public if necessary -#REMOVEME? if [ $is_public -eq 1 ] -then - # Everyone can access the app. - # The "main" permission is automatically created before the install script. -#REMOVEME? ynh_permission_update --permission="main" --add="visitors" -#REMOVEME? ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" -fi - -#================================================= -# 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 #================================================= diff --git a/scripts/remove b/scripts/remove index 0fcee83..ba6c864 100644 --- a/scripts/remove +++ b/scripts/remove @@ -9,18 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$(ynh_app_setting_get --app=$app --key=db_user) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) - #================================================= # STANDARD REMOVE #================================================= @@ -56,22 +44,6 @@ ynh_remove_systemd_config --service="$app-web" ynh_remove_systemd_config --service="$app-sidekiq" ynh_remove_systemd_config --service="$app-streaming" -#================================================= -# REMOVE THE POSTGRESQL DATABASE -#================================================= -#REMOVEME? ynh_script_progression --message="Removing the PostgreSQL database..." --weight=10 - -# Remove a database if it exists, along with the associated user -#REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=10 - -# Remove the app directory securely -#REMOVEME? ynh_secure_remove --file="$install_dir" - #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -83,13 +55,10 @@ ynh_remove_nginx_config #================================================= # REMOVE DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=10 +ynh_script_progression --message="Removing Ruby and NodeJS..." --weight=10 -# Remove metapackage and its dependencies ynh_remove_ruby ynh_remove_nodejs -#REMOVEME? ynh_remove_app_dependencies -ynh_remove_extra_repo #================================================= # SPECIFIC REMOVE @@ -107,12 +76,9 @@ ynh_del_swap #================================================= # GENERIC FINALIZATION #================================================= -# REMOVE DEDICATED USER +# ... #================================================= -#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1 -# Delete a system user -#REMOVEME? ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 4930edc..0c274e0 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,38 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation 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? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$(ynh_app_setting_get --app=$app --key=db_user) -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -#REMOVEME? test ! -d $install_dir \ - || ynh_die --message="There is already a directory: $install_dir " - #================================================= # STANDARD RESTORATION STEPS #================================================= @@ -51,14 +19,6 @@ ynh_script_progression --message="Restoring the NGINX web server configuration.. ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir=$install_dir - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -75,22 +35,16 @@ chown -R $app:www-data "$install_dir" #================================================= # REINSTALL DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=10 +ynh_script_progression --message="Reinstalling Ruby and NodeJS..." --weight=10 -# Define and install dependencies -#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION -#REMOVEME? ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_install_ruby --ruby_version=$RUBY_VERSION #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=10 +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=10 -#REMOVEME? ynh_psql_test_if_first_run -#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;" ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" #================================================= @@ -112,7 +66,7 @@ ynh_add_swap --size=$swap_needed #================================================= # INSTALLING RUBY AND BUNDLER #================================================= -#REMOVEME? ynh_script_progression --message="Installing Ruby dependencies..." --weight=10 +ynh_script_progression --message="Installing Ruby dependencies..." --weight=10 pushd "$install_dir/live" ynh_use_ruby diff --git a/scripts/upgrade b/scripts/upgrade index bee1fe8..4d86b99 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,42 +12,11 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 +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? admin=$(ynh_app_setting_get --app=$app --key=admin) -#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) -#REMOVEME? language=$(ynh_app_setting_get --app=$app --key=language) -#REMOVEME? redis_namespace=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#REMOVEME? db_user=$(ynh_app_setting_get --app=$app --key=db_user) -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) admin_mail=$(ynh_user_get_info --username=$admin --key='mail') -#REMOVEME? port_web=$(ynh_app_setting_get --app=$app --key=port_web) -#REMOVEME? port_stream=$(ynh_app_setting_get --app=$app --key=port_stream) - -#REMOVEME? secret_key_base=$(ynh_app_setting_get --app=$app --key=secret_key_base) -#REMOVEME? otp_secret=$(ynh_app_setting_get --app=$app --key=otp_secret) -#REMOVEME? vapid_private_key=$(ynh_app_setting_get --app=$app --key=vapid_private_key) -#REMOVEME? vapid_public_key=$(ynh_app_setting_get --app=$app --key=vapid_public_key) - config="$install_dir/live/.env.production" -#REMOVEME? max_toot_chars=$(ynh_app_setting_get --app=$app --key=max_toot_chars) -#REMOVEME? max_pinned_toots=$(ynh_app_setting_get --app=$app --key=max_pinned_toots) -#REMOVEME? max_bio_chars=$(ynh_app_setting_get --app=$app --key=max_bio_chars) -#REMOVEME? max_profile_fields=$(ynh_app_setting_get --app=$app --key=max_profile_fields) -#REMOVEME? max_display_name_chars=$(ynh_app_setting_get --app=$app --key=max_display_name_chars) -#REMOVEME? max_poll_options=$(ynh_app_setting_get --app=$app --key=max_poll_options) -#REMOVEME? max_poll_option_chars=$(ynh_app_setting_get --app=$app --key=max_poll_option_chars) -#REMOVEME? max_image_size=$(ynh_app_setting_get --app=$app --key=max_image_size) -#REMOVEME? max_video_size=$(ynh_app_setting_get --app=$app --key=max_video_size) -#REMOVEME? max_emoji_size=$(ynh_app_setting_get --app=$app --key=max_emoji_size) -#REMOVEME? max_remote_emoji_size=$(ynh_app_setting_get --app=$app --key=max_remote_emoji_size) - #================================================= # CHECK VERSION #================================================= @@ -55,21 +24,6 @@ ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting - # 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 #================================================= @@ -86,45 +40,6 @@ ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=sy #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# Cleaning legacy permissions -#REMOVEME? if ynh_legacy_permissions_exists; then -#REMOVEME? ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -# Create a permission if needed -#REMOVEME? if ! ynh_permission_exists --permission="api"; then -#REMOVEME? ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" -fi - -# If port_web doesn't exist, create it, needed for old install -if [[ -z "$port_web" ]]; then - port_web=3000 -#REMOVEME? ynh_app_setting_set --app=$app --key=port_web --value=$port_web -fi - -# If port_web doesn't exist, create it, needed for old install -if [[ -z "$port_stream" ]]; then - port_stream=4000 -#REMOVEME? ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream -fi - -# If db_user doesn't exist, create it, needed for old install -if [[ -z "$db_user" ]]; then - db_user=$(ynh_sanitize_dbid --db_name=$app) -#REMOVEME? ynh_app_setting_set --app=$app --key=db_user --value=$db_user -fi - -# If db_pwd doesn't exist, create it, needed for old install -if [[ -z "$db_pwd" ]]; then - db_pwd=$(ynh_string_random) -#REMOVEME? ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd -#REMOVEME? ynh_psql_test_if_first_run - sudo --login --user=postgres psql -c"ALTER user $app WITH PASSWORD '$db_pwd'" postgres - ynh_replace_string --match_string="DB_PASS=" --replace_string="DB_PASS=${db_pwd}" --target_file="$config" -fi - # Remove paperclip_secret ynh_app_setting_delete --app=$app --key=paperclip_secret @@ -215,17 +130,6 @@ if [ -z "$max_remote_emoji_size" ]; then 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 -#================================================= -#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 - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -235,25 +139,7 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download Glitch-Soc - tmpdir="$(mktemp -d)" - - mkdir $tmpdir/system - if [ -d "$install_dir/live/public/system" ]; then - mv --verbose --no-target-directory --backup=numbered "$install_dir/live/public/system" "$install_dir/system.tmp" - fi - rsync -a "$config" "$tmpdir/." -#REMOVEME? ynh_secure_remove --file="$install_dir/live" - - ynh_setup_source --dest_dir="$install_dir/live" - - if [ -d "$install_dir/system.tmp" ]; then - mv --verbose --no-target-directory "$install_dir/system.tmp" "$install_dir/live/public/system" - fi - rsync -a "$tmpdir/.env.production" "$install_dir/live/." - ynh_secure_remove --file="$tmpdir" - - # Clean files which are not needed anymore -#REMOVEME? ynh_secure_remove --file="$install_dir/live/config/initializers/timeout.rb" + ynh_setup_source --dest_dir="$install_dir/live" --keep="public/system/" chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" @@ -271,11 +157,9 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=10 +ynh_script_progression --message="Upgrading Ruby and NodeJS..." --weight=10 -#REMOVEME? ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION -#REMOVEME? ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_exec_warn_less ynh_install_ruby --ruby_version=$RUBY_VERSION #================================================= @@ -299,7 +183,7 @@ ynh_add_swap --size=$swap_needed #================================================= # INSTALLING RUBY AND BUNDLER #================================================= -#REMOVEME? ynh_script_progression --message="Installing Ruby dependencies..." --weight=5 +ynh_script_progression --message="Installing Ruby dependencies..." --weight=5 pushd "$install_dir/live" ynh_use_ruby @@ -376,13 +260,6 @@ ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded" ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=systemd --line_match="Worker 1 now listening" -#================================================= -# 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 #================================================= diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..c0c737a --- /dev/null +++ b/tests.toml @@ -0,0 +1,28 @@ +test_format = 1.0 + +[default] + + # ------------ + # Tests to run + # ------------ + + exclude = ["install.subdir", "install.nourl", "install.multi"] + # The test IDs to be used in only/exclude statements are: install.root, install.subdir, install.nourl, install.multi, backup_restore, upgrade, upgrade.someCommitId change_url + # NB: you should NOT need this except if you really have a good reason... + + + # ------------------------------- + # Default args to use for install + # ------------------------------- + + # Use defaults from manifest.toml + + # ------------------------------- + # Commits to test upgrade from + # ------------------------------- + + test_upgrade_from.614380ee.name = "Upgrade from 2022.04.28~ynh1" + test_upgrade_from.614380ee.args.domain="domain.tld" + test_upgrade_from.614380ee.args.admin="john" + test_upgrade_from.614380ee.args.language="fr_FR" + test_upgrade_from.614380ee.args.is_public=1