1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/acropolis_ynh.git synced 2024-09-03 18:06:22 +02:00
This commit is contained in:
YunoHost Bot 2024-08-31 13:08:51 +02:00 committed by GitHub
commit 73b0e6a0e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 131 additions and 145 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
*~ *~
*.sw[op] *.sw[op]
.DS_Store

View file

@ -18,6 +18,7 @@ code = "https://github.com/magicstone-dev/acropolis"
[integration] [integration]
yunohost = ">=11.2.12" yunohost = ">=11.2.12"
helpers_version = "2.1"
architectures = "all" architectures = "all"
multi_instance = false multi_instance = false
@ -59,6 +60,7 @@ ram.runtime = "50M"
[resources.system_user] [resources.system_user]
[resources.install_dir] [resources.install_dir]
group = "www-data:r-x"
[resources.permissions] [resources.permissions]
main.url = "/" main.url = "/"

View file

@ -1,17 +1,13 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES AND CUSTOM HELPERS
#================================================= #=================================================
RUBY_VERSION="2.7.1" ruby_version="2.7.1"
MEMORY_NEEDED="2560" MEMORY_NEEDED="2560"
#=================================================
# PERSONAL HELPERS
#=================================================
# Returns true if a swap partition is enabled, false otherwise # Returns true if a swap partition is enabled, false otherwise
# usage: is_swap_present # usage: is_swap_present
is_swap_present() { is_swap_present() {
@ -37,11 +33,11 @@ is_memory_available() {
# terminates installation if requirements not met # terminates installation if requirements not met
check_memory_requirements() { check_memory_requirements() {
if ! is_swap_present ; then if ! is_swap_present ; then
ynh_die --message="You must have a swap partition in order to install and use this application" ynh_die "You must have a swap partition in order to install and use this application"
elif ! is_swappiness_sufficient ; then elif ! is_swappiness_sufficient ; then
ynh_die --message="Your swappiness must be higher than 50; please see https://en.wikipedia.org/wiki/Swappiness" ynh_die "Your swappiness must be higher than 50; please see https://en.wikipedia.org/wiki/Swappiness"
elif ! is_memory_available 1000000 ; then elif ! is_memory_available 1000000 ; then
ynh_die --message="You must have a minimum of 1Gb available memory (RAM+swap) for the installation" ynh_die "You must have a minimum of 1Gb available memory (RAM+swap) for the installation"
fi fi
} }
# Checks discourse upgrade memory requirements # Checks discourse upgrade memory requirements
@ -49,7 +45,7 @@ check_memory_requirements() {
# terminates upgrade if requirements not met # terminates upgrade if requirements not met
check_memory_requirements_upgrade() { check_memory_requirements_upgrade() {
if ! is_memory_available 400000 ; then if ! is_memory_available 400000 ; then
ynh_die --message="You must have a minimum of 400Mb available memory (RAM+swap) for the upgrade" ynh_die "You must have a minimum of 400Mb available memory (RAM+swap) for the upgrade"
fi fi
} }
@ -111,11 +107,3 @@ ynh_maintenance_mode_OFF () {
systemctl reload nginx systemctl reload nginx
} }
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -9,37 +9,34 @@ source ../settings/scripts/_common.sh
source ../settings/scripts/ynh_add_swap source ../settings/scripts/ynh_add_swap
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= ynh_print_info "Declaring files to be backed up..."
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$install_dir" ynh_backup "$install_dir"
#================================================= #=================================================
# BACKUP THE SYSTEM CONFIGURATION # BACKUP THE 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 "/etc/systemd/system/$app-web.service"
ynh_backup --src_path="/etc/systemd/system/$app-sidekiq.service" ynh_backup "/etc/systemd/system/$app-sidekiq.service"
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup "/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP THE MYSQL DATABASE # BACKUP THE MYSQL 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 # 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)."

View file

@ -11,14 +11,14 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing Ruby..." --weight=1 ynh_script_progression "Installing Ruby..."
ynh_exec_warn_less ynh_install_ruby --ruby_version="$RUBY_VERSION" ynh_ruby_install
#================================================= #=================================================
# ADD SWAP IF NEEDED # ADD SWAP IF NEEDED
#================================================= #=================================================
ynh_script_progression --message="Adding swap if needed..." ynh_script_progression "Adding swap if needed..."
total_memory=$(ynh_get_ram --total) total_memory=$(ynh_get_ram --total)
swap_needed=0 swap_needed=0
@ -28,92 +28,92 @@ if (( MEMORY_NEEDED > total_memory )); then
swap_needed=$((MEMORY_NEEDED - total_memory)) swap_needed=$((MEMORY_NEEDED - total_memory))
fi fi
ynh_script_progression --message="Adding $swap_needed Mo to swap..." ynh_script_progression "Adding $swap_needed Mo to swap..."
ynh_add_swap --size=$swap_needed ynh_add_swap --size=$swap_needed
#================================================= #=================================================
# CREATE A POSTGRESQL DATABASE # CREATE A POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Setting the PostgreSQL database..." ynh_script_progression "Setting the PostgreSQL database..."
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS hstore;" --database="$db_name" ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS hstore;"
ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database="$db_name"
ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=1 ynh_script_progression "Setting up source files..."
ynh_setup_source --dest_dir="$install_dir" ynh_setup_source --dest_dir="$install_dir"
mkdir -p "$install_dir/tmp/pids" mkdir -p "$install_dir/tmp/pids"
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 | 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 | chown -R "$app:www-data" "$install_dir"
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_script_progression "Adding $app's configuration..."
ynh_add_config --template="database.yml.example" --destination="$install_dir/config/database.yml" ynh_config_add --template="database.yml.example" --destination="$install_dir/config/database.yml"
ynh_add_config --template="diaspora.toml.example" --destination="$install_dir/config/diaspora.toml" ynh_config_add --template="diaspora.toml.example" --destination="$install_dir/config/diaspora.toml"
chmod 400 "$install_dir/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/config/database.yml"
chmod 400 "$install_dir/config/diaspora.toml" #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/config/diaspora.toml"
chown "$app:$app" "$install_dir/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/config/database.yml"
chown "$app:$app" "$install_dir/config/diaspora.toml" #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/config/diaspora.toml"
#================================================= #=================================================
# INSTALLING RUBY AND BUNDLER # INSTALLING RUBY AND BUNDLER
#================================================= #=================================================
ynh_script_progression --message="Building $app..." ynh_script_progression "Building $app..."
pushd "$install_dir" pushd "$install_dir"
ynh_use_ruby
ynh_gem install bundler:1.17.3 --no-document
ynh_exec_as "$app" echo "gem: --no-ri --no-rdoc" >> "$install_dir/.gemrc"
ynh_exec_as "$app" chmod +x script/server
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" script/configure_bundler gem install bundler:1.17.3 --no-document
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" bin/bundle config set path 'vendor/bundle' ynh_exec_as_app echo "gem: --no-ri --no-rdoc" >> "$install_dir/.gemrc"
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" bin/bundle install --full-index --with postgresql ynh_exec_as_app chmod +x script/server
ynh_hide_warnings ynh_exec_as_app ruby_load_path" script/configure_bundler
ynh_hide_warnings ynh_exec_as_app ruby_load_path" bin/bundle config set path 'vendor/bundle'
ynh_hide_warnings ynh_exec_as_app ruby_load_path" bin/bundle install --full-index --with postgresql
popd popd
ynh_script_progression --message="Preparing the database and create initial admin user..." ynh_script_progression "Preparing the database and create initial admin user..."
pushd "$install_dir" pushd "$install_dir"
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" RAILS_ENV=production bin/rake db:migrate ynh_hide_warnings ynh_exec_as_app ruby_load_path" RAILS_ENV=production bin/rake db:migrate
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" RAILS_ENV=production bin/rake assets:precompile ynh_hide_warnings ynh_exec_as_app ruby_load_path" RAILS_ENV=production bin/rake assets:precompile
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" RAILS_ENV=production bin/rake "admin:create[$admin, $email, $password]" ynh_hide_warnings ynh_exec_as_app ruby_load_path" RAILS_ENV=production bin/rake "admin:create[$admin, $email, $password]"
popd popd
#================================================= #=================================================
# SYSTEM CONFIGURATION # SYSTEM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 ynh_script_progression "Adding system configurations related to $app..."
ynh_add_nginx_config ynh_config_add_nginx
ynh_add_systemd_config --service="$app-web" --template="$app-web.service" ynh_config_add_systemd --service="$app-web" --template="$app-web.service"
yunohost service add "$app-web" --description="$app web service" yunohost service add "$app-web" --description="$app web service"
ynh_add_systemd_config --service="$app-sidekiq" --template="$app-sidekiq.service" ynh_config_add_systemd --service="$app-sidekiq" --template="$app-sidekiq.service"
yunohost service add "$app-sidekiq" --description="$app sidekiq service" yunohost service add "$app-sidekiq" --description="$app sidekiq service"
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate ynh_config_add_logrotate
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name="${app}-web" --action="start" --log_path=systemd --line_match="listening on" ynh_systemctl --service="${app}-web" --action="start" --log_path=systemd --wait_until="listening on"
ynh_systemd_action --service_name="${app}-sidekiq" --action="start" --log_path=systemd --line_match="Booted Rails" ynh_systemctl --service="${app}-sidekiq" --action="start" --log_path=systemd --wait_until="Booted Rails"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression "Installation of $app completed"

View file

@ -11,37 +11,37 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# REMOVE SYSTEM CONFIGURATIONS # 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`) # 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-web" >/dev/null; then if ynh_hide_warnings yunohost service status "$app-web" >/dev/null; then
yunohost service remove "$app-web" yunohost service remove "$app-web"
fi fi
ynh_remove_systemd_config --service="$app-web" ynh_config_remove_systemd"$app-web"
if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null; then if ynh_hide_warnings yunohost service status "$app-sidekiq" >/dev/null; then
yunohost service remove "$app-sidekiq" yunohost service remove "$app-sidekiq"
fi fi
ynh_remove_systemd_config --service="$app-sidekiq" ynh_config_remove_systemd"$app-sidekiq"
ynh_remove_nginx_config ynh_config_remove_nginx
#================================================= #=================================================
# REMOVE VARIOUS FILES # REMOVE VARIOUS FILES
#================================================= #=================================================
ynh_secure_remove --file="/etc/$app" ynh_safe_rm "/etc/$app"
ynh_secure_remove --file="/var/log/$app" #REMOVEME? (Apps should not remove their log dir during remove ... this should only happen if --purge is used, and be handled by the core...) ynh_safe_rm "/var/log/$app"
ynh_script_progression --message="Removing Swap..." --weight=1 ynh_script_progression "Removing Swap..."
ynh_del_swap ynh_del_swap
ynh_script_progression --message="Uninstalling Ruby..." --weight=1 ynh_script_progression "Uninstalling Ruby..."
ynh_remove_ruby ynh_ruby_remove
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --last ynh_script_progression "Removal of $app completed"

View file

@ -12,14 +12,14 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling Ruby..." --weight=4 ynh_script_progression "Reinstalling Ruby..."
ynh_exec_warn_less ynh_install_ruby --ruby_version="$RUBY_VERSION" ynh_ruby_install
#================================================= #=================================================
# ADD SWAP IF NEEDED # ADD SWAP IF NEEDED
#================================================= #=================================================
ynh_script_progression --message="Adding swap if needed..." ynh_script_progression "Adding swap if needed..."
total_memory=$(ynh_get_ram --total) total_memory=$(ynh_get_ram --total)
swap_needed=0 swap_needed=0
@ -29,68 +29,67 @@ if (( MEMORY_NEEDED > total_memory )); then
swap_needed=$((MEMORY_NEEDED - total_memory)) swap_needed=$((MEMORY_NEEDED - total_memory))
fi fi
ynh_script_progression --message="Adding $swap_needed Mo to swap..." ynh_script_progression "Adding $swap_needed Mo to swap..."
ynh_add_swap --size=$swap_needed ynh_add_swap --size=$swap_needed
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # 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" ynh_restore "$install_dir"
mkdir -p "$install_dir/tmp/pids" mkdir -p "$install_dir/tmp/pids"
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 | chmod -R o-rwx "$install_dir"
chown -R "$app:$app" "$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:$app" "$install_dir"
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # 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
#================================================= #=================================================
# INSTALLING RUBY AND BUNDLER # INSTALLING RUBY AND BUNDLER
#================================================= #=================================================
ynh_script_progression --message="Rebuilding $app..." ynh_script_progression "Rebuilding $app..."
pushd "$install_dir" pushd "$install_dir"
ynh_use_ruby
ynh_gem install bundler:1.17.3 --no-document gem install bundler:1.17.3 --no-document
ynh_exec_as "$app" echo "gem: --no-ri --no-rdoc" >> "$install_dir/.gemrc" ynh_exec_as_app echo "gem: --no-ri --no-rdoc" >> "$install_dir/.gemrc"
popd popd
#================================================= #=================================================
# RESTORE SYSTEM CONFIGURATIONS # 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 "/etc/systemd/system/$app-web.service"
systemctl enable "$app-web" --quiet systemctl enable "$app-web" --quiet
yunohost service add "$app-web" --description="$app web service" yunohost service add "$app-web" --description="$app web service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service" ynh_restore "/etc/systemd/system/$app-sidekiq.service"
systemctl enable "$app-sidekiq" --quiet systemctl enable "$app-sidekiq" --quiet
yunohost service add "$app-sidekiq" --description="$app sidekiq service" yunohost service add "$app-sidekiq" --description="$app sidekiq service"
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore "/etc/logrotate.d/$app"
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE # 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..."
ynh_systemd_action --service_name="${app}-web" --action="start" --log_path=systemd --line_match="listening on" ynh_systemctl --service="${app}-web" --action="start" --log_path=systemd --wait_until="listening on"
ynh_systemd_action --service_name="${app}-sidekiq" --action="start" --log_path=systemd --line_match="Booted Rails" ynh_systemctl --service="${app}-sidekiq" --action="start" --log_path=systemd --wait_until="Booted Rails"
ynh_systemd_action --service_name=nginx --action=reload ynh_systemctl --service=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" --last ynh_script_progression "Restoration completed for $app"

View file

@ -11,100 +11,99 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# STOP SYSTEMD SERVICE # 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}-web" --action="stop" --log_path=systemd ynh_systemctl --service="${app}-web" --action="stop" --log_path=systemd
ynh_systemd_action --service_name="${app}-sidekiq" --action="stop" --log_path=systemd ynh_systemctl --service="${app}-sidekiq" --action="stop" --log_path=systemd
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." ynh_script_progression "Ensuring downward compatibility..."
ynh_remove_extra_repo ynh_remove_extra_repo
ynh_app_setting_delete --app="$app" --key=redis_namespace ynh_app_setting_delete --key=redis_namespace
ynh_app_setting_delete --app="$app" --key=secret_key_base ynh_app_setting_delete --key=secret_key_base
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Updating Ruby..." --weight=1 ynh_script_progression "Updating Ruby..."
ynh_exec_warn_less ynh_install_ruby --ruby_version="$RUBY_VERSION" ynh_ruby_install
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # 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 # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="config/database.yml config/diaspora.toml" ynh_setup_source --dest_dir="$install_dir" --full_replace --keep="config/database.yml config/diaspora.toml"
mkdir -p "$install_dir/tmp/pids" mkdir -p "$install_dir/tmp/pids"
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 | 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 | chown -R "$app:www-data" "$install_dir"
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating $app's configuration files..." --weight=1 ynh_script_progression "Updating $app's configuration files..."
ynh_add_config --template="database.yml.example" --destination="$install_dir/config/database.yml" ynh_config_add --template="database.yml.example" --destination="$install_dir/config/database.yml"
ynh_add_config --template="diaspora.toml.example" --destination="$install_dir/config/diaspora.toml" ynh_config_add --template="diaspora.toml.example" --destination="$install_dir/config/diaspora.toml"
chmod 400 "$install_dir/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/config/database.yml"
chmod 400 "$install_dir/config/diaspora.toml" #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/config/diaspora.toml"
chown "$app:$app" "$install_dir/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/config/database.yml"
chown "$app:$app" "$install_dir/config/diaspora.toml" #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/config/diaspora.toml"
#================================================= #=================================================
# INSTALLING RUBY AND BUNDLER # INSTALLING RUBY AND BUNDLER
#================================================= #=================================================
ynh_script_progression --message="Building $app..." ynh_script_progression "Building $app..."
pushd "$install_dir" pushd "$install_dir"
ynh_use_ruby
ynh_gem install bundler:1.17.3 --no-document
ynh_exec_as "$app" echo "gem: --no-ri --no-rdoc" >> "$install_dir/.gemrc"
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" bin/bundle config deployment 'true' gem install bundler:1.17.3 --no-document
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" bin/bundle config without 'development test' ynh_exec_as_app echo "gem: --no-ri --no-rdoc" >> "$install_dir/.gemrc"
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" bin/bundle install --full-index --with postgresql
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" RAILS_ENV=production bin/rake assets:clean ynh_hide_warnings ynh_exec_as_app ruby_load_path" bin/bundle config deployment 'true'
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" RAILS_ENV=production bin/rake assets:precompile ynh_hide_warnings ynh_exec_as_app ruby_load_path" bin/bundle config without 'development test'
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_ruby_load_path" RAILS_ENV=production bin/rake db:migrate ynh_hide_warnings ynh_exec_as_app ruby_load_path" bin/bundle install --full-index --with postgresql
ynh_hide_warnings ynh_exec_as_app ruby_load_path" RAILS_ENV=production bin/rake assets:clean
ynh_hide_warnings ynh_exec_as_app ruby_load_path" RAILS_ENV=production bin/rake assets:precompile
ynh_hide_warnings ynh_exec_as_app ruby_load_path" RAILS_ENV=production bin/rake db:migrate
popd popd
#================================================= #=================================================
# REAPPLY SYSTEM CONFIGURATIONS # 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 # Create a dedicated NGINX config
ynh_add_nginx_config ynh_config_add_nginx
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config --service="$app-web" --template="acropolis-web.service" ynh_config_add_systemd --service="$app-web" --template="acropolis-web.service"
yunohost service add "$app-web" --description="$app web service" yunohost service add "$app-web" --description="$app web service"
ynh_add_systemd_config --service="$app-sidekiq" --template="acropolis-sidekiq.service" ynh_config_add_systemd --service="$app-sidekiq" --template="acropolis-sidekiq.service"
yunohost service add "$app-sidekiq" --description="$app sidekiq service" yunohost service add "$app-sidekiq" --description="$app sidekiq service"
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append ynh_config_add_logrotate
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting $app's systemd service..." --weight=1 ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name="${app}-web" --action="start" --log_path=systemd --line_match="listening on" ynh_systemctl --service="${app}-web" --action="start" --log_path=systemd --wait_until="listening on"
ynh_systemd_action --service_name="${app}-sidekiq" --action="start" --log_path=systemd --line_match="Booted Rails" ynh_systemctl --service="${app}-sidekiq" --action="start" --log_path=systemd --wait_until="Booted Rails"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression "Upgrade of $app completed"