1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/glitchsoc_ynh.git synced 2024-09-03 19:15:59 +02:00

Be closer to mastodon_ynh

This commit is contained in:
Tagada 2024-02-22 22:04:18 +01:00 committed by Félix Piédallu
parent fc27534bfa
commit 24b4b59541
13 changed files with 157 additions and 227 deletions

View file

@ -10,7 +10,8 @@ Environment="__LD_PRELOAD__"
Environment="RAILS_ENV=production"
Environment="DB_POOL=25"
Environment="MALLOC_ARENA_MAX=2"
ExecStart=__RBENV_ROOT__/versions/__APP__/bin/bundle exec sidekiq -c 25
Environment="__YNH_RUBY_LOAD_PATH__"
ExecStart=__INSTALL_DIR__/live/bin/bundle exec sidekiq -c 25
TimeoutSec=15
Restart=always
StandardOutput=append:/var/log/__APP__/__APP__-sidekiq.log

View file

@ -6,10 +6,11 @@ After=network.target
Type=simple
User=__APP__
WorkingDirectory=__INSTALL_DIR__/live
Environment="__LD_PRELOAD__"
Environment="RAILS_ENV=production"
Environment="PORT=__PORT_WEB__"
ExecStart=__RBENV_ROOT__/versions/__APP__/bin/bundle exec puma -C config/puma.rb
Environment="__YNH_RUBY_LOAD_PATH__"
ExecStart=__INSTALL_DIR__/live/bin/bundle exec puma -C config/puma.rb
ExecReload=/bin/kill -SIGUSR1 $MAINPID
TimeoutSec=15
Restart=always

View file

@ -29,4 +29,8 @@ First dry-run to see how much space is freed up (without actually removing):
If all looks good commit the cleanup:
`$ sudo cd __INSTALL_DIR__/live && sudo -u __APP__ RAILS_ENV=production PATH=/opt/rbenv/versions/glitchsoc/bin bin/tootctl media remove --days=X `
`$ sudo cd /var/www/mastodon/live && sudo -u mastodon RAILS_ENV=production PATH=/opt/rbenv/versions/mastodon/bin bin/tootctl media remove --days=X `
## Known Bugs
- Log-out from YunoHost's portal doesn't log out from Mastodon. See https://github.com/YunoHost/issues/issues/501

View file

@ -27,4 +27,8 @@ En premier faite un essai à blanc pour voir combien de place sera libérée (sa
`$ sudo cd __INSTALL_DIR__/live && sudo -u __APP__ 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 __INSTALL_DIR__/live && sudo -u __APP__ RAILS_ENV=production PATH=/opt/rbenv/versions/glitchsoc/bin bin/tootctl media remove --days=X `
`$ sudo cd /var/www/mastodon/live && sudo -u mastodon RAILS_ENV=production PATH=/opt/rbenv/versions/mastodon/bin bin/tootctl media remove --days=X `
## Bugs connus
- Se déconnecter depuis le portail YunoHost ne vous déconnecte pas de Mastodon. Voir https://github.com/YunoHost/issues/issues/501

View file

@ -1,19 +1,17 @@
## Points importants à lire avant l'installation
1. **Glitch-Soc** nécessite un **nom de domaine** dédié, par exemple : glitchsoc.domain.tld
2. Il est impossible de changer le nom de domaine après l'installation.
3. L'utilisateur sélectionné pendant l'installation sera créé automatiquement dans Glitch-Soc avec des droits d'administration.
4. À la fin de l'installation, un mail est envoyé à cet utilisateur avec un mot de passe généré automatiquement.
5. 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.
- **Mastodon** nécessite un **nom de domaine** dédié, par exemple : `domaine.tld` ou `mastodon.domaine.tld` sans apps installées sur ce domaine. Il est impossible de changer le nom de domaine après l'installation.
- L'utilisateur sélectionné pendant l'installation sera créé automatiquement dans Mastodon avec des droits d'administration.
- Pour que votre instance Mastodon reste privée, il est important de fermer les inscriptions. Nous vous invitons à bloquer les instances 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`.
L'installation de Mastodon 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
$ sudo apt install screen
$ screen
$ sudo yunohost app install glitchsoc
$ sudo yunohost app install mastodon
```
Récupérer l'installation après une deconnection :
```

View file

@ -18,22 +18,20 @@ code = "https://github.com/glitch-soc/mastodon"
yunohost = ">= 11.2"
architectures = "all"
multi_instance = true
ldap = true
sso = true
sso = false
disk = "2G"
ram.build = "4G"
ram.runtime = "1G"
ram.build = "1G"
ram.runtime = "500M"
[install]
[install.domain]
type = "domain"
[install.admin]
type = "user"
[install.init_main_permission]
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"
@ -44,7 +42,11 @@ ram.runtime = "1G"
choices = ["en_EN", "fr_FR"]
default = "fr_FR"
[install.admin]
type = "user"
[resources]
[resources.sources]
[resources.sources.main]
url = "https://github.com/glitch-soc/mastodon/archive/3341db939cd077820ad598b0445d02ab2382eaf4.tar.gz"
sha256 = "abf095bbf7f879d35b3e62f3fd4f339ff99b6aac98023fcc836baccfe91a0b97"
@ -70,7 +72,7 @@ ram.runtime = "1G"
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, 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, 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-tools, redis-server, postgresql, postgresql-contrib, libidn11-dev, libicu-dev, libjemalloc-dev, curl, apt-transport-https"
[resources.apt.extras.yarn]
repo = "deb https://dl.yarnpkg.com/debian/ stable main"

View file

@ -4,29 +4,34 @@
# COMMON VARIABLES
#=================================================
MEMORY_NEEDED="2560"
memory_needed="2560"
ruby_version=3.2.2
nodejs_version=20
RUBY_VERSION="3.2.3"
NODEJS_VERSION="20"
# Workaround for Mastodon on Bullseye and later
# Workaround for Mastodon on Bullseye
# See https://github.com/mastodon/mastodon/issues/15751#issuecomment-873594463
if [ "$(lsb_release --codename --short)" = "bullseye" ];
then
case $YNH_ARCH in
amd64)
arch="x86_64"
ld_preload="LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so"
;;
arm64)
arch="aarch64"
ld_preload="LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libjemalloc.so"
;;
armel|armhf)
arch="arm"
armhf)
ld_preload="LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libjemalloc.so"
;;
armel)
ld_preload="LD_PRELOAD=/usr/lib/arm-linux-gnueabi/libjemalloc.so"
;;
i386)
arch="i386"
ld_preload="LD_PRELOAD=/usr/lib/i386-linux-gnu/libjemalloc.so"
;;
esac
ld_preload="LD_PRELOAD=/usr/lib/$arch-linux-gnu/libjemalloc.so"
else
ld_preload=""
fi
#=================================================
# PERSONAL HELPERS

View file

@ -32,6 +32,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================

View file

@ -64,8 +64,8 @@ chown -R $app:www-data "$install_dir"
#=================================================
ynh_script_progression --message="Installing Ruby and NodeJS..." --weight=1
ynh_exec_warn_less ynh_install_ruby --ruby_version=$RUBY_VERSION
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# ADD SWAP IF NEEDED
@ -75,12 +75,13 @@ ynh_script_progression --message="Adding swap if needed..." --weight=1
total_memory=$(ynh_get_ram --total)
swap_needed=0
if [ $total_memory -lt $MEMORY_NEEDED ]; then
if [ $total_memory -lt $memory_needed ]; then
# Need a minimum of 2.5Go of memory
swap_needed=$(($MEMORY_NEEDED - $total_memory))
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
#=================================================
@ -105,7 +106,7 @@ ynh_app_setting_set --app="$app" --key=otp_secret --value="$otp_secret"
vapid_private_key=""
vapid_public_key=""
ynh_add_config --template="../conf/.env.production.sample" --destination="$config"
ynh_add_config --template=".env.production.sample" --destination="$config"
chmod 400 "$config"
chown $app:$app "$config"
@ -151,7 +152,7 @@ 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"
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"
ynh_add_config --template=".env.production.sample" --destination="$config"
chmod 400 "$config"
chown $app:$app "$config"
@ -174,7 +175,7 @@ ynh_add_systemd_config --service="$app-streaming" --template="glitchsoc-streamin
yunohost service add "$app-streaming" --description="$app streaming service"
# Create a cron file
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
# Use logrotate to manage application logfile(s)
mkdir -p /var/log/$app
@ -190,7 +191,7 @@ ynh_script_progression --message="Starting all systemd services..." --weight=1
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=/var/log/$app/$app-web.log --line_match="Listening on"
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=/var/log/$app/$app-sidekiq.log --line_match="Schedules Loaded"
ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=/var/log/$app/$app-streaming.log --line_match="Streaming API now listening on"
ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=/var/log/$app/$app-streaming.log --line_match="Streaming API now listening"
#=================================================
# END OF SCRIPT

View file

@ -41,21 +41,22 @@ ynh_script_progression --message="Adding swap if needed..." --weight=1
total_memory=$(ynh_get_ram --total)
swap_needed=0
if [ $total_memory -lt $MEMORY_NEEDED ]; then
if [ $total_memory -lt $memory_needed ]; then
# Need a minimum of 8Go of memory
swap_needed=$(($MEMORY_NEEDED - $total_memory))
swap_needed=$(($memory_needed - $total_memory))
fi
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
ynh_add_swap --size=$swap_needed
#=================================================
# INSTALLING RUBY, BUNDLER, AND YARN
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling Ruby and NodeJS..." --weight=1
ynh_exec_warn_less ynh_install_ruby --ruby_version=$RUBY_VERSION
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_script_progression --message="Installing Yarn dependencies..." --weight=10
@ -109,7 +110,7 @@ ynh_script_progression --message="Reloading NGINX web server and $app's service.
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=/var/log/$app/$app-web.log --line_match="Listening on"
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=/var/log/$app/$app-sidekiq.log --line_match="Schedules Loaded"
ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=/var/log/$app/$app-streaming.log --line_match="Streaming API now listening on"
ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=/var/log/$app/$app-streaming.log --line_match="Streaming API now listening"
ynh_systemd_action --service_name=nginx --action=reload

View file

@ -21,110 +21,23 @@ config="$install_dir/live/.env.production"
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Remove paperclip_secret
ynh_app_setting_delete --app=$app --key=paperclip_secret
# If secret_key_base doesn't exist, retrieve it or create it
if [[ -z "${secret_key_base:-}" ]]; then
secret_key_base=$(grep -oP "SECRET_KEY_BASE=\K\w+" $config)
if [[ -z "$secret_key_base" ]]; then
secret_key_base=$(ynh_string_random --length=128)
fi
ynh_app_setting_set --app=$app --key=secret_key_base --value="$secret_key_base"
fi
# If otp_secret doesn't exist, retrieve it or create it
if [[ -z "${otp_secret:-}" ]]; then
otp_secret=$(grep -oP "OTP_SECRET=\K\w+" $config)
if [[ -z "$otp_secret" ]]; then
otp_secret=$(ynh_string_random --length=128)
fi
ynh_app_setting_set --app=$app --key=otp_secret --value="$otp_secret"
fi
# If vapid_private_key doesn't exist, retrieve it or create it
if [[ -z "${vapid_private_key:-}" ]]; then
vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" $config)
vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" $config)
ynh_app_setting_set "$app" vapid_private_key "$vapid_private_key"
ynh_app_setting_set "$app" vapid_public_key "$vapid_public_key"
fi
# If redis_namespace doesn't exist, create it
if [[ -z "${redis_namespace:-}" ]]; then
redis_namespace=${app}_production
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
# If service doesn't exist, create it
if [[ -z "${service:-}" ]]; then
# Set `service` settings to support `yunohost app shell` command
ynh_app_setting_set --app="$app" --key=service --value="$app-web.service"
if [[ -z "${service:-}" ]]; then
service="$app-web.service"
ynh_app_setting_set --app="$app" --key=service --value="$service"
fi
#Remove previous added repository
ynh_remove_extra_repo
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=${app}-web --action="stop" --log_path=/var/log/$app/$app-web.log --line_match="Stopped"
ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=/var/log/$app/$app-sidekiq.log --line_match="Stopped"
ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=/var/log/$app/$app-streaming.log --line_match="Stopped"
ynh_systemd_action --service_name=${app}-web --action="stop" --log_path=/var/log/$app/$app-web.log --line_match="Goodbye"
ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=/var/log/$app/$app-sidekiq.log --line_match="Bye"
ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=/var/log/$app/$app-streaming.log --line_match="exiting"
# Rename the database to match packaging v2 defaults db_name (`$app_production` to `$app`)
if [[ $db_name = *'_production' ]]; then
@ -141,9 +54,9 @@ ynh_script_progression --message="Adding swap if needed..." --weight=1
total_memory=$(ynh_get_ram --total)
swap_needed=0
if [ $total_memory -lt $MEMORY_NEEDED ]; then
if [ $total_memory -lt $memory_needed ]; then
# Need a minimum of 8Go of memory
swap_needed=$(($MEMORY_NEEDED - $total_memory))
swap_needed=$(($memory_needed - $total_memory))
fi
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
@ -154,8 +67,8 @@ ynh_add_swap --size=$swap_needed
#=================================================
ynh_script_progression --message="Upgrading Ruby and NodeJS..." --weight=1
ynh_exec_warn_less ynh_install_ruby --ruby_version=$RUBY_VERSION
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
@ -173,71 +86,7 @@ then
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
pushd "$install_dir/live"
ynh_use_ruby
ynh_gem update --system --no-document
ynh_gem install bundler --no-document
popd
# Perform upgrade actions on Glitch-Soc
ynh_script_progression --message="Upgrading Glitch-Soc..." --weight=10
pushd "$install_dir/live"
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config deployment 'true'
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config without 'development test'
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
ynh_use_nodejs
corepack enable
yarn install
if [ -d "$final_path/live/public/assets" ]; then
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:clean
fi
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:precompile
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails db:migrate
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/tootctl cache clear
popd
fi
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
ynh_add_nginx_config
ynh_use_ruby
# Create a dedicated systemd config
ynh_add_systemd_config --service="$app-web" --template="glitchsoc-web.service"
yunohost service add "$app-web" --description="$app web service"
ynh_add_systemd_config --service="$app-sidekiq" --template="glitchsoc-sidekiq.service"
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
ynh_add_systemd_config --service="$app-streaming" --template="glitchsoc-streaming.service"
yunohost service add "$app-streaming" --description="$app streaming service"
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
# Use logrotate to manage app-specific logfile(s)
mkdir -p /var/log/$app
chown $app:$app /var/log/$app
ynh_use_logrotate --non-append
#=================================================
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a config file..." --weight=1
language="$(echo $language | head -c 2)"
ynh_add_config --template="../conf/.env.production.sample" --destination="$config"
chmod 400 "$config"
chown $app:$app "$config"
#=================================================
# BUILD ASSETS
@ -253,11 +102,56 @@ pushd "$install_dir/live"
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config set force_ruby_platform true --quiet
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
ynh_use_nodejs
ynh_exec_as $app $ynh_node_load_PATH yarn install --pure-lockfile
corepack enable
yarn install
if [ -d "$final_path/live/public/assets" ]; then
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:clean
fi
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:precompile
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails db:migrate
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/tootctl cache clear
popd
#=================================================
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
ynh_add_nginx_config
ynh_use_ruby
# Create a dedicated systemd config
ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service"
yunohost service add "$app-web" --description="$app web service"
ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service"
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service"
yunohost service add "$app-streaming" --description="$app streaming service"
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
# Use logrotate to manage app-specific logfile(s)
mkdir -p /var/log/$app
chown $app:$app /var/log/$app
ynh_use_logrotate --non-append
#=================================================
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a config file..." --weight=1
language="$(echo $language | head -c 2)"
ynh_add_config --template=".env.production.sample" --destination="$config"
chmod 400 "$config"
chown $app:$app "$config"
#=================================================
# APPLY MIGRATIONS
#=================================================
@ -276,7 +170,7 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=/var/log/$app/$app-web.log --line_match="Listening on"
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=/var/log/$app/$app-sidekiq.log --line_match="Schedules Loaded"
ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=/var/log/$app/$app-streaming.log --line_match="Streaming API now listening on"
ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=/var/log/$app/$app-streaming.log --line_match="Streaming API now listening"
#=================================================
# END OF SCRIPT

View file

@ -19,6 +19,13 @@ ynh_add_swap () {
SD_CARD_CAN_SWAP=${SD_CARD_CAN_SWAP:-0}
# Can't swap inside an LXD
if [ "$(systemd-detect-virt)" == "lxc" ]
then
ynh_print_warn --message="You are inside a LXC container, swap will not be added, but that can cause troubles for the app $app. Please make sure you have more than 2.5G available RAM."
return
fi
# Swap on SD card only if it's is specified
if ynh_is_main_device_a_sd_card && [ "$SD_CARD_CAN_SWAP" == "0" ]
then

View file

@ -6,10 +6,21 @@ test_format = 1.0
# Tests to run
# ------------
exclude = ["install.multi", "change_url"]
exclude = ["install.multi", "install.private", "change_url"]
# 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
# -------------------------------
# Default args to use for install
# -------------------------------
# Nothing to do here...yet
# -------------------------------
# Commits to test upgrade from
# -------------------------------
test_upgrade_from.9c7a5ae.name = "Upgrade from 2023.06.19~ynh1"
test_upgrade_from.e6e04a0.name = "Upgrade from 2024.02.18~ynh1"
test_upgrade_from.e6e04a0.args.domain="domain.tld"
test_upgrade_from.e6e04a0.args.is_public=1
test_upgrade_from.e6e04a0.args.admin="john"
test_upgrade_from.e6e04a0.args.language="fr_FR"