jwe_ynh 2.0.0~ynh1 — paquet YunoHost initial (format v2, helpers 2.1)

This commit is contained in:
sucupira
2026-07-19 19:58:37 -04:00
commit 4869e6463c
17 changed files with 517 additions and 0 deletions
Executable
+34
View File
@@ -0,0 +1,34 @@
#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
ynh_print_info "Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup "$install_dir"
#=================================================
# BACKUP SYSTEM CONFIGURATION
#=================================================
# Backup the NGINX configuration
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
# Backup the systemd service unit
ynh_backup "/etc/systemd/system/$app.service"
# Backup the logrotate configuration
ynh_backup "/etc/logrotate.d/$app"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
+43
View File
@@ -0,0 +1,43 @@
#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemctl --service="$app" --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression "Updating NGINX web server configuration..."
# this will most likely adjust NGINX config correctly
ynh_config_change_url_nginx
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression "Updating $app's configuration files..."
# $domain contient désormais le nouveau domaine (ORIGIN)
ynh_config_add --template="env" --destination="$install_dir/app/.env"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression "Starting $app's systemd service..."
ynh_systemctl --service="$app" --action="start" --wait_until="Listening" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Change of URL completed for $app"
+64
View File
@@ -0,0 +1,64 @@
#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression "Setting up source files..."
ynh_setup_source --dest_dir="$install_dir"
chown -R "$app:$app" "$install_dir"
#=================================================
# BUILD THE APP
#=================================================
ynh_script_progression "Building $app (this may take a few minutes)..."
pushd "$install_dir/app"
ynh_hide_warnings ynh_exec_as_app npm ci
ynh_hide_warnings ynh_exec_as_app npm run build
ynh_hide_warnings ynh_exec_as_app npm prune --omit=dev
popd
#=================================================
# APP INITIAL CONFIGURATION
#=================================================
ynh_script_progression "Adding $app's configuration files..."
ynh_config_add --template="env" --destination="$install_dir/app/.env"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression "Adding system configurations related to $app..."
# Create a dedicated NGINX config using the conf/nginx.conf template
ynh_config_add_nginx
# Create a dedicated systemd config
ynh_config_add_systemd
yunohost service add "$app" --description="Jeu de géolocalisation OKI" --log="/var/log/$app/$app.log"
# Use logrotate to manage application logfile(s)
mkdir -p "/var/log/$app"
chown -R "$app:$app" "/var/log/$app"
ynh_config_add_logrotate
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression "Starting $app's systemd service..."
ynh_systemctl --service="$app" --action="start" --wait_until="Listening" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Installation of $app completed"
Executable
+29
View File
@@ -0,0 +1,29 @@
#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
#=================================================
# REMOVE SYSTEM CONFIGURATION
#=================================================
ynh_script_progression "Removing system configurations related to $app..."
ynh_config_remove_logrotate
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_hide_warnings yunohost service status "$app" >/dev/null; then
yunohost service remove "$app"
fi
ynh_config_remove_systemd
ynh_config_remove_nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Removal of $app completed"
+47
View File
@@ -0,0 +1,47 @@
#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression "Restoring the app main directory..."
ynh_restore "$install_dir"
chown -R "$app:$app" "$install_dir"
#=================================================
# RESTORE SYSTEM CONFIGURATION
#=================================================
ynh_script_progression "Restoring system configurations related to $app..."
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/systemd/system/$app.service"
systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="Jeu de géolocalisation OKI" --log="/var/log/$app/$app.log"
mkdir -p "/var/log/$app"
chown -R "$app:$app" "/var/log/$app"
ynh_restore "/etc/logrotate.d/$app"
#=================================================
# RELOAD NGINX AND START THE APP SERVICE
#=================================================
ynh_script_progression "Reloading NGINX web server and $app's service..."
ynh_systemctl --service="$app" --action="start" --wait_until="Listening" --log_path="/var/log/$app/$app.log"
ynh_systemctl --service=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Restoration completed for $app"
+68
View File
@@ -0,0 +1,68 @@
#!/bin/bash
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression "Stopping $app's systemd service..."
ynh_systemctl --service="$app" --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression "Upgrading source files..."
ynh_setup_source --dest_dir="$install_dir" --full_replace
chown -R "$app:$app" "$install_dir"
#=================================================
# RE-BUILD THE APP
#=================================================
ynh_script_progression "Building $app (this may take a few minutes)..."
pushd "$install_dir/app"
ynh_hide_warnings ynh_exec_as_app npm ci
ynh_hide_warnings ynh_exec_as_app npm run build
ynh_hide_warnings ynh_exec_as_app npm prune --omit=dev
popd
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression "Updating $app's configuration files..."
ynh_config_add --template="env" --destination="$install_dir/app/.env"
#=================================================
# REAPPLY SYSTEM CONFIGURATION
#=================================================
ynh_script_progression "Upgrading system configurations related to $app..."
ynh_config_add_nginx
ynh_config_add_systemd
yunohost service add "$app" --description="Jeu de géolocalisation OKI" --log="/var/log/$app/$app.log"
mkdir -p "/var/log/$app"
chown -R "$app:$app" "/var/log/$app"
ynh_config_add_logrotate
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression "Starting $app's systemd service..."
ynh_systemctl --service="$app" --action="start" --wait_until="Listening" --log_path="/var/log/$app/$app.log"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Upgrade of $app completed"