mirror of
https://github.com/YunoHost-Apps/huginn_ynh.git
synced 2024-09-03 19:26:13 +02:00
Merge afe59381eb
into 151b5ab098
This commit is contained in:
commit
d43cf428f7
10 changed files with 120 additions and 134 deletions
|
@ -8,7 +8,7 @@ User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__INSTALL_DIR__/
|
WorkingDirectory=__INSTALL_DIR__/
|
||||||
EnvironmentFile=__INSTALL_DIR__/.env
|
EnvironmentFile=__INSTALL_DIR__/.env
|
||||||
Environment="__YNH_RUBY_LOAD_PATH__"
|
Environment="PATH=__PATH_WITH_RUBY__"
|
||||||
ExecStart=/opt/rbenv/versions/__APP__/bin/bundle exec rails runner bin/threaded.rb
|
ExecStart=/opt/rbenv/versions/__APP__/bin/bundle exec rails runner bin/threaded.rb
|
||||||
StandardOutput=append:__INSTALL_DIR__/log/__APP__-jobs.log
|
StandardOutput=append:__INSTALL_DIR__/log/__APP__-jobs.log
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
|
|
|
@ -8,7 +8,7 @@ User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
WorkingDirectory=__INSTALL_DIR__/
|
WorkingDirectory=__INSTALL_DIR__/
|
||||||
EnvironmentFile=__INSTALL_DIR__/.env
|
EnvironmentFile=__INSTALL_DIR__/.env
|
||||||
Environment="__YNH_RUBY_LOAD_PATH__"
|
Environment="PATH=__PATH_WITH_RUBY__"
|
||||||
ExecStart=/opt/rbenv/versions/__APP__/bin/bundle exec unicorn -c config/unicorn.rb
|
ExecStart=/opt/rbenv/versions/__APP__/bin/bundle exec unicorn -c config/unicorn.rb
|
||||||
StandardOutput=append:__INSTALL_DIR__/log/__APP__-web.log
|
StandardOutput=append:__INSTALL_DIR__/log/__APP__-web.log
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
|
|
|
@ -15,7 +15,8 @@ license = "MIT"
|
||||||
code = "https://github.com/huginn/huginn"
|
code = "https://github.com/huginn/huginn"
|
||||||
|
|
||||||
[integration]
|
[integration]
|
||||||
yunohost = ">= 11.2.12"
|
yunohost = ">= 11.2.18"
|
||||||
|
helpers_version = "2.1"
|
||||||
architectures = "all"
|
architectures = "all"
|
||||||
multi_instance = true
|
multi_instance = true
|
||||||
ldap = false
|
ldap = false
|
||||||
|
@ -56,6 +57,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 = "/"
|
||||||
|
|
|
@ -1,19 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# COMMON VARIABLES
|
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ruby_version=3.2.4
|
ruby_version=3.2.4
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# PERSONAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# EXPERIMENTAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# FUTURE OFFICIAL HELPERS
|
|
||||||
#=================================================
|
|
||||||
|
|
|
@ -8,35 +8,32 @@
|
||||||
source ../settings/scripts/_common.sh
|
source ../settings/scripts/_common.sh
|
||||||
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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SYSTEM CONFIGURATION
|
# 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-jobs.service"
|
ynh_backup "/etc/systemd/system/$app-jobs.service"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE MYSQL DATABASE
|
# BACKUP THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Backing up the MySQL database..."
|
ynh_print_info "Backing up the MySQL database..."
|
||||||
|
|
||||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
ynh_mysql_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)."
|
||||||
|
|
|
@ -10,41 +10,42 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping $app's systemd service..."
|
ynh_script_progression "Stopping $app's systemd service..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app-web" --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemctl --service="$app-web" --action="stop"
|
||||||
ynh_systemd_action --service_name="$app-jobs" --action="stop" --log_path="/var/log/$app/$app.log"
|
|
||||||
|
ynh_systemctl --service="$app-jobs" --action="stop"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating NGINX web server configuration..."
|
ynh_script_progression "Updating NGINX web server configuration..."
|
||||||
|
|
||||||
ynh_change_url_nginx_config
|
ynh_config_change_url_nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC MODIFICATIONS
|
# SPECIFIC MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating $app's configuration file..."
|
ynh_script_progression "Updating $app's configuration file..."
|
||||||
|
|
||||||
#domain=$new_domain
|
#domain=$new_domain
|
||||||
#path=$new_path
|
#path=$new_path
|
||||||
ynh_add_config --template=".env.example" --destination="$install_dir/.env"
|
ynh_config_add --template=".env.example" --destination="$install_dir/.env"
|
||||||
|
|
||||||
chmod 400 "$install_dir/.env"
|
#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/.env"
|
||||||
chown "$app:$app" "$install_dir/.env"
|
#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/.env"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting $app's systemd service..."
|
ynh_script_progression "Starting $app's systemd service..."
|
||||||
|
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="$install_dir/log/unicorn.log" --line_match="listening on addr"
|
ynh_systemctl --service="$app-web" --action="start" --log_path="$install_dir/log/unicorn.log" --wait_until="listening on addr"
|
||||||
ynh_systemd_action --service_name="$app-jobs" --action="start" --log_path="$install_dir/log/huginn-jobs.log"
|
ynh_systemctl --service="$app-jobs" --action="start" --log_path="$install_dir/log/huginn-jobs.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Change of URL completed for $app"
|
ynh_script_progression "Change of URL completed for $app"
|
||||||
|
|
|
@ -13,58 +13,57 @@ source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
secret=$(ynh_string_random --length=16)
|
secret=$(ynh_string_random --length=16)
|
||||||
|
|
||||||
ynh_app_setting_set --app="$app" --key="secret" --value="$secret"
|
ynh_app_setting_set --key="secret" --value="$secret"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing Ruby..."
|
ynh_script_progression "Installing Ruby..."
|
||||||
|
|
||||||
ynh_install_ruby --ruby_version=$ruby_version
|
ynh_ruby_install
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Setting up source files..."
|
ynh_script_progression "Setting up 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"
|
ynh_setup_source --dest_dir="$install_dir"
|
||||||
|
|
||||||
mkdir -p "$install_dir/log" "$install_dir/tmp/pids" "$install_dir/tmp/sockets"
|
mkdir -p "$install_dir/log" "$install_dir/tmp/pids" "$install_dir/tmp/sockets"
|
||||||
|
|
||||||
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 $app's configuration file..."
|
ynh_script_progression "Adding $app's configuration file..."
|
||||||
|
|
||||||
ynh_add_config --template=".env.example" --destination="$install_dir/.env"
|
ynh_config_add --template=".env.example" --destination="$install_dir/.env"
|
||||||
|
|
||||||
chmod 400 "$install_dir/.env"
|
#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/.env"
|
||||||
chown "$app:$app" "$install_dir/.env"
|
#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/.env"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD APP
|
# BUILD APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Building app..."
|
ynh_script_progression "Building app..."
|
||||||
|
|
||||||
pushd "$install_dir"
|
pushd "$install_dir"
|
||||||
ynh_use_ruby
|
|
||||||
cp config/unicorn.rb.example config/unicorn.rb
|
cp config/unicorn.rb.example config/unicorn.rb
|
||||||
chown -R "$app:www-data" "$install_dir/config/unicorn.rb"
|
chown -R "$app:www-data" "$install_dir/config/unicorn.rb"
|
||||||
ynh_gem install rubygems-update -v 3.4
|
gem install rubygems-update -v 3.4
|
||||||
ynh_gem update --system --no-document
|
gem update --system --no-document
|
||||||
ynh_gem install bundler -v 2.4.22
|
gem install bundler -v 2.4.22
|
||||||
ynh_gem install rake foreman --no-document
|
gem install rake foreman --no-document
|
||||||
bundle config set --local deployment 'true'
|
bundle config set --local deployment 'true'
|
||||||
bundle config set --local without 'development test'
|
bundle config set --local without 'development test'
|
||||||
bundle install
|
bundle install
|
||||||
ynh_exec_warn_less bundle exec rake db:create RAILS_ENV=production
|
ynh_hide_warnings bundle exec rake db:create RAILS_ENV=production
|
||||||
ynh_exec_warn_less bundle exec rake db:migrate RAILS_ENV=production
|
ynh_hide_warnings bundle exec rake db:migrate RAILS_ENV=production
|
||||||
ynh_exec_warn_less bundle exec rake db:seed RAILS_ENV=production SEED_USERNAME=$admin SEED_PASSWORD=$password
|
ynh_hide_warnings bundle exec rake db:seed RAILS_ENV=production SEED_USERNAME=$admin SEED_PASSWORD=$password
|
||||||
ynh_exec_warn_less bundle exec rake assets:precompile RAILS_ENV=production
|
ynh_hide_warnings bundle exec rake assets:precompile RAILS_ENV=production
|
||||||
popd
|
popd
|
||||||
|
|
||||||
chmod 750 "$install_dir/public"
|
chmod 750 "$install_dir/public"
|
||||||
|
@ -74,29 +73,29 @@ chown -R "$app:www-data" "$install_dir/public"
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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..."
|
||||||
|
|
||||||
# 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="web.service"
|
ynh_config_add_systemd --service="$app-web" --template="web.service"
|
||||||
yunohost service add "$app-web" --log="$install_dir/log/unicorn.log"
|
yunohost service add "$app-web" --log="$install_dir/log/unicorn.log"
|
||||||
|
|
||||||
ynh_add_systemd_config --service="$app-jobs" --template="jobs.service"
|
ynh_config_add_systemd --service="$app-jobs" --template="jobs.service"
|
||||||
yunohost service add "$app-jobs" --log="$install_dir/log/production.log"
|
yunohost service add "$app-jobs" --log="$install_dir/log/production.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting $app's systemd services..."
|
ynh_script_progression "Starting $app's systemd services..."
|
||||||
|
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="$install_dir/log/unicorn.log" --line_match="listening on addr"
|
ynh_systemctl --service="$app-web" --action="start" --log_path="$install_dir/log/unicorn.log" --wait_until="listening on addr"
|
||||||
ynh_systemd_action --service_name="$app-jobs" --action="start" --log_path="$install_dir/log/huginn-jobs.log" --line_match="Starting"
|
ynh_systemctl --service="$app-jobs" --action="start" --log_path="$install_dir/log/huginn-jobs.log" --wait_until="Starting"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Installation of $app completed"
|
ynh_script_progression "Installation of $app completed"
|
||||||
|
|
|
@ -10,29 +10,29 @@ 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
|
||||||
# Remove the dedicated systemd config
|
# Remove the dedicated systemd config
|
||||||
ynh_remove_systemd_config --service="$app-web"
|
ynh_config_remove_systemd"$app-web"
|
||||||
|
|
||||||
if ynh_exec_warn_less yunohost service status "$app-jobs" >/dev/null; then
|
if ynh_hide_warnings yunohost service status "$app-jobs" >/dev/null; then
|
||||||
yunohost service remove "$app-jobs"
|
yunohost service remove "$app-jobs"
|
||||||
fi
|
fi
|
||||||
# Remove the dedicated systemd config
|
# Remove the dedicated systemd config
|
||||||
ynh_remove_systemd_config --service="$app-jobs"
|
ynh_config_remove_systemd"$app-jobs"
|
||||||
|
|
||||||
# Remove the dedicated NGINX config
|
# Remove the dedicated NGINX config
|
||||||
ynh_remove_nginx_config
|
ynh_config_remove_nginx
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
# Remove metapackage and its dependencies
|
||||||
ynh_remove_ruby
|
ynh_ruby_remove
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Removal of $app completed"
|
ynh_script_progression "Removal of $app completed"
|
||||||
|
|
|
@ -11,44 +11,43 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reinstalling Ruby..."
|
ynh_script_progression "Reinstalling Ruby..."
|
||||||
|
|
||||||
ynh_install_ruby --ruby_version=$ruby_version
|
ynh_ruby_install
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the app main directory..."
|
ynh_script_progression "Restoring the app main directory..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$install_dir"
|
ynh_restore "$install_dir"
|
||||||
|
|
||||||
mkdir -p "$install_dir/log" "$install_dir/tmp/pids" "$install_dir/tmp/sockets"
|
mkdir -p "$install_dir/log" "$install_dir/tmp/pids" "$install_dir/tmp/sockets"
|
||||||
|
|
||||||
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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE MYSQL DATABASE
|
# RESTORE THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
|
ynh_script_progression "Restoring the MySQL database..."
|
||||||
|
|
||||||
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
ynh_mysql_db_shell < ./db.sql
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD APP
|
# BUILD APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Building app..."
|
ynh_script_progression "Building app..."
|
||||||
|
|
||||||
pushd "$install_dir"
|
pushd "$install_dir"
|
||||||
ynh_use_ruby
|
|
||||||
ynh_gem install rubygems-update -v 3.4
|
gem install rubygems-update -v 3.4
|
||||||
ynh_gem update --system --no-document
|
gem update --system --no-document
|
||||||
ynh_gem install bundler -v 2.4.22
|
gem install bundler -v 2.4.22
|
||||||
ynh_gem install rake foreman --no-document
|
gem install rake foreman --no-document
|
||||||
bundle config set --local deployment 'true'
|
bundle config set --local deployment 'true'
|
||||||
ynh_exec_warn_less bundle config set --local without 'development test'
|
ynh_hide_warnings bundle config set --local without 'development test'
|
||||||
ynh_exec_warn_less bundle install
|
ynh_hide_warnings bundle install
|
||||||
ynh_exec_warn_less bundle exec rake assets:clean assets:precompile tmp:cache:clear RAILS_ENV=production
|
ynh_hide_warnings bundle exec rake assets:clean assets:precompile tmp:cache:clear RAILS_ENV=production
|
||||||
popd
|
popd
|
||||||
|
|
||||||
chmod 750 "$install_dir/public"
|
chmod 750 "$install_dir/public"
|
||||||
|
@ -58,31 +57,31 @@ chown -R "$app:www-data" "$install_dir/public"
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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.service" --quiet
|
systemctl enable "$app-web.service" --quiet
|
||||||
yunohost service add "$app-web" --log="$install_dir/log/unicorn.log"
|
yunohost service add "$app-web" --log="$install_dir/log/unicorn.log"
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/systemd/system/$app-jobs.service"
|
ynh_restore "/etc/systemd/system/$app-jobs.service"
|
||||||
systemctl enable "$app-jobs.service" --quiet
|
systemctl enable "$app-jobs.service" --quiet
|
||||||
yunohost service add "$app-jobs" --log="$install_dir/log/production.log"
|
yunohost service add "$app-jobs" --log="$install_dir/log/production.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..."
|
ynh_script_progression "Reloading NGINX web server and $app's service..."
|
||||||
|
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="$install_dir/log/unicorn.log" --line_match="listening on addr"
|
ynh_systemctl --service="$app-web" --action="start" --log_path="$install_dir/log/unicorn.log" --wait_until="listening on addr"
|
||||||
ynh_systemd_action --service_name="$app-jobs" --action="start" --log_path="$install_dir/log/huginn-jobs.log" --line_match="Starting"
|
ynh_systemctl --service="$app-jobs" --action="start" --log_path="$install_dir/log/huginn-jobs.log" --wait_until="Starting"
|
||||||
|
|
||||||
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"
|
ynh_script_progression "Restoration completed for $app"
|
||||||
|
|
|
@ -10,58 +10,58 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Stopping $app's systemd services..."
|
ynh_script_progression "Stopping $app's systemd services..."
|
||||||
|
|
||||||
ynh_systemd_action --service_name="$app-web" --action="stop" --log_path="/var/log/$app/$app.log"
|
ynh_systemctl --service="$app-web" --action="stop"
|
||||||
ynh_systemd_action --service_name="$app-jobs" --action="stop" --log_path="/var/log/$app/$app.log"
|
|
||||||
|
ynh_systemctl --service="$app-jobs" --action="stop"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE DEPENDENCIES
|
# UPGRADE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading Ruby..." --weight=1
|
ynh_script_progression "Upgrading 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..."
|
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=".env"
|
ynh_setup_source --dest_dir="$install_dir" --full_replace --keep=".env"
|
||||||
mkdir -p "$install_dir/log" "$install_dir/tmp/pids" "$install_dir/tmp/sockets"
|
mkdir -p "$install_dir/log" "$install_dir/tmp/pids" "$install_dir/tmp/sockets"
|
||||||
|
|
||||||
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 a configuration file..."
|
ynh_script_progression "Updating configuration..."
|
||||||
|
|
||||||
ynh_add_config --template="../conf/.env.example" --destination="$install_dir/.env"
|
ynh_config_add --template=".env.example" --destination="$install_dir/.env"
|
||||||
|
|
||||||
chmod 400 "$install_dir/.env"
|
#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/.env"
|
||||||
chown "$app:$app" "$install_dir/.env"
|
#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/.env"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BUILD APP
|
# BUILD APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Building app..."
|
ynh_script_progression "Building app..."
|
||||||
|
|
||||||
pushd $install_dir
|
pushd $install_dir
|
||||||
ynh_use_ruby
|
|
||||||
cp -f config/unicorn.rb.example config/unicorn.rb
|
cp -f config/unicorn.rb.example config/unicorn.rb
|
||||||
chown -R "$app:www-data" "$install_dir/config/unicorn.rb"
|
chown -R "$app:www-data" "$install_dir/config/unicorn.rb"
|
||||||
ynh_gem install rubygems-update -v 3.4
|
gem install rubygems-update -v 3.4
|
||||||
ynh_gem update --system --no-document
|
gem update --system --no-document
|
||||||
ynh_gem install bundler -v 2.4.22
|
gem install bundler -v 2.4.22
|
||||||
ynh_gem install rake foreman --no-document
|
gem install rake foreman --no-document
|
||||||
bundle config set --local deployment 'true'
|
bundle config set --local deployment 'true'
|
||||||
bundle config set --local without 'development test'
|
bundle config set --local without 'development test'
|
||||||
bundle install
|
bundle install
|
||||||
ynh_exec_warn_less bundle exec rake db:migrate RAILS_ENV=production
|
ynh_hide_warnings bundle exec rake db:migrate RAILS_ENV=production
|
||||||
ynh_exec_warn_less bundle exec rake assets:clean assets:precompile tmp:cache:clear RAILS_ENV=production
|
ynh_hide_warnings bundle exec rake assets:clean assets:precompile tmp:cache:clear RAILS_ENV=production
|
||||||
popd
|
popd
|
||||||
|
|
||||||
chmod 750 "$install_dir/public"
|
chmod 750 "$install_dir/public"
|
||||||
|
@ -71,29 +71,29 @@ chown -R "$app:www-data" "$install_dir/public"
|
||||||
#=================================================
|
#=================================================
|
||||||
# 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="web.service"
|
ynh_config_add_systemd --service="$app-web" --template="web.service"
|
||||||
yunohost service add "$app-web" --log="$install_dir/log/unicorn.log"
|
yunohost service add "$app-web" --log="$install_dir/log/unicorn.log"
|
||||||
|
|
||||||
ynh_add_systemd_config --service="$app-jobs" --template="jobs.service"
|
ynh_config_add_systemd --service="$app-jobs" --template="jobs.service"
|
||||||
yunohost service add "$app-jobs" --log="$install_dir/log/production.log"
|
yunohost service add "$app-jobs" --log="$install_dir/log/production.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting $app's systemd service..."
|
ynh_script_progression "Starting $app's systemd service..."
|
||||||
|
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="$install_dir/log/unicorn.log" --line_match="listening on addr"
|
ynh_systemctl --service="$app-web" --action="start" --log_path="$install_dir/log/unicorn.log" --wait_until="listening on addr"
|
||||||
ynh_systemd_action --service_name="$app-jobs" --action="start" --log_path="$install_dir/log/huginn-jobs.log" --line_match="Starting"
|
ynh_systemctl --service="$app-jobs" --action="start" --log_path="$install_dir/log/huginn-jobs.log" --wait_until="Starting"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrade of $app completed"
|
ynh_script_progression "Upgrade of $app completed"
|
||||||
|
|
Loading…
Add table
Reference in a new issue