1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/huginn_ynh.git synced 2024-09-03 19:26:13 +02:00

Apply template

This commit is contained in:
Salamandar 2024-02-23 20:33:09 +01:00
parent 37e74a9cdf
commit 28171bd0c1
6 changed files with 71 additions and 151 deletions

View file

@ -22,17 +22,11 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
# SYSTEM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app-web.service"
ynh_backup --src_path="/etc/systemd/system/$app-jobs.service"

View file

@ -9,15 +9,13 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_script_progression --message="Stopping $app's systemd service..."
ynh_systemd_action --service_name=$app-web --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app-jobs --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-web" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-jobs" --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# MODIFY URL IN NGINX CONF
@ -29,23 +27,19 @@ ynh_change_url_nginx_config
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
ynh_script_progression --message="Updating $app's configuration file..."
#domain=$new_domain
#path=$new_path
ynh_add_config --template=".env.example" --destination="$install_dir/.env"
chmod 400 "$install_dir/.env"
chown $app:$app "$install_dir/.env"
chown "$app:$app" "$install_dir/.env"
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_script_progression --message="Starting $app's systemd service..."
# Start a systemd service
ynh_systemd_action --service_name="$app-web" --action="start" --log_path="/var/log/$app/$app-web.log" --line_match="listening on addr"

View file

@ -11,17 +11,17 @@ source ynh_install_ruby__2
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
# INITIALIZE AND STORE SETTINGS
#=================================================
secret=$(ynh_string_random --length=16)
ynh_app_setting_set --app=$app --key=secret --value=$secret
ynh_app_setting_set --app="$app" --key="secret" --value="$secret"
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
ynh_script_progression --message="Installing Ruby..."
ynh_install_ruby --ruby_version=$ruby_version
@ -36,34 +36,26 @@ ynh_setup_source --dest_dir="$install_dir"
mkdir -p "$install_dir/log" "$install_dir/tmp/pids" "$install_dir/tmp/sockets"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated NGINX config
ynh_add_nginx_config
chown -R "$app:www-data" "$install_dir"
#=================================================
# SPECIFIC SETUP
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
ynh_script_progression --message="Adding $app's configuration file..."
ynh_add_config --template=".env.example" --destination="$install_dir/.env"
chmod 400 "$install_dir/.env"
chown $app:$app "$install_dir/.env"
chown "$app:$app" "$install_dir/.env"
#=================================================
# BUILD APP
#=================================================
ynh_script_progression --message="Building app..."
pushd $install_dir
pushd "$install_dir"
ynh_use_ruby
cp config/unicorn.rb.example config/unicorn.rb
chown -R $app:www-data "$install_dir/config/unicorn.rb"
@ -83,28 +75,23 @@ chmod -R o-rwx "$install_dir/public"
chown -R $app:www-data "$install_dir/public"
#=================================================
# SETUP SYSTEMD
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring a systemd service..."
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config --service="$app-web" --template="web.service"
ynh_add_systemd_config --service="$app-jobs" --template="jobs.service"
#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add "$app-web" --log="$install_dir/log/unicorn.log"
yunohost service add "$app-jobs" --log="$install_dir/log/production.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_script_progression --message="Starting $app's systemd services..."
# 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"

View file

@ -11,36 +11,22 @@ source ynh_install_ruby__2
source /usr/share/yunohost/helpers
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# 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
ynh_script_progression --message="Removing $app-web service integration..."
yunohost service remove "$app-web"
if ynh_exec_warn_less yunohost service status "$app-web" >/dev/null; then
yunohost service remove "$app-web"
fi
if ynh_exec_warn_less yunohost service status "$app-jobs" >/dev/null
then
ynh_script_progression --message="Removing $app-jobs service integration..."
yunohost service remove "$app-jobs"
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config --service="$app-web"
ynh_remove_systemd_config --service="$app-jobs"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..."
if ynh_exec_warn_less yunohost service status "$app-jobs" >/dev/null; then
yunohost service remove "$app-jobs"
fi
# Remove the dedicated systemd config
ynh_remove_systemd_config --service="$app-jobs"
# Remove the dedicated NGINX config
ynh_remove_nginx_config

View file

@ -12,13 +12,11 @@ source ../settings/scripts/ynh_install_ruby__2
source /usr/share/yunohost/helpers
#=================================================
# STANDARD RESTORATION STEPS
# REINSTALL DEPENDENCIES
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_script_progression --message="Reinstalling Ruby..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_install_ruby --ruby_version=$ruby_version
#=================================================
# RESTORE THE APP MAIN DIR
@ -27,33 +25,22 @@ ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$install_dir"
mkdir -p "$install_dir/log" "$install_dir/tmp/pids" "$install_dir/tmp/sockets"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..."
ynh_install_ruby --ruby_version=$ruby_version
chown -R "$app:www-data" "$install_dir"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..."
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
#=================================================
# BUILD APP
#=================================================
ynh_script_progression --message="Building app..."
pushd $install_dir
pushd "$install_dir"
ynh_use_ruby
ynh_gem update --system --no-document
ynh_gem install rake bundler foreman --no-document
@ -65,43 +52,32 @@ popd
chmod 750 "$install_dir/public"
chmod -R o-rwx "$install_dir/public"
chown -R $app:www-data "$install_dir/public"
chown -R "$app:www-data" "$install_dir/public"
#=================================================
# RESTORE SYSTEMD
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..."
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/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"
ynh_restore_file --origin_path="/etc/systemd/system/$app-jobs.service"
systemctl enable $app-jobs.service --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add "$app-web" --log="$install_dir/log/unicorn.log"
systemctl enable "$app-jobs.service" --quiet
yunohost service add "$app-jobs" --log="$install_dir/log/production.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_script_progression --message="Reloading NGINX web server and $app's 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_systemd_action --service_name="$app-jobs" --action="start" --log_path="$install_dir/log/huginn-jobs.log" --line_match="Starting"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
#=================================================

View file

@ -10,47 +10,34 @@ source _common.sh
source ynh_install_ruby__2
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..."
ynh_script_progression --message="Stopping $app's systemd services..."
ynh_systemd_action --service_name=$app-web --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=$app-jobs --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-web" --action="stop" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name="$app-jobs" --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading Ruby..." --weight=1
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..."
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --keep=".env"
mkdir -p "$install_dir/log" "$install_dir/tmp/pids" "$install_dir/tmp/sockets"
fi
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep=".env"
mkdir -p "$install_dir/log" "$install_dir/tmp/pids" "$install_dir/tmp/sockets"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_install_ruby --ruby_version=$ruby_version
chown -R "$app:www-data" "$install_dir"
#=================================================
# SPECIFIC UPGRADE
@ -62,7 +49,7 @@ ynh_script_progression --message="Updating a configuration file..."
ynh_add_config --template="../conf/.env.example" --destination="$install_dir/.env"
chmod 400 "$install_dir/.env"
chown $app:$app "$install_dir/.env"
chown "$app:$app" "$install_dir/.env"
#=================================================
# BUILD APP
@ -72,7 +59,7 @@ ynh_script_progression --message="Building app..."
pushd $install_dir
ynh_use_ruby
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 update --system --no-document
ynh_gem install rake bundler foreman --no-document
bundle config set --local deployment 'true'
@ -84,31 +71,27 @@ popd
chmod 750 "$install_dir/public"
chmod -R o-rwx "$install_dir/public"
chown -R $app:www-data "$install_dir/public"
chown -R "$app:www-data" "$install_dir/public"
#=================================================
# SETUP SYSTEMD
# REAPPLY SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..."
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config --service="$app-web" --template="web.service"
ynh_add_systemd_config --service="$app-jobs" --template="jobs.service"
#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add "$app-web" --log="$install_dir/log/unicorn.log"
ynh_add_systemd_config --service="$app-jobs" --template="jobs.service"
yunohost service add "$app-jobs" --log="$install_dir/log/production.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_script_progression --message="Starting $app's 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"