mirror of
https://github.com/YunoHost-Apps/mastodon_ynh.git
synced 2024-09-03 19:46:02 +02:00
Fix install and upgrade steps
This commit is contained in:
parent
61dfd27722
commit
2c8861a994
2 changed files with 47 additions and 50 deletions
|
@ -16,6 +16,7 @@ source ynh_install_ruby
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
### Remove this function if there's nothing to clean before calling the remove script.
|
### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
|
read -p "Press any key..."
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
|
@ -99,6 +100,9 @@ ynh_package_update
|
||||||
# install nodejs
|
# install nodejs
|
||||||
ynh_install_nodejs 8
|
ynh_install_nodejs 8
|
||||||
|
|
||||||
|
# install ruby
|
||||||
|
ynh_install_ruby --ruby_version=2.6.0
|
||||||
|
|
||||||
# TODO: use the same mecanism with other files
|
# TODO: use the same mecanism with other files
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
@ -122,12 +126,13 @@ ynh_psql_execute_as_root \
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Setting up source files..."
|
ynh_print_info "Setting up source files..."
|
||||||
|
|
||||||
# Creates the destination directory and stores its location.
|
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
|
||||||
ynh_app_setting_set "$app" final_path "$final_path"
|
### downloaded from an upstream source, like a git repository.
|
||||||
# Download all sources rbenv, ruby and mastodon
|
### `ynh_setup_source` use the file conf/app.src
|
||||||
|
|
||||||
|
ynh_app_setting_set $app final_path $final_path
|
||||||
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
|
||||||
ynh_setup_source "$final_path/.rbenv" "app-rbenv"
|
|
||||||
ynh_setup_source "$final_path/.rbenv/plugins/ruby-build" "app-ruby-build"
|
|
||||||
ynh_setup_source "$final_path/live" "app-mastodon"
|
ynh_setup_source "$final_path/live" "app-mastodon"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -135,6 +140,8 @@ ynh_setup_source "$final_path/live" "app-mastodon"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Configuring nginx web server..."
|
ynh_print_info "Configuring nginx web server..."
|
||||||
|
|
||||||
|
### `ynh_add_nginx_config` will use the file conf/nginx.conf
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf"
|
ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf"
|
||||||
ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf"
|
ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf"
|
||||||
|
@ -150,12 +157,6 @@ ynh_system_user_create $app $final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
#=================================================
|
|
||||||
# INSTALLING RUBY
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_install_ruby --ruby_version=2.6.0
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY A CONFIG FILE
|
# MODIFY A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -194,18 +195,14 @@ ynh_print_info "Installing Mastodon..."
|
||||||
chown -R "$app": "$final_path"
|
chown -R "$app": "$final_path"
|
||||||
|
|
||||||
pushd "$final_path/live"
|
pushd "$final_path/live"
|
||||||
su mastodon <<INSTALL
|
ynh_use_nodejs
|
||||||
ynh_use_nodejs
|
sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/gem update --system
|
||||||
env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/gem update --system
|
sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/gem install bundler --no-document
|
||||||
env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/gem install bundler --no-document
|
sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test
|
||||||
env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/bundle install \
|
sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile
|
||||||
-j$(getconf _NPROCESSORS_ONLN) \
|
sudo -u "$app" echo "SAFETY_ASSURED=1">> .env.production
|
||||||
--deployment --without development test
|
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate --quiet
|
||||||
env PATH=$PATH yarn install --pure-lockfile
|
sudo -u "$app" env PATH=$PTH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile --quiet
|
||||||
echo "SAFETY_ASSURED=1">> .env.production
|
|
||||||
env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate --quiet
|
|
||||||
env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile --quiet
|
|
||||||
INSTALL
|
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -215,14 +212,12 @@ ynh_print_info "Creating Mastodon Admin User..."
|
||||||
|
|
||||||
# Create user
|
# Create user
|
||||||
pushd "$final_path/live"
|
pushd "$final_path/live"
|
||||||
su mastodon <<SETADMIN
|
sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts create '$admin_mastodon' --email='$admin_mastodon_mail' > acc.txt
|
||||||
env PATH=$PATH RAILS_ENV=production bin/tootctl accounts create '$admin_mastodon' --email='$admin_mastodon_mail' > acc.txt
|
sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --confirm
|
||||||
env PATH=$PATH RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --confirm
|
sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --role admin
|
||||||
env PATH=$PATH RAILS_ENV=production bin/tootctl accounts modify $admin_mastodon --role admin
|
|
||||||
SETADMIN
|
|
||||||
popd
|
popd
|
||||||
|
|
||||||
admin_pass=$( cd $final_path/live && tail -1 acc.txt | head -1 | cut -c 15- )
|
admin_pass=$( tail -1 $final_path/live/acc.txt | head -1 | cut -c 15- )
|
||||||
ynh_secure_remove "$final_path/live/acc.txt"
|
ynh_secure_remove "$final_path/live/acc.txt"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -239,6 +234,17 @@ sudo cp -f ../conf/cron /etc/cron.d/$app
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info "Configuring a systemd service..."
|
ynh_print_info "Configuring a systemd service..."
|
||||||
|
|
||||||
|
### `ynh_systemd_config` is used to configure a systemd script for an app.
|
||||||
|
### It can be used for apps that use sysvinit (with adaptation) or systemd.
|
||||||
|
### Have a look at the app to be sure this app needs a systemd script.
|
||||||
|
### `ynh_systemd_config` will use the file conf/systemd.service
|
||||||
|
### If you're not using these lines:
|
||||||
|
### - You can remove those files in conf/.
|
||||||
|
### - Remove the section "BACKUP SYSTEMD" in the backup script
|
||||||
|
### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script
|
||||||
|
### - As well as the section "RESTORE SYSTEMD" in the restore script
|
||||||
|
### - And the section "SETUP SYSTEMD" in the upgrade script
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mastodon-web.service"
|
ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mastodon-web.service"
|
||||||
ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/mastodon-streaming.service"
|
ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/mastodon-streaming.service"
|
||||||
|
|
|
@ -110,10 +110,6 @@ rm -Rf "$final_path/live_back"
|
||||||
# Clean files which are not needed anymore
|
# Clean files which are not needed anymore
|
||||||
ynh_secure_remove $final_path/live/config/initializers/timeout.rb
|
ynh_secure_remove $final_path/live/config/initializers/timeout.rb
|
||||||
|
|
||||||
# Upgrade rbenv and ruby plugins
|
|
||||||
ynh_setup_source "$final_path/.rbenv" "app-rbenv"
|
|
||||||
ynh_setup_source "$final_path/.rbenv/plugins/ruby-build" "app-ruby-build"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -139,6 +135,9 @@ ynh_package_update
|
||||||
# install nodejs
|
# install nodejs
|
||||||
ynh_install_nodejs 8
|
ynh_install_nodejs 8
|
||||||
|
|
||||||
|
# install ruby
|
||||||
|
ynh_install_ruby --ruby_version=2.6.0
|
||||||
|
|
||||||
# TODO: use the same mecanism with other files
|
# TODO: use the same mecanism with other files
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
@ -152,12 +151,6 @@ ynh_system_user_create $app
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
#=================================================
|
|
||||||
# INSTALLING RUBY
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_install_ruby --ruby_version=2.6.0
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE MASTODON
|
# UPGRADE MASTODON
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -166,20 +159,18 @@ ynh_print_info "Upgrading Mastodon..."
|
||||||
chown -R "$app": "$final_path"
|
chown -R "$app": "$final_path"
|
||||||
|
|
||||||
pushd "$final_path/live"
|
pushd "$final_path/live"
|
||||||
su mastodon <<UPGRADE
|
ynh_use_nodejs
|
||||||
ynh_use_nodejs
|
sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/gem update --system
|
||||||
env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/gem update --system
|
sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/gem install bundler
|
||||||
env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/gem install bundler
|
|
||||||
if [ "$(lsb_release --codename --short)" == "jessie" ]; then
|
if [ "$(lsb_release --codename --short)" == "jessie" ]; then
|
||||||
env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/bundle install --deployment --without development test
|
sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/bundle install --deployment --without development test
|
||||||
else
|
else
|
||||||
env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/bundle install --deployment --force --without development test
|
sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.0/bin/bundle install --deployment --force --without development test
|
||||||
fi
|
fi
|
||||||
env PATH=$PATH yarn install --pure-lockfile
|
sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile
|
||||||
env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:clean
|
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:clean
|
||||||
env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile
|
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails assets:precompile
|
||||||
env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate
|
sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rails db:migrate
|
||||||
UPGRADE
|
|
||||||
popd
|
popd
|
||||||
|
|
||||||
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||||
|
|
Loading…
Reference in a new issue