mirror of
https://github.com/YunoHost-Apps/mastodon_ynh.git
synced 2024-09-03 19:46:02 +02:00
RUBY_VERSION factorisation
This commit is contained in:
parent
36ff48ac1d
commit
736d7908b4
7 changed files with 42 additions and 27 deletions
|
@ -1,2 +1,2 @@
|
|||
RAILS_ENV=production
|
||||
@daily cd __FINAL__PATH__/live && /opt/rbenv/versions/2.6.5/bin/bundle exec rake __USER__:media:remove_remote
|
||||
@daily cd __FINAL__PATH__/live && __RBENVROOT__/shims/bundle exec rake __USER__:media:remove_remote
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
Environment="RAILS_ENV=production"
|
||||
Environment="DB_POOL=25"
|
||||
Environment="MALLOC_ARENA_MAX=2"
|
||||
ExecStart=/opt/rbenv/versions/2.6.5/bin/bundle exec sidekiq -c 25
|
||||
ExecStart=__RBENVROOT__/shims/bundle exec sidekiq -c 25
|
||||
TimeoutSec=15
|
||||
Restart=always
|
||||
StandardError=syslog
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
WorkingDirectory=__FINALPATH__/live
|
||||
Environment="RAILS_ENV=production"
|
||||
Environment="PORT=__PORT_WEB__"
|
||||
ExecStart=/opt/rbenv/versions/2.6.5/bin/bundle exec puma -C config/puma.rb
|
||||
ExecStart=__RBENVROOT__/shims/bundle exec puma -C config/puma.rb
|
||||
ExecReload=/bin/kill -SIGUSR1 $MAINPID
|
||||
TimeoutSec=15
|
||||
Restart=always
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
# dependencies used by the app
|
||||
pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3|libgdbm6 libgdbm-dev redis-server redis-tools postgresql postgresql-contrib libidn11-dev libicu-dev libjemalloc-dev curl apt-transport-https"
|
||||
|
||||
RUBY_VERSION="2.6.5"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -20,6 +20,7 @@ source /usr/share/yunohost/helpers
|
|||
ynh_script_progression --message="Managing script failure..." --weight=1
|
||||
|
||||
ynh_clean_setup () {
|
||||
read -p "key"
|
||||
ynh_clean_check_starting
|
||||
}
|
||||
# Exit if an error occurs during the execution of the script
|
||||
|
@ -153,9 +154,11 @@ ynh_add_swap --size=$swap_needed
|
|||
#=================================================
|
||||
ynh_script_progression --message="Installing Ruby..." --weight=424
|
||||
|
||||
ynh_install_ruby --ruby_version=2.6.5
|
||||
/opt/rbenv/versions/2.6.5/bin/gem update --system
|
||||
/opt/rbenv/versions/2.6.5/bin/gem install bundler:1.17.3 --no-document
|
||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||
pushd "$final_path/live"
|
||||
gem update --system
|
||||
gem install bundler:1.17.3 --no-document
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
|
@ -194,13 +197,13 @@ chown -R "$app": "$final_path"
|
|||
|
||||
pushd "$final_path/live"
|
||||
ynh_use_nodejs
|
||||
sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.5/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test
|
||||
sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile
|
||||
sudo -u "$app" echo "SAFETY_ASSURED=1">> $config
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.5/bin/bundle exec rails db:setup --quiet
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.5/bin/bundle exec rails assets:precompile --quiet
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.5/bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > acc.txt
|
||||
bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test
|
||||
yarn install --pure-lockfile
|
||||
echo "SAFETY_ASSURED=1">> $config
|
||||
RAILS_ENV=production bundle exec rails db:setup --quiet
|
||||
RAILS_ENV=production bundle exec rails assets:precompile --quiet
|
||||
RAILS_ENV=production bundle exec rake mastodon:webpush:generate_vapid_key > key.txt
|
||||
RAILS_ENV=production bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > acc.txt
|
||||
popd
|
||||
|
||||
admin_pass=$( tail -1 $final_path/live/acc.txt | head -1 | cut -c 15- )
|
||||
|
@ -224,7 +227,8 @@ ynh_script_progression --message="Setuping a cron job for removing cache..." --w
|
|||
|
||||
ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron"
|
||||
ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/cron"
|
||||
sudo cp -f ../conf/cron /etc/cron.d/$app
|
||||
ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/cron"
|
||||
cp -f ../conf/cron /etc/cron.d/$app
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
|
@ -233,6 +237,8 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=5
|
|||
|
||||
# Create a dedicated systemd config
|
||||
ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service"
|
||||
ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/mastodon-web.service"
|
||||
ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/mastodon-sidekiq.service"
|
||||
ynh_replace_string --match_string="__PORT_STREAM__" --replace_string="$port_stream" --target_file="../conf/mastodon-streaming.service"
|
||||
ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/mastodon-streaming.service"
|
||||
ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service"
|
||||
|
|
|
@ -114,9 +114,11 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st
|
|||
#=================================================
|
||||
ynh_script_progression --message="Installing Ruby..." --weight=393
|
||||
|
||||
ynh_install_ruby --ruby_version=2.6.5
|
||||
/opt/rbenv/versions/2.6.5/bin/gem update --system
|
||||
/opt/rbenv/versions/2.6.5/bin/gem install bundler:1.17.3 --no-document
|
||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||
pushd "$final_path/live"
|
||||
gem update --system
|
||||
gem install bundler:1.17.3 --no-document
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
|
|
|
@ -249,9 +249,11 @@ ynh_add_swap --size=$swap_needed
|
|||
#=================================================
|
||||
ynh_script_progression --message="Installing Ruby..." --weight=424
|
||||
|
||||
ynh_install_ruby --ruby_version=2.6.5
|
||||
/opt/rbenv/versions/2.6.5/bin/gem update --system
|
||||
/opt/rbenv/versions/2.6.5/bin/gem install bundler:1.17.3 --no-document
|
||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||
pushd "$final_path/live"
|
||||
gem update --system
|
||||
gem install bundler:1.17.3 --no-document
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
|
@ -287,12 +289,12 @@ chown -R "$app": "$final_path"
|
|||
|
||||
pushd "$final_path/live"
|
||||
ynh_use_nodejs
|
||||
sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.5/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test
|
||||
sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.5/bin/bundle exec rails assets:clean
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.5/bin/bundle exec rails assets:precompile
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.5/bin/bundle exec rails db:migrate
|
||||
sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl cache clear
|
||||
bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test
|
||||
yarn install --pure-lockfile
|
||||
RAILS_ENV=production bundle exec rails assets:clean
|
||||
RAILS_ENV=production bundle exec rails assets:precompile
|
||||
RAILS_ENV=production bundle exec rails db:migrate
|
||||
RAILS_ENV=production bin/tootctl cache clear
|
||||
popd
|
||||
|
||||
# Recalculate and store the checksum of the file for the next upgrade.
|
||||
|
@ -305,7 +307,8 @@ ynh_script_progression --message="Setuping a cron job for removing cache..." --w
|
|||
|
||||
ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron"
|
||||
ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/cron"
|
||||
sudo cp -f ../conf/cron /etc/cron.d/$app
|
||||
ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/cron"
|
||||
cp -f ../conf/cron /etc/cron.d/$app
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
|
@ -314,6 +317,8 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
|||
|
||||
# Create a dedicated systemd config
|
||||
ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service"
|
||||
ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/mastodon-web.service"
|
||||
ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/mastodon-sidekiq.service"
|
||||
ynh_replace_string --match_string="__PORT_STREAM__" --replace_string="$port_stream" --target_file="../conf/mastodon-streaming.service"
|
||||
ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/mastodon-streaming.service"
|
||||
ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service"
|
||||
|
|
Loading…
Reference in a new issue