aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf/cron2
-rw-r--r--conf/mastodon-sidekiq.service2
-rw-r--r--conf/mastodon-web.service2
-rw-r--r--scripts/_common.sh2
-rw-r--r--scripts/install28
-rw-r--r--scripts/restore8
-rw-r--r--scripts/upgrade25
7 files changed, 42 insertions, 27 deletions
diff --git a/conf/cron b/conf/cron
index 9a984a3..8bf7bdb 100644
--- a/conf/cron
+++ b/conf/cron
@@ -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
diff --git a/conf/mastodon-sidekiq.service b/conf/mastodon-sidekiq.service
index d5fc7e1..73f29e5 100644
--- a/conf/mastodon-sidekiq.service
+++ b/conf/mastodon-sidekiq.service
@@ -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
diff --git a/conf/mastodon-web.service b/conf/mastodon-web.service
index bb65afe..14d1260 100644
--- a/conf/mastodon-web.service
+++ b/conf/mastodon-web.service
@@ -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
diff --git a/scripts/_common.sh b/scripts/_common.sh
index 015c1e9..f39b966 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -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
#=================================================
diff --git a/scripts/install b/scripts/install
index 409911b..2e218c6 100644
--- a/scripts/install
+++ b/scripts/install
@@ -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"
diff --git a/scripts/restore b/scripts/restore
index c6e4bc8..bd79e95 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -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
diff --git a/scripts/upgrade b/scripts/upgrade
index 98d0403..f34010b 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -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"