1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/biboumi_ynh.git synced 2024-09-03 18:15:58 +02:00
This commit is contained in:
Salamandar 2024-07-01 15:36:20 +02:00
parent 066e0e1178
commit aeb3d5228e
6 changed files with 67 additions and 182 deletions

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -9,115 +7,70 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
shared_secret="$(ynh_string_random 25)"
admin_jid="${admin}@$app.${domain}"
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
#REMOVEME? ynh_script_progression --message="Validating installation parameters..."
if dpkg --compare-versions "$(uname -r)" "<=" "4.0"
then
if dpkg --compare-versions "$(uname -r)" "<=" "4.0"; then
ynh_die "Upgrade your kernel first. Unsupported version: $(uname -r)"
fi
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=shared_secret --value=$shared_secret
ynh_app_setting_set --app=$app --key=admin_jid --value=$admin_jid
#=================================================
# INSTALL DEPENDENCIES
# INITIALIZE AND STORE SETTINGS
#=================================================
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
shared_secret="$(ynh_string_random 25)"
ynh_app_setting_set --app="$app" --key="shared_secret" --value="$shared_secret"
#=================================================
# SPECIFIC SETUP
#=================================================
# CONFIGURE METRONOME
#=================================================
ynh_script_progression --message="Configuring Metronome..."
# Add metronome component
ynh_add_config --template="../conf/biboumi.cfg.lua" --destination="/etc/metronome/conf.d/$app.cfg.lua"
chown metronome:metronome "/etc/metronome/conf.d/$app.cfg.lua"
ynh_systemd_action --service_name=metronome --action="restart"
admin_jid="${admin}@${app}.${domain}"
ynh_app_setting_set --app="$app" --key="admin_jid" --value="$admin_jid"
#=================================================
# CREATE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Creating a data directory..."
mkdir -p /var/lib/$app
ynh_script_progression --message="Setting up the data directory..."
# Set permissions to app files
chown -R _biboumi:_biboumi "/var/lib/$app"
#=================================================
# ADD A CONFIGURATION
# APP INITIAL CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..."
ynh_script_progression --message="Adding $app's configuration files..." --weight=1
# Stop the service started by apt install
ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd"
# Add metronome component
ynh_add_config --template="metronome.cfg.lua" --destination="/etc/metronome/conf.d/$app.cfg.lua"
chown metronome:metronome "/etc/metronome/conf.d/$app.cfg.lua"
ynh_systemd_action --service_name="metronome" --action="restart"
# Add biboumi configuration
mkdir -p "/etc/$app/"
ynh_add_config --template="../conf/biboumi.cfg" --destination="/etc/$app/$app.cfg"
ynh_add_config --template="biboumi.cfg" --destination="/etc/$app/$app.cfg"
chown -R _biboumi:_biboumi "/etc/$app/$app.cfg"
#=================================================
# 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 systemd config
systemctl enable $app.service --quiet
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..."
mkdir -p /var/log/$app
chown -R _biboumi:_biboumi "/var/log/$app"
systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
chown -R _biboumi:_biboumi "/var/log/$app"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --line_match="Started Biboumi" --log_path="systemd"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..."
# Prevent conflict with other apps on the same domain
ynh_app_setting_set --app=$app --key=no_sso --value=1
ynh_systemd_action --service_name="$app" --action="start" --line_match="Started Biboumi" --log_path="systemd"
#=================================================
# END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -10,37 +8,22 @@ source _common.sh
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 >/dev/null
then
ynh_script_progression --message="Removing $app service integration..."
yunohost service remove $app
if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
yunohost service remove "$app"
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped Biboumi" --log_path="systemd"
systemctl disable $app.service --quiet
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
ynh_systemd_action --service_name="$app" --action="stop" --line_match="Stopped Biboumi" --log_path="systemd"
systemctl disable "$app.service" --quiet
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
@ -52,8 +35,6 @@ ynh_secure_remove --file="/var/lib/$app"
# Remove a directory securely
ynh_secure_remove --file="/etc/$app"
# Remove the log files
# Remove Metronome component
ynh_secure_remove --file="/etc/metronome/conf.d/$app.cfg.lua"
ynh_systemd_action --action=restart --service_name=metronome

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -15,56 +13,47 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
if dpkg --compare-versions "$(uname -r)" "<=" "4.0"
then
if dpkg --compare-versions "$(uname -r)" "<=" "4.0"; then
ynh_die "Upgrade your kernel first. Unsupported version: $(uname -r)"
fi
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="/var/lib/$app"
chown -R _biboumi:_biboumi "/var/lib/$app"
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..."
ynh_restore_file --origin_path="/etc/$app"
chown -R _biboumi:_biboumi /etc/$app
ynh_restore_file --origin_path="/var/lib/$app"
chown -R _biboumi:_biboumi /var/lib/$app
chown -R _biboumi:_biboumi "/etc/$app"
ynh_restore_file --origin_path="/etc/metronome/conf.d/$app.cfg.lua"
chown metronome:metronome "/etc/metronome/conf.d/$app.cfg.lua"
ynh_systemd_action --service_name=metronome --action="restart"
#=================================================
# 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
systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
mkdir -p /var/log/$app
chown -R _biboumi:_biboumi "/var/log/$app"
systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
chown -R _biboumi:_biboumi "/var/log/$app"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
yunohost service add $app --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=$app --action="start" --line_match="Started Biboumi" --log_path="systemd"
ynh_systemd_action --service_name="$app" --action="start" --line_match="Started Biboumi" --log_path="systemd"
#=================================================
# END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -9,41 +7,17 @@
source _common.sh
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 service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped Biboumi" --log_path="systemd"
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPGRADE METRONOME COMPONENT
#=================================================
ynh_script_progression --message="Upgrading Metronome component..."
# Upgrade metronome component
ynh_add_config --template="../conf/biboumi.cfg.lua" --destination="/etc/metronome/conf.d/$app.cfg.lua"
chown metronome:metronome "/etc/metronome/conf.d/$app.cfg.lua"
ynh_systemd_action --service_name=metronome --action="restart"
ynh_systemd_action --service_name="$app" --action="stop" --line_match="Stopped Biboumi" --log_path="systemd"
#=================================================
# CREATE DIRECTORIES
#=================================================
ynh_script_progression --message="Creating a data directory..."
mkdir -p /var/lib/$app
ynh_script_progression --message="Setting up the data directory..."
# Set permissions to app files
chown -R _biboumi:_biboumi "/var/lib/$app"
@ -51,46 +25,36 @@ chown -R _biboumi:_biboumi "/var/lib/$app"
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
ynh_script_progression --message="Updating $app's configuration files..." --weight=1
ynh_add_config --template="../conf/biboumi.cfg" --destination="/etc/$app/$app.cfg"
# Upgrade metronome component
ynh_add_config --template="metronome.cfg.lua" --destination="/etc/metronome/conf.d/$app.cfg.lua"
chown metronome:metronome "/etc/metronome/conf.d/$app.cfg.lua"
ynh_systemd_action --service_name=metronome --action="restart"
# Upgrade biboumi configuration
ynh_add_config --template="biboumi.cfg" --destination="/etc/$app/$app.cfg"
chown -R _biboumi:_biboumi "/etc/$app/$app.cfg"
#=================================================
# 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 systemd config
systemctl enable $app.service --quiet
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..."
mkdir -p /var/log/$app
chown -R _biboumi:_biboumi "/var/log/$app"
systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="XMPP gateway for the IRC network" --log="/var/log/$app/$app.log"
chown -R _biboumi:_biboumi "/var/log/$app"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_script_progression --message="Starting $app's systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --line_match="Started Biboumi" --log_path="systemd"
ynh_systemd_action --service_name="$app" --action="start" --line_match="Started Biboumi" --log_path="systemd"
#=================================================
# END OF SCRIPT