mirror of
https://github.com/YunoHost-Apps/diaspora_ynh.git
synced 2024-09-03 18:26:13 +02:00
[autopatch] Automatic patch attempt for helpers 2.1
This commit is contained in:
parent
988030382e
commit
48f9e13c8d
11 changed files with 143 additions and 161 deletions
|
@ -8,7 +8,7 @@ User=__APP__
|
|||
WorkingDirectory=__INSTALL_DIR__/live
|
||||
Environment="__LD_PRELOAD__"
|
||||
Environment="RAILS_ENV=production"
|
||||
Environment="__YNH_RUBY_LOAD_PATH__"
|
||||
Environment="PATH=__PATH_WITH_RUBY__"
|
||||
ExecStart=__INSTALL_DIR__/live/bin/bundle exec sidekiq
|
||||
Restart=always
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ User=__APP__
|
|||
WorkingDirectory=__INSTALL_DIR__/live
|
||||
Environment="__LD_PRELOAD__"
|
||||
Environment="RAILS_ENV=production"
|
||||
Environment="__YNH_RUBY_LOAD_PATH__"
|
||||
Environment="PATH=__PATH_WITH_RUBY__"
|
||||
PIDFile=/run/__APP__/diaspora.pid
|
||||
ExecStart=__INSTALL_DIR__/live/bin/bundle exec unicorn -c config/unicorn.rb -E production
|
||||
ExecReload=/bin/kill -USR2 $MAINPID
|
||||
|
|
|
@ -28,5 +28,5 @@ location @diaspora {
|
|||
proxy_set_header Host $host;
|
||||
proxy_redirect off;
|
||||
|
||||
proxy_pass http://unix:/run/__NAME__/diaspora.sock;
|
||||
proxy_pass http://unix:/run/__APP__/diaspora.sock;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ code = "https://github.com/diaspora/diaspora"
|
|||
|
||||
[integration]
|
||||
yunohost = ">=11.2.12"
|
||||
helpers_version = "2.1"
|
||||
architectures = "all"
|
||||
multi_instance = true
|
||||
ldap = false
|
||||
|
@ -56,6 +57,7 @@ ram.runtime = "2000M"
|
|||
allow_email = true
|
||||
|
||||
[resources.install_dir]
|
||||
group = "www-data:r-x"
|
||||
|
||||
[resources.permissions]
|
||||
main.url = "/"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||
#=================================================
|
||||
|
||||
ruby_version=2.7
|
||||
|
@ -25,26 +25,14 @@ case $YNH_ARCH in
|
|||
esac
|
||||
ld_preload="LD_PRELOAD=/usr/lib/$arch-linux-gnu/libjemalloc.so"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
_ynh_add_systemd_target() {
|
||||
ynh_add_config --template="diaspora.target" --destination="/etc/systemd/system/${app}.target"
|
||||
ynh_config_add --template="diaspora.target" --destination="/etc/systemd/system/${app}.target"
|
||||
systemctl daemon-reload
|
||||
systemctl enable "${app}.target" --quiet
|
||||
}
|
||||
_ynh_remove_systemd_target() {
|
||||
systemctl stop "${app}.target"
|
||||
systemctl disable "${app}.target" --quiet
|
||||
ynh_secure_remove --file="/etc/systemd/system/${app}.target"
|
||||
ynh_safe_rm "/etc/systemd/system/${app}.target"
|
||||
systemctl daemon-reload
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -8,37 +8,34 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
ynh_print_info "Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$install_dir"
|
||||
ynh_backup "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
ynh_backup --src_path="/etc/systemd/system/${app}_web.service"
|
||||
ynh_backup --src_path="/etc/systemd/system/${app}_sidekiq.service"
|
||||
ynh_backup --src_path="/etc/systemd/system/${app}.target"
|
||||
ynh_backup --src_path="/etc/tmpfiles.d/${app}.conf"
|
||||
ynh_backup "/etc/systemd/system/${app}_web.service"
|
||||
ynh_backup "/etc/systemd/system/${app}_sidekiq.service"
|
||||
ynh_backup "/etc/systemd/system/${app}.target"
|
||||
ynh_backup "/etc/tmpfiles.d/${app}.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the PostgreSQL database..."
|
||||
ynh_print_info "Backing up the PostgreSQL database..."
|
||||
|
||||
ynh_psql_dump_db --database="$db_name" > db.sql
|
||||
ynh_psql_dump_db > db.sql
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -16,38 +16,38 @@ admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name="$app.target" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemctl --service="$app.target" --action="stop"
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
||||
ynh_script_progression "Updating NGINX web server configuration..."
|
||||
|
||||
# this will most likely adjust NGINX config correctly
|
||||
ynh_change_url_nginx_config
|
||||
ynh_config_change_url_nginx
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||
ynh_script_progression "Updating configuration..."
|
||||
|
||||
ynh_add_config --template="diaspora.yml" --destination="$install_dir/live/config/diaspora.yml"
|
||||
chmod 400 "$install_dir/live/config/diaspora.yml"
|
||||
chown "$app:$app" "$install_dir/live/config/diaspora.yml"
|
||||
ynh_config_add --template="diaspora.yml" --destination="$install_dir/live/config/diaspora.yml"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/live/config/diaspora.yml"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/live/config/diaspora.yml"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
systemctl restart "${app}.target"
|
||||
ynh_systemd_action --service_name="${app}_web.service" --action=restart --log_path="$install_dir/live/log/production.log" --line_match="successfully configured the federation library"
|
||||
ynh_systemd_action --service_name="${app}_sidekiq.service" --action=restart --log_path="systemd" --line_match="Running in ruby"
|
||||
ynh_systemctl --service="${app}_web.service" --action=restart --log_path="$install_dir/live/log/production.log" --wait_until="successfully configured the federation library"
|
||||
ynh_systemctl --service="${app}_sidekiq.service" --action=restart --log_path="systemd" --wait_until="Running in ruby"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||
ynh_script_progression "Change of URL completed for $app"
|
||||
|
|
|
@ -16,16 +16,16 @@ admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
|
|||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Ruby..." --weight=5
|
||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||
ynh_script_progression "Installing Ruby..."
|
||||
ynh_ruby_install
|
||||
|
||||
ynh_script_progression --message="Installing NodeJS..." --weight=5
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
ynh_script_progression "Installing NodeJS..."
|
||||
ynh_nodejs_install
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=1
|
||||
ynh_script_progression "Setting up source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir/live"
|
||||
|
@ -34,36 +34,34 @@ ynh_setup_source --dest_dir="$install_dir/live"
|
|||
mkdir -p "$install_dir/uploads"
|
||||
ln -s "$install_dir/uploads" "$install_dir/live/public"
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding $app's configuration file..." --weight=1
|
||||
ynh_script_progression "Adding $app's configuration file..."
|
||||
|
||||
ynh_add_config --template="diaspora.yml" --destination="$install_dir/live/config/diaspora.yml"
|
||||
chmod 400 "$install_dir/live/config/diaspora.yml"
|
||||
chown "$app:$app" "$install_dir/live/config/diaspora.yml"
|
||||
ynh_config_add --template="diaspora.yml" --destination="$install_dir/live/config/diaspora.yml"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/live/config/diaspora.yml"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/live/config/diaspora.yml"
|
||||
|
||||
ynh_add_config --template="database.yml" --destination="$install_dir/live/config/database.yml"
|
||||
chmod 400 "$install_dir/live/config/database.yml"
|
||||
chown "$app:$app" "$install_dir/live/config/database.yml"
|
||||
ynh_config_add --template="database.yml" --destination="$install_dir/live/config/database.yml"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/live/config/database.yml"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/live/config/database.yml"
|
||||
|
||||
#=================================================
|
||||
# BUILD APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building app..." --weight=40
|
||||
ynh_script_progression "Building app..."
|
||||
|
||||
pushd "$install_dir/live"
|
||||
ynh_use_ruby
|
||||
ynh_use_nodejs
|
||||
ynh_gem install "bundler:$bundler_version"
|
||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" "$ld_preload" script/configure_bundler
|
||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" "$ld_preload" bin/bundle install --full-index --with=postgresql
|
||||
ynh_exec_warn_less ynh_exec_as "$app" RAILS_ENV=production "$ynh_ruby_load_path" "$ld_preload" bin/bundle exec rake db:migrate
|
||||
ynh_exec_warn_less ynh_exec_as "$app" RAILS_ENV=production "$ynh_ruby_load_path" "$ld_preload" bin/rake assets:precompile
|
||||
ynh_exec_warn_less ynh_exec_as "$app" RAILS_ENV=production "$ynh_ruby_load_path" "$ld_preload" bin/bundle exec rails console << END
|
||||
|
||||
gem install "bundler:$bundler_version"
|
||||
ynh_hide_warnings ynh_exec_as_app ruby_load_path" "$ld_preload" script/configure_bundler
|
||||
ynh_hide_warnings ynh_exec_as_app ruby_load_path" "$ld_preload" bin/bundle install --full-index --with=postgresql
|
||||
ynh_hide_warnings ynh_exec_as_app RAILS_ENV=production ruby_load_path" "$ld_preload" bin/bundle exec rake db:migrate
|
||||
ynh_hide_warnings ynh_exec_as_app RAILS_ENV=production ruby_load_path" "$ld_preload" bin/rake assets:precompile
|
||||
ynh_hide_warnings ynh_exec_as_app RAILS_ENV=production ruby_load_path" "$ld_preload" bin/bundle exec rails console << END
|
||||
user = User.build({username: '$admin', email: '$admin_mail', password: '$password', password_confirmation: '$password' })
|
||||
user.save
|
||||
user.seed_aspects
|
||||
|
@ -74,14 +72,14 @@ popd
|
|||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Adding system configurations related to $app..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config --service="${app}_sidekiq" --template="diaspora_sidekiq.service"
|
||||
ynh_add_systemd_config --service="${app}_web" --template="diaspora_web.service"
|
||||
ynh_config_add_systemd --service="${app}_sidekiq" --template="diaspora_sidekiq.service"
|
||||
ynh_config_add_systemd --service="${app}_web" --template="diaspora_web.service"
|
||||
|
||||
# Create target unit
|
||||
_ynh_add_systemd_target
|
||||
|
@ -92,20 +90,20 @@ yunohost service add "$app.target" --description "Diaspora service (unicorn web
|
|||
"$install_dir/live/log/sidekiq.log"
|
||||
|
||||
# Create tmpfile
|
||||
ynh_add_config --template="diaspora.tmpfiles.d" --destination="/etc/tmpfiles.d/${app}.conf"
|
||||
ynh_config_add --template="diaspora.tmpfiles.d" --destination="/etc/tmpfiles.d/${app}.conf"
|
||||
systemd-tmpfiles --create
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
systemctl restart "${app}.target"
|
||||
ynh_systemd_action --service_name="${app}_web.service" --action=restart --log_path="$install_dir/live/log/production.log" --line_match="successfully configured the federation library"
|
||||
ynh_systemd_action --service_name="${app}_sidekiq.service" --action=restart --log_path="systemd" --line_match="Running in ruby"
|
||||
ynh_systemctl --service="${app}_web.service" --action=restart --log_path="$install_dir/live/log/production.log" --wait_until="successfully configured the federation library"
|
||||
ynh_systemctl --service="${app}_sidekiq.service" --action=restart --log_path="systemd" --wait_until="Running in ruby"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
|
|
|
@ -10,34 +10,34 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Removing system configurations related to $app..."
|
||||
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status "$app.target" >/dev/null; then
|
||||
if ynh_hide_warnings yunohost service status "$app.target" >/dev/null; then
|
||||
yunohost service remove "$app.target"
|
||||
fi
|
||||
|
||||
ynh_remove_systemd_config
|
||||
ynh_config_remove_systemd
|
||||
|
||||
ynh_secure_remove --file="/etc/tmpfiles.d/${app}.conf"
|
||||
ynh_secure_remove --file="/run/${app}"
|
||||
ynh_safe_rm "/etc/tmpfiles.d/${app}.conf"
|
||||
ynh_safe_rm "/run/${app}"
|
||||
|
||||
_ynh_remove_systemd_target
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
ynh_config_remove_nginx
|
||||
|
||||
#=================================================
|
||||
# REMOVE DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing dependencies..." --weight=10
|
||||
ynh_script_progression "Removing dependencies..."
|
||||
|
||||
# Remove metapackage and its dependencies
|
||||
ynh_remove_ruby
|
||||
ynh_remove_nodejs
|
||||
ynh_ruby_remove
|
||||
ynh_nodejs_remove
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
ynh_script_progression "Removal of $app completed"
|
||||
|
|
|
@ -11,51 +11,49 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reinstalling Ruby..." --weight=5
|
||||
ynh_exec_warn_less ynh_install_ruby --ruby_version="$ruby_version"
|
||||
ynh_script_progression "Reinstalling Ruby..."
|
||||
ynh_ruby_install
|
||||
|
||||
ynh_script_progression --message="Reinstalling NodeJS..." --weight=5
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version"
|
||||
ynh_script_progression "Reinstalling NodeJS..."
|
||||
ynh_nodejs_install
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||
ynh_script_progression "Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
ynh_restore "$install_dir"
|
||||
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
|
||||
#=================================================
|
||||
# RESTORE THE POSTGRESQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
|
||||
ynh_script_progression "Restoring the PostgreSQL database..."
|
||||
|
||||
ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
||||
ynh_psql_db_shell < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# BUILD APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building app..." --weight=40
|
||||
ynh_script_progression "Building app..."
|
||||
|
||||
pushd "$install_dir/live"
|
||||
ynh_use_ruby
|
||||
ynh_use_nodejs
|
||||
ynh_gem install "bundler:$bundler_version"
|
||||
ynh_exec_as "$app" "$ynh_ruby_load_path" "$ld_preload" script/configure_bundler
|
||||
|
||||
gem install "bundler:$bundler_version"
|
||||
ynh_exec_as_app ruby_load_path" "$ld_preload" script/configure_bundler
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Restoring system configurations related to $app..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/${app}_web.service"
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/${app}_sidekiq.service"
|
||||
ynh_restore_file --origin_path="/etc/systemd/system/${app}.target"
|
||||
ynh_restore "/etc/systemd/system/${app}_web.service"
|
||||
ynh_restore "/etc/systemd/system/${app}_sidekiq.service"
|
||||
ynh_restore "/etc/systemd/system/${app}.target"
|
||||
systemctl enable "${app}_web" "${app}_sidekiq" "$app.target" --quiet
|
||||
yunohost service add "$app.target" --description "Diaspora service (unicorn web and sidekiq)" \
|
||||
--log "$install_dir/live/log/production.log" \
|
||||
|
@ -63,22 +61,22 @@ yunohost service add "$app.target" --description "Diaspora service (unicorn web
|
|||
"$install_dir/live/log/unicorn-stdout.log" \
|
||||
"$install_dir/live/log/sidekiq.log"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/tmpfiles.d/${app}.conf"
|
||||
ynh_restore "/etc/tmpfiles.d/${app}.conf"
|
||||
systemd-tmpfiles --create
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
||||
ynh_script_progression "Reloading NGINX web server and $app's service..."
|
||||
|
||||
systemctl restart "${app}.target"
|
||||
ynh_systemd_action --service_name="${app}_web.service" --action=restart --log_path="$install_dir/live/log/production.log" --line_match="successfully configured the federation library"
|
||||
ynh_systemd_action --service_name="${app}_sidekiq.service" --action=restart --log_path="systemd" --line_match="Running in ruby"
|
||||
ynh_systemctl --service="${app}_web.service" --action=restart --log_path="$install_dir/live/log/production.log" --wait_until="successfully configured the federation library"
|
||||
ynh_systemctl --service="${app}_sidekiq.service" --action=restart --log_path="systemd" --wait_until="Running in ruby"
|
||||
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
ynh_systemctl --service=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
ynh_script_progression "Restoration completed for $app"
|
||||
|
|
|
@ -10,28 +10,28 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemd_action --service_name="$app.target" --action="stop" --log_path="/var/log/$app/$app.log"
|
||||
ynh_systemctl --service="$app.target" --action="stop"
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
ynh_script_progression "Ensuring downward compatibility..."
|
||||
|
||||
if [ -e "$install_dir/.rvm" ]; then
|
||||
# migrate from rvm to rbenv
|
||||
ynh_script_progression --message="Remove rvm if needed..." --weight=1
|
||||
ynh_exec_as "$app" --login rvm implode --force
|
||||
ynh_script_progression "Remove rvm if needed..."
|
||||
ynh_exec_as_app --login rvm implode --force
|
||||
|
||||
# remove old gpg keys for rvm
|
||||
if gpg --list-keys mpapis@gmail.com >/dev/null 2>&1; then
|
||||
ynh_exec_as "$app" gpg --delete-keys mpapis@gmail.com
|
||||
ynh_secure_remove "$install_dir/mpapis@gmail.com.pgp"
|
||||
ynh_exec_as_app gpg --delete-keys mpapis@gmail.com
|
||||
ynh_safe_rm "$install_dir/mpapis@gmail.com.pgp"
|
||||
fi
|
||||
if gpg --list-keys piotr.kuczynski@gmail.com >/dev/null 2>&1; then
|
||||
ynh_exec_as "$app" gpg --delete-keys piotr.kuczynski@gmail.com
|
||||
ynh_secure_remove "$install_dir/piotr.kuczynski@gmail.com.pgp"
|
||||
ynh_exec_as_app gpg --delete-keys piotr.kuczynski@gmail.com
|
||||
ynh_safe_rm "$install_dir/piotr.kuczynski@gmail.com.pgp"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -46,18 +46,19 @@ if ! [ -d "$install_dir/live" ]; then
|
|||
mkdir "$install_dir/uploads"
|
||||
fi
|
||||
|
||||
ynh_delete_file_checksum --file="$install_dir/diaspora/config/diaspora.yml"
|
||||
ynh_delete_file_checksum --file="$install_dir/diaspora/config/database.yml"
|
||||
ynh_delete_file_checksum "$install_dir/diaspora/config/diaspora.yml"
|
||||
ynh_delete_file_checksum "$install_dir/diaspora/config/database.yml"
|
||||
mv "$install_dir/diaspora" "$install_dir/live"
|
||||
ynh_store_file_checksum --file="$install_dir/live/config/diaspora.yml"
|
||||
ynh_store_file_checksum --file="$install_dir/live/config/database.yml"
|
||||
ynh_store_file_checksum "$install_dir/live/config/diaspora.yml"
|
||||
ynh_store_file_checksum "$install_dir/live/config/database.yml"
|
||||
fi
|
||||
|
||||
ynh_secure_remove "$install_dir/Experimental_helpers"
|
||||
ynh_safe_rm "$install_dir/Experimental_helpers"
|
||||
|
||||
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=admin --value=""
|
||||
if [[ -z "${admin:-}" ]]; then
|
||||
admin=""
|
||||
ynh_app_setting_set --app="$app" --key=admin --value="$admin"
|
||||
ynh_app_setting_set --key=admin --value="$admin"
|
||||
fi
|
||||
|
||||
admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
|
||||
|
@ -65,66 +66,64 @@ admin_mail=$(ynh_user_get_info --username="$admin" --key=mail)
|
|||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing Ruby..." --weight=5
|
||||
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||
ynh_script_progression "Installing Ruby..."
|
||||
ynh_ruby_install
|
||||
|
||||
ynh_script_progression --message="Installing NodeJS..." --weight=5
|
||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||
ynh_script_progression "Installing NodeJS..."
|
||||
ynh_nodejs_install
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||
ynh_script_progression "Upgrading source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir/live" --full_replace=1 --keep="config/diaspora.yml config/database.yml"
|
||||
ynh_setup_source --dest_dir="$install_dir/live" --full_replace --keep="config/diaspora.yml config/database.yml"
|
||||
|
||||
# create upload folder and link it
|
||||
mkdir -p "$install_dir/uploads"
|
||||
ln -s "$install_dir/uploads" "$install_dir/live/public"
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
|
||||
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||
ynh_script_progression "Updating configuration..."
|
||||
|
||||
ynh_add_config --template="diaspora.yml" --destination="$install_dir/live/config/diaspora.yml"
|
||||
chmod 400 "$install_dir/live/config/diaspora.yml"
|
||||
chown "$app:$app" "$install_dir/live/config/diaspora.yml"
|
||||
ynh_config_add --template="diaspora.yml" --destination="$install_dir/live/config/diaspora.yml"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/live/config/diaspora.yml"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/live/config/diaspora.yml"
|
||||
|
||||
ynh_add_config --template="database.yml" --destination="$install_dir/live/config/database.yml"
|
||||
chmod 400 "$install_dir/live/config/database.yml"
|
||||
chown "$app:$app" "$install_dir/live/config/database.yml"
|
||||
ynh_config_add --template="database.yml" --destination="$install_dir/live/config/database.yml"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$install_dir/live/config/database.yml"
|
||||
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/live/config/database.yml"
|
||||
|
||||
#=================================================
|
||||
# BUILD APP
|
||||
#=================================================
|
||||
ynh_script_progression --message="Building app..." --weight=40
|
||||
ynh_script_progression "Building app..."
|
||||
|
||||
pushd "$install_dir/live"
|
||||
ynh_use_ruby
|
||||
ynh_use_nodejs
|
||||
ynh_gem install "bundler:$bundler_version"
|
||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" "$ld_preload" script/configure_bundler
|
||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" "$ld_preload" bin/bundle install --full-index --with=postgresql
|
||||
ynh_exec_warn_less ynh_exec_as "$app" RAILS_ENV=production "$ynh_ruby_load_path" "$ld_preload" bin/bundle exec rake db:migrate
|
||||
ynh_exec_warn_less ynh_exec_as "$app" RAILS_ENV=production "$ynh_ruby_load_path" "$ld_preload" bin/rake assets:precompile
|
||||
|
||||
gem install "bundler:$bundler_version"
|
||||
ynh_hide_warnings ynh_exec_as_app ruby_load_path" "$ld_preload" script/configure_bundler
|
||||
ynh_hide_warnings ynh_exec_as_app ruby_load_path" "$ld_preload" bin/bundle install --full-index --with=postgresql
|
||||
ynh_hide_warnings ynh_exec_as_app RAILS_ENV=production ruby_load_path" "$ld_preload" bin/bundle exec rake db:migrate
|
||||
ynh_hide_warnings ynh_exec_as_app RAILS_ENV=production ruby_load_path" "$ld_preload" bin/rake assets:precompile
|
||||
popd
|
||||
|
||||
#=================================================
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Upgrading system configurations related to $app..."
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config --service="${app}_sidekiq" --template="diaspora_sidekiq.service"
|
||||
ynh_add_systemd_config --service="${app}_web" --template="diaspora_web.service"
|
||||
ynh_config_add_systemd --service="${app}_sidekiq" --template="diaspora_sidekiq.service"
|
||||
ynh_config_add_systemd --service="${app}_web" --template="diaspora_web.service"
|
||||
# Create target unit
|
||||
_ynh_add_systemd_target
|
||||
yunohost service add "$app.target" --description "Diaspora service (unicorn web and sidekiq)" \
|
||||
|
@ -134,20 +133,20 @@ yunohost service add "$app.target" --description "Diaspora service (unicorn web
|
|||
"$install_dir/live/log/sidekiq.log"
|
||||
|
||||
# Create tmpfile
|
||||
ynh_add_config --template="diaspora.tmpfiles.d" --destination="/etc/tmpfiles.d/${app}.conf"
|
||||
ynh_config_add --template="diaspora.tmpfiles.d" --destination="/etc/tmpfiles.d/${app}.conf"
|
||||
systemd-tmpfiles --create
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
systemctl restart "${app}.target"
|
||||
ynh_systemd_action --service_name="${app}_web.service" --action=restart --log_path="$install_dir/live/log/production.log" --line_match="successfully configured the federation library"
|
||||
ynh_systemd_action --service_name="${app}_sidekiq.service" --action=restart --log_path="systemd" --line_match="Running in ruby"
|
||||
ynh_systemctl --service="${app}_web.service" --action=restart --log_path="$install_dir/live/log/production.log" --wait_until="successfully configured the federation library"
|
||||
ynh_systemctl --service="${app}_sidekiq.service" --action=restart --log_path="systemd" --wait_until="Running in ruby"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
ynh_script_progression "Upgrade of $app completed"
|
||||
|
|
Loading…
Reference in a new issue