1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/prosody_ynh.git synced 2024-09-03 20:15:57 +02:00

[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-31 02:54:51 +02:00 committed by Alexandre Aubin
parent 9f9035604c
commit 1bacf49b54
7 changed files with 114 additions and 172 deletions

View file

@ -16,7 +16,8 @@ admindoc = "https://prosody.im/doc"
code = "https://hg.prosody.im/" code = "https://hg.prosody.im/"
[integration] [integration]
yunohost = ">= 11.2" yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all" architectures = "all"
multi_instance = false multi_instance = false

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES AND CUSTOM HELPERS
#================================================= #=================================================
if [[ $(lsb_release --codename --short) == "bookworm" ]]; then if [[ $(lsb_release --codename --short) == "bookworm" ]]; then
@ -9,15 +9,3 @@ if [[ $(lsb_release --codename --short) == "bookworm" ]]; then
else else
luaversion="5.2" luaversion="5.2"
fi fi
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,33 +1,24 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
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 CONFIG DIR # BACKUP THE CONFIG DIR
#================================================= #=================================================
ynh_backup --src_path="$config_path" ynh_backup "$config_path"
#================================================= #=================================================
# BACKUP THE DATA DIR # BACKUP THE DATA DIR
#================================================= #=================================================
ynh_backup --src_path="$data_dir" --is_big ynh_backup "$data_dir"
ynh_backup --src_path="/var/lib/$app" ynh_backup "/var/lib/$app"
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
@ -35,16 +26,16 @@ ynh_backup --src_path="/var/lib/$app"
# BACKUP LOGROTATE # BACKUP LOGROTATE
#================================================= #=================================================
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup "/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD
#================================================= #=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup "/etc/systemd/system/$app.service"
#================================================= #=================================================
# 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

@ -1,29 +1,23 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# DISABLE METRONOME # DISABLE METRONOME
#================================================= #=================================================
ynh_script_progression --message="Disabling Metronome..." ynh_script_progression "Disabling Metronome..."
if systemctl list-unit-files metronome.service &>/dev/null if systemctl list-unit-files metronome.service &>/dev/null
then then
ynh_systemd_action --service_name="metronome" --action="stop" ynh_systemctl --service="metronome" --action="stop"
systemctl disable metronome.service --quiet systemctl disable metronome.service --quiet
fi fi
#================================================= #=================================================
# 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..."
builddir="$(mktemp -d)" builddir="$(mktemp -d)"
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
@ -34,7 +28,7 @@ ynh_setup_source --dest_dir="$builddir"
#================================================= #=================================================
# BUILD PROSODY # BUILD PROSODY
#================================================= #=================================================
ynh_script_progression --message="Building Prosody..." ynh_script_progression "Building Prosody..."
update-alternatives --set lua-interpreter /usr/bin/lua${luaversion} update-alternatives --set lua-interpreter /usr/bin/lua${luaversion}
@ -44,76 +38,74 @@ pushd "$builddir"
make install make install
popd popd
ynh_secure_remove --file="$builddir" ynh_safe_rm "$builddir"
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." ynh_script_progression "Adding $app's configuration..."
config_path=/etc/$app config_path=/etc/$app
ynh_app_setting_set --app=$app --key=config_path --value=$config_path ynh_app_setting_set --key=config_path --value=$config_path
mkdir -p $config_path mkdir -p $config_path
mkdir -p $config_path/{certs,conf.avail,conf.d} mkdir -p $config_path/{certs,conf.avail,conf.d}
ynh_add_config --template="../conf/prosody.cfg.lua" --destination="$config_path/prosody.cfg.lua" ynh_config_add --template="prosody.cfg.lua" --destination="$config_path/prosody.cfg.lua"
ynh_add_config --template="../conf/example.com.cfg.lua" --destination="$config_path/conf.avail/example.com.cfg.lua" ynh_config_add --template="example.com.cfg.lua" --destination="$config_path/conf.avail/example.com.cfg.lua"
#ynh_add_config --template="../conf/localhost.cfg.lua" --destination="$config_path/conf.avail/localhost.cfg.lua" #ynh_config_add --template="localhost.cfg.lua" --destination="$config_path/conf.avail/localhost.cfg.lua"
#ln -s $config_path/conf.avail/localhost.cfg.lua $config_path/conf.d/ #ln -s $config_path/conf.avail/localhost.cfg.lua $config_path/conf.d/
chown root:root "$config_path" #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 root:root "$config_path"
chmod 755 "$config_path" #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 755 "$config_path"
chown root:$app "$config_path/conf.d" #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 root:$app "$config_path/conf.d"
chmod 754 "$config_path/conf.d" #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 754 "$config_path/conf.d"
chown root:$app "$config_path/conf.avail" #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 root:$app "$config_path/conf.avail"
chmod 754 "$config_path/conf.avail" #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 754 "$config_path/conf.avail"
chown root:$app "$config_path/certs" #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 root:$app "$config_path/certs"
chmod 750 "$config_path/certs" #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 750 "$config_path/certs"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." ynh_script_progression "Configuring $app's systemd service..."
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_config_add_systemd
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Configuring log rotation..." ynh_script_progression "Configuring log rotation..."
mkdir -p "/var/log/$app" mkdir -p "/var/log/$app"
chmod 750 "/var/log/$app" #REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "/var/log/$app"
chmod -R o-rwx "/var/log/$app" #REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "/var/log/$app"
chown -R $app:adm "/var/log/$app" #REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:adm "/var/log/$app"
chown -R $app:$app "/var/lib/$app" chown -R $app:$app "/var/lib/$app"
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate ynh_config_add_logrotate
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression "Integrating service in YunoHost..."
yunohost service add $app --log="/var/log/$app/$app.log" yunohost service add $app --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemctl --service=$app --action="start"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" ynh_script_progression "Installation of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -14,51 +8,51 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST # REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 ynh_script_progression "Removing system configurations related to $app..."
if ynh_exec_warn_less yunohost service status $app >/dev/null if ynh_hide_warnings yunohost service status $app >/dev/null
then then
ynh_script_progression --message="Removing $app service integration..." ynh_script_progression "Removing $app service integration..."
yunohost service remove $app yunohost service remove $app
fi fi
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_config_remove_systemd
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_config_remove_logrotate
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
#================================================= #=================================================
# REMOVE VARIOUS FILES # REMOVE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Removing various files..." --weight=1 ynh_script_progression "Removing various files..."
# Remove a directory securely # Remove a directory securely
ynh_secure_remove --file="$config_path" ynh_safe_rm "$config_path"
# Remove the log files # Remove the log files
ynh_secure_remove --file="/run/$app" ynh_safe_rm "/run/$app"
ynh_secure_remove --file="/var/lib/$app" ynh_safe_rm "/var/lib/$app"
ynh_secure_remove --file="/usr/bin/prosody" ynh_safe_rm "/usr/bin/prosody"
ynh_secure_remove --file="/usr/bin/prosodyctl" ynh_safe_rm "/usr/bin/prosodyctl"
ynh_secure_remove --file="/usr/bin/prosody-migrator" ynh_safe_rm "/usr/bin/prosody-migrator"
#================================================= #=================================================
# ENABLE METRONOME # ENABLE METRONOME
#================================================= #=================================================
ynh_script_progression --message="Enabling Metronome..." --weight=1 ynh_script_progression "Enabling Metronome..."
if systemctl list-unit-files metronome.service &>/dev/null if systemctl list-unit-files metronome.service &>/dev/null
then then
systemctl enable metronome.service --quiet systemctl enable metronome.service --quiet
ynh_systemd_action --service_name="metronome" --action="start" ynh_systemctl --service="metronome" --action="start"
fi fi
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --last ynh_script_progression "Removal of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -13,45 +7,45 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# DISABLE METRONOME # DISABLE METRONOME
#================================================= #=================================================
ynh_script_progression --message="Disabling Metronome..." --weight=1 ynh_script_progression "Disabling Metronome..."
if systemctl list-unit-files metronome.service &>/dev/null if systemctl list-unit-files metronome.service &>/dev/null
then then
ynh_systemd_action --service_name="metronome" --action="stop" ynh_systemctl --service="metronome" --action="stop"
systemctl disable metronome.service --quiet systemctl disable metronome.service --quiet
fi fi
#================================================= #=================================================
# RESTORE THE CONFIG DIR # RESTORE THE CONFIG DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the config directory..." --weight=1 ynh_script_progression "Restoring the config directory..."
ynh_restore_file --origin_path="$config_path" ynh_restore "$config_path"
mkdir -p $config_path mkdir -p $config_path
mkdir -p $config_path/{certs,conf.avail,conf.d} mkdir -p $config_path/{certs,conf.avail,conf.d}
#ln -s $config_path/conf.avail/localhost.cfg.lua $config_path/conf.d/ #ln -s $config_path/conf.avail/localhost.cfg.lua $config_path/conf.d/
chown root:root "$config_path" #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 root:root "$config_path"
chmod 755 "$config_path" #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 755 "$config_path"
chown root:$app "$config_path/conf.d" #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 root:$app "$config_path/conf.d"
chmod 754 "$config_path/conf.d" #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 754 "$config_path/conf.d"
chown root:$app "$config_path/conf.avail" #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 root:$app "$config_path/conf.avail"
chmod 754 "$config_path/conf.avail" #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 754 "$config_path/conf.avail"
chown root:$app "$config_path/certs" #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 root:$app "$config_path/certs"
chmod 750 "$config_path/certs" #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 750 "$config_path/certs"
#================================================= #=================================================
# RESTORE THE DATA DIRECTORY # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1 ynh_script_progression "Restoring the data directory..."
ynh_restore_file --origin_path="$data_dir" --not_mandatory ynh_restore "$data_dir"
ynh_restore_file --origin_path="/var/lib/$app" --not_mandatory ynh_restore "/var/lib/$app" || true
chown -R $app:$app "$data_dir" chown -R $app:$app "$data_dir"
chown -R $app:$app "/var/lib/$app" chown -R $app:$app "/var/lib/$app"
@ -59,41 +53,39 @@ chown -R $app:$app "/var/lib/$app"
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_script_progression "Restoring $app's systemd service..."
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore "/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet systemctl enable $app.service --quiet
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # RESTORE THE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 ynh_script_progression "Restoring the logrotate configuration..."
mkdir -p "/var/log/$app" mkdir -p "/var/log/$app"
chmod 750 "/var/log/$app" #REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "/var/log/$app"
chmod -R o-rwx "/var/log/$app" #REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "/var/log/$app"
chown -R $app:adm "/var/log/$app" #REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:adm "/var/log/$app"
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore "/etc/logrotate.d/$app"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression "Integrating service in YunoHost..."
yunohost service add $app --log="/var/log/$app/$app.log" yunohost service add $app --log="/var/log/$app/$app.log"
#================================================= #=================================================
# 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 --action="start" --log_path="/var/log/$app/$app.log" ynh_systemctl --service=$app --action="start"
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" --last ynh_script_progression "Restoration completed for $app"

View file

@ -1,61 +1,47 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# DISABLE METRONOME # DISABLE METRONOME
#================================================= #=================================================
ynh_script_progression --message="Disabling Metronome..." ynh_script_progression "Disabling Metronome..."
if systemctl list-unit-files metronome.service &>/dev/null if systemctl list-unit-files metronome.service &>/dev/null
then then
ynh_systemd_action --service_name="metronome" --action="stop" ynh_systemctl --service="metronome" --action="stop"
systemctl disable metronome.service --quiet systemctl disable metronome.service --quiet
fi fi
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" ynh_systemctl --service=$app --action="stop"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ] # FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
if ynh_app_upstream_version_changed
then then
ynh_script_progression --message="Upgrading source files..." ynh_script_progression "Upgrading source files..."
builddir="$(mktemp -d)" builddir="$(mktemp -d)"
# 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="$builddir" ynh_setup_source --dest_dir="$builddir"
fi fi
#=================================================
# SPECIFIC UPGRADE
#================================================= #=================================================
# BUILD PROSODY # BUILD PROSODY
#================================================= #=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ] # FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
if ynh_app_upstream_version_changed
then then
ynh_script_progression --message="Building Prosody..." ynh_script_progression "Building Prosody..."
update-alternatives --set lua-interpreter /usr/bin/lua${luaversion} update-alternatives --set lua-interpreter /usr/bin/lua${luaversion}
@ -65,74 +51,72 @@ then
make install make install
popd popd
ynh_secure_remove --file="$builddir" ynh_safe_rm "$builddir"
fi fi
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." ynh_script_progression "Updating configuration..."
mkdir -p $config_path mkdir -p $config_path
mkdir -p $config_path/{certs,conf.avail,conf.d} mkdir -p $config_path/{certs,conf.avail,conf.d}
ynh_add_config --template="../conf/prosody.cfg.lua" --destination="$config_path/prosody.cfg.lua" ynh_config_add --template="prosody.cfg.lua" --destination="$config_path/prosody.cfg.lua"
ynh_add_config --template="../conf/example.com.cfg.lua" --destination="$config_path/conf.avail/example.com.cfg.lua" ynh_config_add --template="example.com.cfg.lua" --destination="$config_path/conf.avail/example.com.cfg.lua"
#ynh_add_config --template="../conf/localhost.cfg.lua" --destination="$config_path/conf.avail/localhost.cfg.lua" #ynh_config_add --template="localhost.cfg.lua" --destination="$config_path/conf.avail/localhost.cfg.lua"
#ln -s $config_path/conf.avail/localhost.cfg.lua $config_path/conf.d/ #ln -s $config_path/conf.avail/localhost.cfg.lua $config_path/conf.d/
chown root:root "$config_path" #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 root:root "$config_path"
chmod 755 "$config_path" #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 755 "$config_path"
chown root:$app "$config_path/conf.d" #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 root:$app "$config_path/conf.d"
chmod 754 "$config_path/conf.d" #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 754 "$config_path/conf.d"
chown root:$app "$config_path/conf.avail" #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 root:$app "$config_path/conf.avail"
chmod 754 "$config_path/conf.avail" #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 754 "$config_path/conf.avail"
chown root:$app "$config_path/certs" #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 root:$app "$config_path/certs"
chmod 750 "$config_path/certs" #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 750 "$config_path/certs"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Upgrading systemd configuration..." ynh_script_progression "Upgrading systemd configuration..."
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_config_add_systemd
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." ynh_script_progression "Upgrading logrotate configuration..."
mkdir -p "/var/log/$app" mkdir -p "/var/log/$app"
chmod 750 "/var/log/$app" #REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "/var/log/$app"
chmod -R o-rwx "/var/log/$app" #REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "/var/log/$app"
chown -R $app:adm "/var/log/$app" #REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:adm "/var/log/$app"
chown -R $app:$app "/var/lib/$app" chown -R $app:$app "/var/lib/$app"
# 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
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression "Integrating service in YunoHost..."
yunohost service add $app --log="/var/log/$app/$app.log" yunohost service add $app --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemctl --service=$app --action="start"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" ynh_script_progression "Upgrade of $app completed"