mirror of
https://github.com/YunoHost-Apps/glitchsoc_ynh.git
synced 2024-09-03 19:15:59 +02:00
be closer to example_ynh
This commit is contained in:
parent
486cdc5716
commit
abb5755829
8 changed files with 143 additions and 351 deletions
|
@ -254,31 +254,31 @@ LDAP_TLS_NO_VERIFY=true
|
||||||
# ---------------
|
# ---------------
|
||||||
|
|
||||||
# Maximum allowed character count
|
# Maximum allowed character count
|
||||||
MAX_TOOT_CHARS=__MAX_TOOT_CHARS__
|
MAX_TOOT_CHARS=500
|
||||||
|
|
||||||
# Maximum number of pinned posts
|
# Maximum number of pinned posts
|
||||||
MAX_PINNED_TOOTS=__MAX_PINNED_TOOTS__
|
MAX_PINNED_TOOTS=5
|
||||||
|
|
||||||
# Maximum allowed bio characters
|
# Maximum allowed bio characters
|
||||||
MAX_BIO_CHARS=__MAX_BIO_CHARS__
|
MAX_BIO_CHARS=500
|
||||||
|
|
||||||
# Maximim number of profile fields allowed
|
# Maximim number of profile fields allowed
|
||||||
MAX_PROFILE_FIELDS=__MAX_PROFILE_FIELDS__
|
MAX_PROFILE_FIELDS=4
|
||||||
|
|
||||||
# Maximum allowed display name characters
|
# Maximum allowed display name characters
|
||||||
MAX_DISPLAY_NAME_CHARS=__MAX_DISPLAY_NAME_CHARS__
|
MAX_DISPLAY_NAME_CHARS=30
|
||||||
|
|
||||||
# Maximum allowed poll options
|
# Maximum allowed poll options
|
||||||
MAX_POLL_OPTIONS=__MAX_POLL_OPTIONS__
|
MAX_POLL_OPTIONS=5
|
||||||
|
|
||||||
# Maximum allowed poll option characters
|
# Maximum allowed poll option characters
|
||||||
MAX_POLL_OPTION_CHARS=__MAX_POLL_OPTION_CHARS__
|
MAX_POLL_OPTION_CHARS=100
|
||||||
|
|
||||||
# Maximum image and video/audio upload sizes
|
# Maximum image and video/audio upload sizes
|
||||||
# Units are in bytes
|
# Units are in bytes
|
||||||
# 1048576 bytes equals 1 megabyte
|
# 1048576 bytes equals 1 megabyte
|
||||||
MAX_IMAGE_SIZE=__MAX_IMAGE_SIZE__
|
MAX_IMAGE_SIZE=8388608
|
||||||
MAX_VIDEO_SIZE=__MAX_VIDEO_SIZE__
|
MAX_VIDEO_SIZE=41943040
|
||||||
|
|
||||||
# Maximum search results to display
|
# Maximum search results to display
|
||||||
# Only relevant when elasticsearch is installed
|
# Only relevant when elasticsearch is installed
|
||||||
|
@ -288,5 +288,5 @@ MAX_VIDEO_SIZE=__MAX_VIDEO_SIZE__
|
||||||
# If undefined or smaller than MAX_EMOJI_SIZE, the value
|
# If undefined or smaller than MAX_EMOJI_SIZE, the value
|
||||||
# of MAX_EMOJI_SIZE will be used for MAX_REMOTE_EMOJI_SIZE
|
# of MAX_EMOJI_SIZE will be used for MAX_REMOTE_EMOJI_SIZE
|
||||||
# Units are in bytes
|
# Units are in bytes
|
||||||
MAX_EMOJI_SIZE=__MAX_EMOJI_SIZE__
|
MAX_EMOJI_SIZE=51200
|
||||||
MAX_REMOTE_EMOJI_SIZE=__MAX_REMOTE_EMOJI_SIZE__
|
MAX_REMOTE_EMOJI_SIZE=204800
|
||||||
|
|
164
scripts/install
164
scripts/install
|
@ -9,44 +9,8 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE SETTINGS
|
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
|
||||||
#=================================================
|
|
||||||
|
|
||||||
admin_mail=$(ynh_user_get_info $admin 'mail')
|
|
||||||
max_toot_chars="500"
|
|
||||||
max_pinned_toots="5"
|
|
||||||
max_bio_chars="500"
|
|
||||||
max_profile_fields="4"
|
|
||||||
max_display_name_chars="30"
|
|
||||||
max_poll_options="5"
|
|
||||||
max_poll_option_chars="100"
|
|
||||||
max_image_size="8388608"
|
|
||||||
max_video_size="41943040"
|
|
||||||
max_emoji_size="51200"
|
|
||||||
max_remote_emoji_size="204800"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STORE SETTINGS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Storing settings..." --weight=1
|
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=language --value=$language
|
|
||||||
ynh_app_setting_set --app=$app --key=max_toot_chars --value=$max_toot_chars
|
|
||||||
ynh_app_setting_set --app=$app --key=max_pinned_toots --value=$max_pinned_toots
|
|
||||||
ynh_app_setting_set --app=$app --key=max_bio_chars --value=$max_bio_chars
|
|
||||||
ynh_app_setting_set --app=$app --key=max_profile_fields --value=$max_profile_fields
|
|
||||||
ynh_app_setting_set --app=$app --key=max_display_name_chars --value=$max_display_name_chars
|
|
||||||
ynh_app_setting_set --app=$app --key=max_poll_options --value=$max_poll_options
|
|
||||||
ynh_app_setting_set --app=$app --key=max_poll_option_chars --value=$max_poll_option_chars
|
|
||||||
ynh_app_setting_set --app=$app --key=max_image_size --value=$max_image_size
|
|
||||||
ynh_app_setting_set --app=$app --key=max_video_size --value=$max_video_size
|
|
||||||
ynh_app_setting_set --app=$app --key=max_emoji_size --value=$max_emoji_size
|
|
||||||
ynh_app_setting_set --app=$app --key=max_remote_emoji_size --value=$max_remote_emoji_size
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD MODIFICATIONS
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -65,35 +29,19 @@ ynh_setup_source --dest_dir="$install_dir/live"
|
||||||
|
|
||||||
chown -R $app:www-data "$install_dir"
|
chown -R $app:www-data "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
# Add swap if needed
|
||||||
# NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
|
||||||
|
|
||||||
# Create a dedicated NGINX config
|
|
||||||
ynh_add_nginx_config
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC SETUP
|
|
||||||
#=================================================
|
|
||||||
# ADD SWAP IF NEEDED
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Adding swap if needed..." --weight=1
|
|
||||||
|
|
||||||
total_memory=$(ynh_get_ram --total)
|
total_memory=$(ynh_get_ram --total)
|
||||||
swap_needed=0
|
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
|
# Need a minimum of 2.5Go of memory
|
||||||
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
||||||
|
|
||||||
|
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
||||||
|
ynh_add_swap --size=$swap_needed
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
# Installing Ruby and Bundler
|
||||||
ynh_add_swap --size=$swap_needed
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INSTALLING RUBY AND BUNDLER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Installing Ruby dependencies..." --weight=3
|
ynh_script_progression --message="Installing Ruby dependencies..." --weight=3
|
||||||
|
|
||||||
pushd "$install_dir/live"
|
pushd "$install_dir/live"
|
||||||
|
@ -102,6 +50,41 @@ pushd "$install_dir/live"
|
||||||
ynh_gem install bundler --no-document
|
ynh_gem install bundler --no-document
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
# Installing Glitch-Soc
|
||||||
|
ynh_script_progression --message="Installing Glitch-Soc..." --weight=5
|
||||||
|
|
||||||
|
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
|
||||||
|
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: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
|
||||||
|
popd
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SYSTEM CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated NGINX config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
# Create a dedicated systemd config
|
||||||
|
ynh_add_systemd_config --service="$app-web" --template="web.service"
|
||||||
|
ynh_add_systemd_config --service="$app-sidekiq" --template="sidekiq.service"
|
||||||
|
ynh_add_systemd_config --service="$app-streaming" --template="streaming.service"
|
||||||
|
|
||||||
|
yunohost service add "$app-web" --description="$app web service"
|
||||||
|
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
||||||
|
yunohost service add "$app-streaming" --description="$app streaming service"
|
||||||
|
|
||||||
|
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# APP INITIAL CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD A CONFIGURATION
|
# ADD A CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -120,15 +103,22 @@ ynh_app_setting_set --app="$app" --key=secret_key_base --value="$secret_key_base
|
||||||
otp_secret=$(ynh_string_random --length=128)
|
otp_secret=$(ynh_string_random --length=128)
|
||||||
ynh_app_setting_set --app="$app" --key=otp_secret --value="$otp_secret"
|
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
|
# Generate vapid keys
|
||||||
vapid_private_key=""
|
pushd "$install_dir/live"
|
||||||
vapid_public_key=""
|
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
|
||||||
|
popd
|
||||||
|
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"
|
||||||
|
ynh_secure_remove --file="$install_dir/live/key.txt"
|
||||||
|
|
||||||
ynh_add_config --template="../conf/.env.production.sample" --destination="$config"
|
ynh_add_config --template="../conf/.env.production.sample" --destination="$config"
|
||||||
|
|
||||||
chmod 400 "$config"
|
chmod 400 "$config"
|
||||||
chown $app:$app "$config"
|
chown $app:$app "$config"
|
||||||
|
|
||||||
|
# Disable registration and invites
|
||||||
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="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"
|
ynh_replace_string --match_string="min_invite_role: 'admin'" --replace_string="min_invite_role: 'none'" --target_file="$install_dir/live/config/settings.yml"
|
||||||
|
|
||||||
|
@ -138,65 +128,17 @@ 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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP ADMIN USER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
ynh_script_progression --message="Creating admin user..." --weight=1
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
|
||||||
ynh_add_systemd_config --service="$app-web" --template="glitchsoc-web.service"
|
|
||||||
ynh_add_systemd_config --service="$app-sidekiq" --template="glitchsoc-sidekiq.service"
|
|
||||||
ynh_add_systemd_config --service="$app-streaming" --template="glitchsoc-streaming.service"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INSTALLING GLITCH-SOC
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Installing Glitch-Soc..." --weight=5
|
|
||||||
|
|
||||||
pushd "$install_dir/live"
|
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
|
|
||||||
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: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 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
|
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/tootctl accounts modify "$admin" --approve
|
||||||
popd
|
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"
|
|
||||||
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"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP THE CRON FILE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Setuping the cron file..." --weight=1
|
|
||||||
|
|
||||||
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
|
||||||
|
|
||||||
yunohost service add "$app-web" --description="$app web service"
|
|
||||||
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
|
||||||
yunohost service add "$app-streaming" --description="$app streaming service"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -10,10 +10,11 @@ source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# REMOVE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
# 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`)
|
# 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
|
if ynh_exec_warn_less yunohost service status "$app-web" >/dev/null
|
||||||
|
@ -34,52 +35,24 @@ then
|
||||||
yunohost service remove "$app-streaming"
|
yunohost service remove "$app-streaming"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STOP AND REMOVE SERVICE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
|
|
||||||
|
|
||||||
# Remove the dedicated systemd config
|
# Remove the dedicated systemd config
|
||||||
ynh_remove_systemd_config --service="$app-web"
|
ynh_remove_systemd_config --service="$app-web"
|
||||||
ynh_remove_systemd_config --service="$app-sidekiq"
|
ynh_remove_systemd_config --service="$app-sidekiq"
|
||||||
ynh_remove_systemd_config --service="$app-streaming"
|
ynh_remove_systemd_config --service="$app-streaming"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
|
||||||
|
|
||||||
# Remove the dedicated NGINX config
|
# Remove the dedicated NGINX config
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
|
|
||||||
#=================================================
|
# Remove Ruby and NodeJS
|
||||||
# REMOVE DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing Ruby and NodeJS..." --weight=10
|
|
||||||
|
|
||||||
ynh_remove_ruby
|
ynh_remove_ruby
|
||||||
ynh_remove_nodejs
|
ynh_remove_nodejs
|
||||||
|
|
||||||
#=================================================
|
# Remove other various files specific to the app... such as :
|
||||||
# SPECIFIC REMOVE
|
|
||||||
#=================================================
|
|
||||||
# REMOVE VARIOUS FILES
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing various files..." --weight=1
|
|
||||||
|
|
||||||
# Remove a cron file
|
|
||||||
ynh_secure_remove --file="/etc/cron.d/$app"
|
ynh_secure_remove --file="/etc/cron.d/$app"
|
||||||
|
|
||||||
# Remove swap
|
# Remove swap
|
||||||
ynh_del_swap
|
ynh_del_swap
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
# ...
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -10,15 +10,6 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STANDARD RESTORATION STEPS
|
|
||||||
#=================================================
|
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
|
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -31,9 +22,7 @@ chmod -R o-rwx "$install_dir"
|
||||||
chown -R $app:www-data "$install_dir"
|
chown -R $app:www-data "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# REINSTALL RUBY
|
||||||
#=================================================
|
|
||||||
# REINSTALL DEPENDENCIES
|
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstalling Ruby and NodeJS..." --weight=10
|
ynh_script_progression --message="Reinstalling Ruby and NodeJS..." --weight=10
|
||||||
|
|
||||||
|
@ -48,26 +37,22 @@ ynh_script_progression --message="Restoring the PostgreSQL database..." --weight
|
||||||
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD SWAP IF NEEDED
|
# INSTALLING RUBY AND BUNDLER
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Adding swap if needed..." --weight=1
|
ynh_script_progression --message="Installing Ruby dependencies..." --weight=10
|
||||||
|
|
||||||
|
# Add swap if needed
|
||||||
total_memory=$(ynh_get_ram --total)
|
total_memory=$(ynh_get_ram --total)
|
||||||
swap_needed=0
|
swap_needed=0
|
||||||
|
|
||||||
if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
||||||
# Need a minimum of 8Go of memory
|
# Need a minimum of 8Go of memory
|
||||||
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
||||||
|
|
||||||
|
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
||||||
|
ynh_add_swap --size=$swap_needed
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
|
||||||
ynh_add_swap --size=$swap_needed
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INSTALLING RUBY AND BUNDLER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Installing Ruby dependencies..." --weight=10
|
|
||||||
|
|
||||||
pushd "$install_dir/live"
|
pushd "$install_dir/live"
|
||||||
ynh_use_ruby
|
ynh_use_ruby
|
||||||
ynh_gem update --system --no-document
|
ynh_gem update --system --no-document
|
||||||
|
@ -75,46 +60,36 @@ pushd "$install_dir/live"
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE VARIOUS FILES
|
# RESTORE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring various files..." --weight=1
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE SYSTEMD
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
|
||||||
|
|
||||||
|
# Restore systemd services
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service"
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service"
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-streaming.service"
|
ynh_restore_file --origin_path="/etc/systemd/system/$app-streaming.service"
|
||||||
systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" --quiet
|
systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" --quiet
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
|
||||||
|
|
||||||
yunohost service add "$app-web" --description="$app web service"
|
yunohost service add "$app-web" --description="$app web service"
|
||||||
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
||||||
yunohost service add "$app-streaming" --description="$app streaming service"
|
yunohost service add "$app-streaming" --description="$app streaming service"
|
||||||
|
|
||||||
#=================================================
|
# Other various files...
|
||||||
# START SYSTEMD SERVICE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on"
|
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
||||||
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"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
ynh_script_progression --message="Starting $app's service and reloading NGINX..." --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on"
|
||||||
|
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded"
|
||||||
|
ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=systemd --line_match="Worker 1 now listening"
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
|
208
scripts/upgrade
208
scripts/upgrade
|
@ -9,32 +9,12 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Loading settings..." --weight=1
|
|
||||||
|
|
||||||
admin_mail=$(ynh_user_get_info --username=$admin --key='mail')
|
admin_mail=$(ynh_user_get_info --username=$admin --key='mail')
|
||||||
config="$install_dir/live/.env.production"
|
config="$install_dir/live/.env.production"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK VERSION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Checking version..." --weight=1
|
|
||||||
|
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
#=================================================
|
|
||||||
# STOP SYSTEMD SERVICE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=${app}-web --action="stop" --log_path=systemd --line_match="Stopped"
|
|
||||||
ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=systemd --line_match="Stopped"
|
|
||||||
ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=systemd --line_match="Stopped"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENSURE DOWNWARD COMPATIBILITY
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -75,149 +55,57 @@ if [[ -z "$redis_namespace" ]]; then
|
||||||
ynh_app_setting_set --app=$app --key=redis_namespace --value=$redis_namespace
|
ynh_app_setting_set --app=$app --key=redis_namespace --value=$redis_namespace
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$max_toot_chars" ]; then
|
#=================================================
|
||||||
max_toot_chars="500"
|
# STOP SYSTEMD SERVICE
|
||||||
ynh_app_setting_set --app=$app --key=max_toot_chars --value=$max_toot_chars
|
#=================================================
|
||||||
fi
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
||||||
|
|
||||||
if [ -z "$max_pinned_toots" ]; then
|
ynh_systemd_action --service_name=${app}-web --action="stop" --log_path=systemd --line_match="Stopped"
|
||||||
max_pinned_toots="5"
|
ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=systemd --line_match="Stopped"
|
||||||
ynh_app_setting_set --app=$app --key=max_pinned_toots --value=$max_pinned_toots
|
ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=systemd --line_match="Stopped"
|
||||||
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
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...)
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
|
# Add swap if needed
|
||||||
|
total_memory=$(ynh_get_ram --total)
|
||||||
|
swap_needed=0
|
||||||
|
|
||||||
|
if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
||||||
|
# Need a minimum of 2.5Go of memory
|
||||||
|
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
||||||
|
|
||||||
|
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
|
||||||
|
ynh_add_swap --size=$swap_needed
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update Glitch-Soc
|
||||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||||
|
|
||||||
# Download Glitch-Soc
|
|
||||||
ynh_setup_source --dest_dir="$install_dir/live" --keep="public/system/"
|
ynh_setup_source --dest_dir="$install_dir/live" --keep="public/system/"
|
||||||
|
|
||||||
chmod 750 "$install_dir"
|
chmod 750 "$install_dir"
|
||||||
chmod -R o-rwx "$install_dir"
|
chmod -R o-rwx "$install_dir"
|
||||||
chown -R $app:www-data "$install_dir"
|
chown -R $app:www-data "$install_dir"
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
# Update Ruby and NodeJS
|
||||||
# NGINX CONFIGURATION
|
ynh_script_progression --message="Upgrading Ruby and NodeJS..." --weight=10
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
|
||||||
|
|
||||||
# Create a dedicated NGINX config
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
||||||
ynh_add_nginx_config
|
ynh_exec_warn_less ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||||
|
|
||||||
#=================================================
|
pushd "$install_dir/live"
|
||||||
# UPGRADE DEPENDENCIES
|
ynh_use_ruby
|
||||||
#=================================================
|
ynh_gem update --system --no-document
|
||||||
ynh_script_progression --message="Upgrading Ruby and NodeJS..." --weight=10
|
ynh_gem install bundler --no-document
|
||||||
|
popd
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
# Perform upgrade actions on Glitch-Soc
|
||||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=$RUBY_VERSION
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC UPGRADE
|
|
||||||
#=================================================
|
|
||||||
# ADD SWAP IF NEEDED
|
|
||||||
#=================================================
|
|
||||||
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
|
|
||||||
# Need a minimum of 8Go of 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 AND BUNDLER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Installing Ruby dependencies..." --weight=5
|
|
||||||
|
|
||||||
pushd "$install_dir/live"
|
|
||||||
ynh_use_ruby
|
|
||||||
ynh_gem update --system --no-document
|
|
||||||
ynh_gem install bundler --no-document
|
|
||||||
popd
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# UPDATE A CONFIG FILE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Updating a config file..." --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"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP SYSTEMD
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
|
||||||
ynh_add_systemd_config --service="$app-web" --template="glitchsoc-web.service"
|
|
||||||
ynh_add_systemd_config --service="$app-sidekiq" --template="glitchsoc-sidekiq.service"
|
|
||||||
ynh_add_systemd_config --service="$app-streaming" --template="glitchsoc-streaming.service"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# UPGRADE GLITCH-SOC
|
|
||||||
#=================================================
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
||||||
then
|
|
||||||
ynh_script_progression --message="Upgrading Glitch-Soc..." --weight=10
|
ynh_script_progression --message="Upgrading Glitch-Soc..." --weight=10
|
||||||
|
|
||||||
pushd "$install_dir/live"
|
pushd "$install_dir/live"
|
||||||
|
@ -234,23 +122,37 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP THE CRON FILE
|
# REAPPLY SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setuping the cron file..." --weight=1
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||||
|
|
||||||
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
ynh_add_systemd_config --service="$app-web" --template="web.service"
|
||||||
# GENERIC FINALIZATION
|
ynh_add_systemd_config --service="$app-sidekiq" --template="sidekiq.service"
|
||||||
#=================================================
|
ynh_add_systemd_config --service="$app-streaming" --template="streaming.service"
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
|
||||||
|
|
||||||
yunohost service add "$app-web" --description="$app web service"
|
yunohost service add "$app-web" --description="$app web service"
|
||||||
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
yunohost service add "$app-sidekiq" --description="$app sidekiq service"
|
||||||
yunohost service add "$app-streaming" --description="$app streaming service"
|
yunohost service add "$app-streaming" --description="$app streaming service"
|
||||||
|
|
||||||
|
ynh_add_systemd_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...)
|
||||||
|
#=================================================
|
||||||
|
# UPDATE A CONFIG FILE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Updating a configuration 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"
|
||||||
|
|
||||||
|
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue