use install script

This commit is contained in:
Antonio J. Delgado 2023-11-28 09:20:18 +02:00
parent 96e0408d0d
commit a906ef2f57
2 changed files with 21 additions and 9 deletions

View file

@ -156,16 +156,20 @@ class mastodon (
group => 'mastodon', group => 'mastodon',
require => Vcsrepo['rbenv'], require => Vcsrepo['rbenv'],
} }
file { '/usr/local/bin/install_ruby.sh':
ensure => $ensure,
content => template('mastodon/install_ruby.sh.erb'),
mode => '0750',
owner => 'mastodon',
group => 'root',
require => Vcsrepo['ruby_build'],
}
exec { 'install_ruby': exec { 'install_ruby':
command => "${mastodon_home}/.rbenv/bin/rbenv install 3.2.2", command => '/usr/local/bin/install_ruby.sh',
path => "${mastodon_home}/.rbenv/bin:/usr/sbin:/usr/bin:/sbin:/bin", user => 'mastodon',
environment => [ cwd => "${mastodon_home}/.rbenv/",
'RUBY_CONFIGURE_OPTS=--with-jemalloc', creates => "${mastodon_home}/.rbenv/versions/3.2.2/bin/ruby",
], require => File['/usr/local/bin/install_ruby.sh'],
user => 'mastodon',
cwd => "${mastodon_home}/.rbenv/",
creates => "${mastodon_home}/.rbenv/versions/3.2.2/bin/ruby",
require => Vcsrepo['ruby_build'],
} }
# exec { 'set_global_ruby_version': # exec { 'set_global_ruby_version':
# command => "${mastodon_home}/.rbenv/libexec/rbenv global 3.2.2", # command => "${mastodon_home}/.rbenv/libexec/rbenv global 3.2.2",

View file

@ -0,0 +1,8 @@
#!/bin/bash
set -euo pipefail
su mastodon
if [ ! -e "<%= @mastodon_home %>/.rbenv/versions/3.2.2/bin/ruby" ]; then
cd "<%= @mastodon_home %>"
RUBY_CONFIGURE_OPTS=--with-jemalloc "<%= @mastodon_home %>/.rbenv/bin/rbenv" install 3.2.2
fi