mirror of
https://github.com/YunoHost-Apps/glitchsoc_ynh.git
synced 2024-09-03 19:15:59 +02:00
cleanup, applying template
This commit is contained in:
parent
68cab1761b
commit
79865d0fc3
5 changed files with 135 additions and 187 deletions
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -22,23 +20,13 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
ynh_backup --src_path="$install_dir"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
# BACKUP THE SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC BACKUP
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP SYSTEMD
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/$app-web.service"
|
||||
ynh_backup --src_path="/etc/systemd/system/$app-sidekiq.service"
|
||||
ynh_backup --src_path="/etc/systemd/system/$app-streaming.service"
|
||||
|
@ -49,6 +37,8 @@ ynh_backup --src_path="/etc/systemd/system/$app-streaming.service"
|
|||
|
||||
ynh_backup --src_path="/etc/cron.d/$app"
|
||||
|
||||
ynh_backup --src_path="/var/log/$app/"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
|
|
108
scripts/install
108
scripts/install
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -11,7 +9,11 @@ source ynh_install_ruby__2
|
|||
source ynh_add_swap
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
|
||||
#=================================================
|
||||
# INITIALIZE AND STORE SETTINGS
|
||||
#=================================================
|
||||
|
||||
admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
|
||||
|
||||
# Initialize config_panel settings :<
|
||||
max_toot_chars="500"
|
||||
|
@ -25,46 +27,37 @@ max_image_size="8388608"
|
|||
max_video_size="41943040"
|
||||
max_emoji_size="51200"
|
||||
max_remote_emoji_size="204800"
|
||||
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
|
||||
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"
|
||||
|
||||
# Set `service` settings to support `yunohost app shell` command
|
||||
ynh_app_setting_set --app="$app" --key=service --value="$app-web.service"
|
||||
|
||||
# Find an available port
|
||||
port_web=$(ynh_find_port --port=3000)
|
||||
ynh_app_setting_set --app=$app --key=port_web --value=$port_web
|
||||
redis_namespace=${app}_production
|
||||
ynh_app_setting_set --app="$app" --key=redis_namespace --value="$redis_namespace"
|
||||
|
||||
port_stream=$(ynh_find_port --port=4000)
|
||||
ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream
|
||||
secret_key_base=$(ynh_string_random --length=128)
|
||||
ynh_app_setting_set --app="$app" --key=secret_key_base --value="$secret_key_base"
|
||||
|
||||
#=================================================
|
||||
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=1
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir/live"
|
||||
|
||||
chown -R $app:www-data "$install_dir"
|
||||
otp_secret=$(ynh_string_random --length=128)
|
||||
ynh_app_setting_set --app="$app" --key=otp_secret --value="$otp_secret"
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Ruby and NodeJS..." --weight=1
|
||||
|
||||
ynh_script_progression --message="Installing Ruby..." --weight=1
|
||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||
|
||||
ynh_script_progression --message="Installing NodeJS..." --weight=1
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
#=================================================
|
||||
|
@ -84,6 +77,16 @@ ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
|||
|
||||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=1
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir/live"
|
||||
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -93,22 +96,13 @@ config="$install_dir/live/.env.production"
|
|||
|
||||
language="$(echo $language | head -c 2)"
|
||||
|
||||
redis_namespace=${app}_production
|
||||
ynh_app_setting_set --app="$app" --key=redis_namespace --value="$redis_namespace"
|
||||
|
||||
secret_key_base=$(ynh_string_random --length=128)
|
||||
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=""
|
||||
|
||||
ynh_add_config --template=".env.production.sample" --destination="$config"
|
||||
chmod 400 "$config"
|
||||
chown $app:$app "$config"
|
||||
chown "$app:$app" "$config"
|
||||
|
||||
ynh_replace_string --match_string="registrations_mode: 'open'" --replace_string="registrations_mode: 'none'" --target_file="$install_dir/live/config/settings.yml"
|
||||
ynh_replace_string --match_string="min_invite_role: 'admin'" --replace_string="min_invite_role: 'none'" --target_file="$install_dir/live/config/settings.yml"
|
||||
|
@ -116,7 +110,7 @@ ynh_replace_string --match_string="min_invite_role: 'admin'" --replace_string="m
|
|||
ynh_store_file_checksum --file="$install_dir/live/config/settings.yml"
|
||||
|
||||
chmod 400 "$install_dir/live/config/settings.yml"
|
||||
chown $app:$app "$install_dir/live/config/settings.yml"
|
||||
chown "$app:$app" "$install_dir/live/config/settings.yml"
|
||||
|
||||
#=================================================
|
||||
# BUILD APP
|
||||
|
@ -128,21 +122,22 @@ pushd "$install_dir/live"
|
|||
ynh_use_ruby
|
||||
ynh_gem update --system
|
||||
ynh_gem install bundler --no-document
|
||||
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 config set force_ruby_platform true
|
||||
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
|
||||
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 config set force_ruby_platform true
|
||||
ynh_exec_as "$app" "$ynh_ruby_load_path" "$ld_preload" bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
# Building assets
|
||||
ynh_use_nodejs
|
||||
corepack enable
|
||||
yarn install
|
||||
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: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
|
||||
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: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/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt
|
||||
# Create the first admin user
|
||||
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 create "$admin" --email="$admin_mail" --confirmed --role=Owner > /dev/null
|
||||
popd
|
||||
|
||||
# Re-generate config with vapid keys
|
||||
|
@ -178,9 +173,8 @@ yunohost service add "$app-streaming" --description="$app streaming service"
|
|||
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
mkdir -p /var/log/$app
|
||||
chown $app:$app /var/log/$app
|
||||
ynh_use_logrotate
|
||||
chown "$app:$app" "/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -189,9 +183,9 @@ ynh_use_logrotate
|
|||
#=================================================
|
||||
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"
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -11,29 +9,21 @@ source ynh_install_ruby__2
|
|||
source ynh_add_swap
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
# REMOVE SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
|
||||
# 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..." --weight=1
|
||||
if ynh_exec_warn_less yunohost service status "$app-web" >/dev/null; then
|
||||
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..." --weight=1
|
||||
if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null; then
|
||||
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..." --weight=1
|
||||
if ynh_exec_warn_less yunohost service status "$app-streaming" >/dev/null; then
|
||||
yunohost service remove "$app-streaming"
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -13,25 +11,13 @@ source ../settings/scripts/ynh_add_swap
|
|||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STANDARD RESTORATION STEPS
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||
ynh_script_progression --message="Reinstalling Ruby..." --weight=1
|
||||
ynh_exec_warn_less ynh_install_ruby --ruby_version="$ruby_version"
|
||||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
|
||||
|
||||
ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;"
|
||||
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
||||
ynh_script_progression --message="Reinstalling NodeJS..." --weight=1
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version"
|
||||
|
||||
#=================================================
|
||||
# ADD SWAP IF NEEDED
|
||||
|
@ -51,35 +37,39 @@ ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
|||
ynh_add_swap --size=$swap_needed
|
||||
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling Ruby and NodeJS..." --weight=1
|
||||
ynh_script_progression --message="Restoring the app main directory..." --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_restore_file --origin_path="$install_dir"
|
||||
|
||||
ynh_script_progression --message="Installing Yarn dependencies..." --weight=10
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
|
||||
pushd "$install_dir/live"
|
||||
ynh_use_nodejs
|
||||
corepack enable
|
||||
yarn install
|
||||
popd
|
||||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
|
||||
|
||||
ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;"
|
||||
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# BUILD APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building app..." --weight=1
|
||||
ynh_script_progression --message="Rebuilding app..." --weight=1
|
||||
|
||||
pushd "$install_dir/live"
|
||||
ynh_use_ruby
|
||||
ynh_gem update --system
|
||||
ynh_gem install bundler --no-document
|
||||
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle install --redownload -j$(getconf _NPROCESSORS_ONLN)
|
||||
ynh_exec_as "$app" "$ynh_ruby_load_path" "$ld_preload" bin/bundle install --redownload -j"$(nproc)"
|
||||
|
||||
ynh_use_nodejs
|
||||
corepack enable
|
||||
yarn install
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -98,20 +88,18 @@ yunohost service add "$app-streaming" --description="$app streaming service"
|
|||
|
||||
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
||||
|
||||
mkdir -p /var/log/$app
|
||||
chown -R $app:$app /var/log/$app
|
||||
ynh_restore_file --origin_path="/var/log/$app/"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX AND THE APP SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and $app's 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"
|
||||
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"
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
|
|
106
scripts/upgrade
106
scripts/upgrade
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
@ -11,11 +9,8 @@ source ynh_install_ruby__2
|
|||
source ynh_add_swap
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
config="$install_dir/live/.env.production"
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
|
@ -35,9 +30,9 @@ ynh_remove_extra_repo
|
|||
#=================================================
|
||||
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="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"
|
||||
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
|
||||
|
@ -65,28 +60,34 @@ ynh_add_swap --size=$swap_needed
|
|||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading Ruby and NodeJS..." --weight=1
|
||||
|
||||
ynh_script_progression --message="Upgrading Ruby..." --weight=1
|
||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||
|
||||
ynh_script_progression --message="Upgrading NodeJS..." --weight=1
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
|
||||
#=================================================
|
||||
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
# Download Mastodon
|
||||
ynh_setup_source --dest_dir="$install_dir/live" --keep="public/system/"
|
||||
|
||||
# Download Mastodon
|
||||
ynh_setup_source --dest_dir="$install_dir/live" --keep="public/system/"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:www-data "$install_dir"
|
||||
fi
|
||||
#=================================================
|
||||
# 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"
|
||||
|
||||
#=================================================
|
||||
# BUILD ASSETS
|
||||
|
@ -97,19 +98,30 @@ pushd "$install_dir/live"
|
|||
ynh_use_ruby
|
||||
ynh_gem update --system
|
||||
ynh_gem install bundler --no-document
|
||||
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 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_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 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
|
||||
corepack enable
|
||||
yarn install
|
||||
if [ -d "$install_dir/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
|
||||
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
|
||||
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
|
||||
|
||||
#=================================================
|
||||
# APPLY MIGRATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Applying migrations..." --weight=1
|
||||
|
||||
pushd "$install_dir/live"
|
||||
ynh_use_ruby
|
||||
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
|
||||
|
||||
#=================================================
|
||||
|
@ -134,43 +146,17 @@ 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
|
||||
#=================================================
|
||||
ynh_script_progression --message="Applying migrations..." --weight=1
|
||||
|
||||
pushd "$install_dir/live"
|
||||
ynh_use_ruby
|
||||
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
|
||||
chown "$app:$app" "/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||
ynh_script_progression --message="Starting $app's 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"
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
Loading…
Reference in a new issue