mirror of
https://github.com/YunoHost-Apps/discourse_ynh.git
synced 2024-09-03 18:26:18 +02:00
Use Ruby 2.6.0 and adapt upgrade script
This commit is contained in:
parent
a78a2498b9
commit
9e9a33cc85
3 changed files with 69 additions and 18 deletions
|
@ -4,7 +4,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
pkg_dependencies="libjemalloc1 libjemalloc-dev zlib1g-dev libreadline-dev libpq-dev libssl-dev libyaml-dev libcurl4-openssl-dev libapr1-dev libxslt1-dev checkinstall libxml2-dev vim imagemagick postgresql postgresql-server-dev-all postgresql-contrib optipng jhead jpegoptim gifsicle"
|
pkg_dependencies="libjemalloc1 libjemalloc-dev zlib1g-dev libreadline-dev libpq-dev libssl-dev libyaml-dev libcurl4-openssl-dev libapr1-dev libxslt1-dev checkinstall libxml2-dev vim imagemagick postgresql postgresql-server-dev-all postgresql-contrib optipng jhead jpegoptim gifsicle"
|
||||||
RUBY_VERSION="2.4.4"
|
RUBY_VERSION="2.6.0"
|
||||||
|
|
||||||
# Execute a command as another user with login
|
# Execute a command as another user with login
|
||||||
# (hence in user home dir, with prior loading of .profile, etc.)
|
# (hence in user home dir, with prior loading of .profile, etc.)
|
||||||
|
@ -339,13 +339,6 @@ SOURCE_SUM=41f1a60714c55eceb21d692a469aee1ec4f46bba351d0dfcb0c660ff9cf1a1c9" > "
|
||||||
# Download and extract rbenv
|
# Download and extract rbenv
|
||||||
ynh_setup_source "$rbenv_install_dir" rbenv
|
ynh_setup_source "$rbenv_install_dir" rbenv
|
||||||
|
|
||||||
# Build an app.src for ruby-build
|
|
||||||
mkdir -p "../conf"
|
|
||||||
echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20180329.tar.gz
|
|
||||||
SOURCE_SUM=4c8610c178ef2fa6bb29d4bcfca52608914632a51a56a5e70aeec8bf0894167b" > "../conf/ruby-build.src"
|
|
||||||
# Download and extract ruby-build
|
|
||||||
ynh_setup_source "$rbenv_install_dir/plugins/ruby-build" ruby-build
|
|
||||||
|
|
||||||
(cd $rbenv_install_dir
|
(cd $rbenv_install_dir
|
||||||
./src/configure && make -C src)
|
./src/configure && make -C src)
|
||||||
|
|
||||||
|
@ -396,6 +389,16 @@ ynh_install_ruby () {
|
||||||
ynh_install_rbenv
|
ynh_install_rbenv
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Download ruby-build (replace if already exists)
|
||||||
|
if [ -d $rbenv_install_dir/plugins/ruby-build ]; then
|
||||||
|
rm -Rf $rbenv_install_dir/plugins/ruby-build
|
||||||
|
fi
|
||||||
|
# Build an app.src for ruby-build
|
||||||
|
mkdir -p "../conf"
|
||||||
|
echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20181225.tar.gz
|
||||||
|
SOURCE_SUM=5ace4787ace47384dc419b20f5eb5a59f1174e00bfabcfed74a175033cd0b18a" > "../conf/ruby-build.src"
|
||||||
|
# Download and extract ruby-build
|
||||||
|
ynh_setup_source "$rbenv_install_dir/plugins/ruby-build" ruby-build
|
||||||
# Restore /usr/local/bin in PATH (if needed)
|
# Restore /usr/local/bin in PATH (if needed)
|
||||||
PATH=$CLEAR_PATH
|
PATH=$CLEAR_PATH
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,7 @@ y
|
||||||
# Patch ldap-auth plugin dependency (omniauth-ldap) to fix it when using domain subfolder
|
# Patch ldap-auth plugin dependency (omniauth-ldap) to fix it when using domain subfolder
|
||||||
# (Can only do that now because we are patching dependencies which have just been downloaded)
|
# (Can only do that now because we are patching dependencies which have just been downloaded)
|
||||||
# Patch applied: https://github.com/omniauth/omniauth-ldap/pull/16
|
# Patch applied: https://github.com/omniauth/omniauth-ldap/pull/16
|
||||||
(cd $final_path/plugins/discourse-ldap-auth/gems/*/gems/omniauth-ldap*/
|
(cd $final_path/plugins/discourse-ldap-auth/gems/${RUBY_VERSION}/gems/omniauth-ldap*/
|
||||||
patch -p1 < $YNH_CWD/../conf/ldap-auth-fix-subfolder.patch)
|
patch -p1 < $YNH_CWD/../conf/ldap-auth-fix-subfolder.patch)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -66,12 +66,6 @@ fi
|
||||||
|
|
||||||
ynh_install_app_dependencies "$pkg_dependencies"
|
ynh_install_app_dependencies "$pkg_dependencies"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INSTALL RUBY
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_install_ruby $RUBY_VERSION
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -99,12 +93,42 @@ if ! ynh_is_upstream_up_to_date ; then
|
||||||
cp ../sources/patches_arm/* ../sources/patches
|
cp ../sources/patches_arm/* ../sources/patches
|
||||||
fi
|
fi
|
||||||
ynh_app_setting_set $app final_path $final_path
|
ynh_app_setting_set $app final_path $final_path
|
||||||
|
# Backup files to keep
|
||||||
|
tmpdir=$(mktemp -d)
|
||||||
|
cp -Rp $final_path/public/uploads $final_path/plugins $final_path/config/discourse.conf $tmpdir
|
||||||
|
if [ -d $final_path/public/backups ] ; then
|
||||||
|
cp -Rp $final_path/public/backups $tmpdir
|
||||||
|
fi
|
||||||
|
if [ -d $final_path/log ] ; then
|
||||||
|
cp -Rp $final_path/log $tmpdir
|
||||||
|
fi
|
||||||
|
# Remove destination directory
|
||||||
|
ynh_secure_remove $final_path
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
ynh_setup_source "$final_path"
|
ynh_setup_source "$final_path"
|
||||||
|
# Restore previous files
|
||||||
|
cp -Rp $tmpdir/uploads $final_path/public
|
||||||
|
if [ -d $tmpdir/backups ] ; then
|
||||||
|
cp -Rp $tmpdir/backups $final_path/public
|
||||||
|
fi
|
||||||
|
if [ -d $tmpdir/log ] ; then
|
||||||
|
cp -Rp $tmpdir/log $final_path
|
||||||
|
fi
|
||||||
|
cp -Rp $tmpdir/plugins/* $final_path/plugins
|
||||||
|
cp -Rp $tmpdir/log $final_path
|
||||||
|
cp -p $tmpdir/discourse.conf $final_path/config
|
||||||
|
|
||||||
# Install LDAP plugin
|
# Install LDAP plugin
|
||||||
|
ynh_secure_remove "$final_path/plugins/discourse-ldap-auth"
|
||||||
mkdir -p "$final_path/plugins/discourse-ldap-auth"
|
mkdir -p "$final_path/plugins/discourse-ldap-auth"
|
||||||
ynh_setup_source "$final_path/plugins/discourse-ldap-auth" ldap-auth
|
ynh_setup_source "$final_path/plugins/discourse-ldap-auth" ldap-auth
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INSTALL RUBY
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_install_ruby $RUBY_VERSION
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -149,6 +173,7 @@ if ! ynh_is_upstream_up_to_date ; then
|
||||||
|
|
||||||
# Make a backup of the original config file if modified
|
# Make a backup of the original config file if modified
|
||||||
ynh_backup_if_checksum_is_different "$final_path/plugins/discourse-ldap-auth/config/settings.yml"
|
ynh_backup_if_checksum_is_different "$final_path/plugins/discourse-ldap-auth/config/settings.yml"
|
||||||
|
|
||||||
# Configure LDAP plugin
|
# Configure LDAP plugin
|
||||||
ldap_config_file="$final_path/plugins/discourse-ldap-auth/config/settings.yml"
|
ldap_config_file="$final_path/plugins/discourse-ldap-auth/config/settings.yml"
|
||||||
ynh_replace_string "adfs.example.com" "localhost" "$ldap_config_file"
|
ynh_replace_string "adfs.example.com" "localhost" "$ldap_config_file"
|
||||||
|
@ -156,6 +181,9 @@ if ! ynh_is_upstream_up_to_date ; then
|
||||||
ynh_replace_string "sAMAccountName" "uid" "$ldap_config_file"
|
ynh_replace_string "sAMAccountName" "uid" "$ldap_config_file"
|
||||||
ynh_store_file_checksum "$ldap_config_file"
|
ynh_store_file_checksum "$ldap_config_file"
|
||||||
|
|
||||||
|
# Disable svgo worker
|
||||||
|
echo "svgo: false" > $final_path/.image_optim.yml
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP UNICORN, A RUBY SERVER
|
# SETUP UNICORN, A RUBY SERVER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -176,14 +204,20 @@ if ! ynh_is_upstream_up_to_date ; then
|
||||||
chown -R $app: $final_path
|
chown -R $app: $final_path
|
||||||
|
|
||||||
|
|
||||||
# Install puma with gem
|
|
||||||
(cd "$final_path"
|
(cd "$final_path"
|
||||||
# Install bundler, a gems installer
|
# Install bundler, a gems installer
|
||||||
gem install bundler
|
gem install bundler
|
||||||
# Install without documentation
|
# Install without documentation
|
||||||
exec_as $app echo "gem: --no-ri --no-rdoc" >> "$final_path/.gemrc"
|
exec_as $app echo "gem: --no-ri --no-rdoc" >> "$final_path/.gemrc")
|
||||||
|
# Specific actions on ARM architecture
|
||||||
|
if [ -n "$(uname -m | grep arm)" ] ; then
|
||||||
|
# Define the platform specifically to retrieve binaries
|
||||||
|
# for libv8 because it currently doesn't compile on ARM devices
|
||||||
|
exec_login_as $app bundle config specific_platform arm-linux
|
||||||
|
fi
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
exec_login_as $app bundle install --path vendor/bundle --with development)
|
exec_login_as $app MAKEFLAGS=-j2 bundle install --jobs 2 --path vendor/bundle --with development
|
||||||
|
|
||||||
# On ARM architecture, replace bundled libpsl by system native libpsl
|
# On ARM architecture, replace bundled libpsl by system native libpsl
|
||||||
# because the provided binary isn't compatible
|
# because the provided binary isn't compatible
|
||||||
if [ -n "$(uname -m | grep arm)" ] ; then
|
if [ -n "$(uname -m | grep arm)" ] ; then
|
||||||
|
@ -200,12 +234,26 @@ if ! ynh_is_upstream_up_to_date ; then
|
||||||
$rake_exec db:migrate
|
$rake_exec db:migrate
|
||||||
$rake_exec assets:precompile
|
$rake_exec assets:precompile
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CONFIGURE PLUGINS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Patch ldap-auth plugin dependency (omniauth-ldap) to fix it when using domain subfolder
|
||||||
|
# (Can only do that now because we are patching dependencies which have just been downloaded)
|
||||||
|
# Patch applied: https://github.com/omniauth/omniauth-ldap/pull/16
|
||||||
|
(cd $final_path/plugins/discourse-ldap-auth/gems/${RUBY_VERSION}/gems/omniauth-ldap*/
|
||||||
|
patch -p1 < $YNH_CWD/../conf/ldap-auth-fix-subfolder.patch)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# SECURE FILES AND DIRECTORIES
|
# SECURE FILES AND DIRECTORIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
# Add a pids and socket directory for the systemd script.
|
||||||
|
mkdir -p "$final_path/tmp/pids"
|
||||||
|
mkdir "$final_path/tmp/sockets"
|
||||||
|
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
chown -R $app: $final_path
|
chown -R $app: $final_path
|
||||||
# Restrict rights to log directory (needed by logrotate)
|
# Restrict rights to log directory (needed by logrotate)
|
||||||
|
|
Loading…
Add table
Reference in a new issue