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

Fix linter warnings

This commit is contained in:
ericgaspar 2020-11-22 23:36:37 +01:00
parent 463b065e4a
commit b6428a51ef
No known key found for this signature in database
GPG key ID: 574F281483054D44
6 changed files with 139 additions and 67 deletions

View file

@ -42,7 +42,7 @@ SETUP_SOURCE () { # Télécharge la source, décompresse et copie dans $final_pa
fi
}
#=================================================
#=================================================
# FUTUR YNH HELPERS
#=================================================
@ -50,38 +50,6 @@ SETUP_SOURCE () { # Télécharge la source, décompresse et copie dans $final_pa
# Ainsi, les officiels prendront le pas sur ceux-ci le cas échéant
#=================================================
# Manage a fail of the script
#
# Print a warning to inform that the script was failed
# Execute the ynh_clean_setup function if used in the app script
#
# usage of ynh_clean_setup function
# This function provide a way to clean some residual of installation that not managed by remove script.
# To use it, simply add in your script:
# ynh_clean_setup () {
# instructions...
# }
# This function is optionnal.
#
# Usage: ynh_exit_properly is used only by the helper ynh_check_error.
# You must not use it directly.
ynh_exit_properly () {
exit_code=$?
if [ "$exit_code" -eq 0 ]; then
exit 0 # Exit without error if the script ended correctly
fi
trap '' EXIT # Ignore new exit signals
set +eu # Do not exit anymore if a command fail or if a variable is empty
echo -e "!!\n $app's script has encountered an error. Its execution was cancelled.\n!!" >&2
if type -t ynh_clean_setup > /dev/null; then # Check if the function exist in the app script.
ynh_clean_setup # Call the function to do specific cleaning for the app.
fi
ynh_die # Exit with error status
}
# Exit if an error occurs during the execution of the script.
#

View file

@ -1,18 +1,48 @@
#!/bin/bash
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
set -eu
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Source YNH helpers
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
# Retrieve app settings
domain=$(ynh_app_setting_get $app domain)
# Save sources & data
ynh_backup "/var/www/${app}" "sources"
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
# Copy NGINX configuration
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="/var/www/$app"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
source .fonctions
source _common.sh
source /usr/share/yunohost/helpers
#=================================================

View file

@ -1,16 +1,42 @@
#!/bin/bash
set -u
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments
domain=$(ynh_app_setting_get "$app" domain)
#=================================================
# REMOVE APP MAIN DIR
#=================================================
# Remove sources and configuration
ynh_secure_remove --file="/var/www/${app}"
ynh_secure_remove --file="/etc/nginx/conf.d/${domain}.d/${app}.conf"
ynh_secure_remove --file="/var/www/$app"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_secure_remove --file="/etc/nginx/conf.d/$domain.d/$app.conf"
# Reload services
sudo service nginx reload
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -1,21 +1,47 @@
#!/bin/bash
# causes the shell to exit if any subcommand or pipeline returns a non-zero status
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_abort_if_errors
# Retrieve old app settings
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_restore_file --origin_path="/var/www/$app"
# Restore sources & data
cp -a ./sources "/var/www/${app}"
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
# Restore Nginx and YunoHost parameters
cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
# Reload services
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -1,10 +1,21 @@
#!/bin/bash
source .fonctions
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
# Récupère les infos de l'application.
@ -27,22 +38,33 @@ CHECK_PATH
final_path="/var/www/${app}"
ynh_app_setting_set $app final_path $final_path
SETUP_SOURCE # Télécharge la source, décompresse et copie dans $final_path
sudo mkdir -p "${final_path}/store/conf"
sudo cp ../conf/*.xml "${final_path}/store/conf/"
mkdir -p "${final_path}/store/conf"
cp ../conf/*.xml "${final_path}/store/conf/"
# Set permissions to jappix directory
sudo chown -R www-data: "$final_path"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
chown -R www-data: "$final_path"
# Set and copy NGINX configuraion
sudo sed -i "s@PATHTOCHANGE@${path}@g" ../conf/nginx.conf
sudo sed -i "s@ALIASTOCHANGE@${final_path}/@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf"
sed -i "s@PATHTOCHANGE@${path}@g" ../conf/nginx.conf
sed -i "s@ALIASTOCHANGE@${final_path}/@g" ../conf/nginx.conf
cp ../conf/nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf"
# Set Jappix configuration
sudo sed -i "s@PATHTOCHANGE@${path}@g" "${final_path}/store/conf/hosts.xml"
sudo sed -i "s@CHANGELANG@${language}@g" "${final_path}/store/conf/main.xml"
sudo sed -i "s@CHANGENAME@${name}@g" "${final_path}/store/conf/main.xml"
sudo sed -i "s@DOMAINTOCHANGE@${domain}@g" "${final_path}/store/conf/hosts.xml"
sed -i "s@PATHTOCHANGE@${path}@g" "${final_path}/store/conf/hosts.xml"
sed -i "s@CHANGELANG@${language}@g" "${final_path}/store/conf/main.xml"
sed -i "s@CHANGENAME@${name}@g" "${final_path}/store/conf/main.xml"
sed -i "s@DOMAINTOCHANGE@${domain}@g" "${final_path}/store/conf/hosts.xml"
# Reload services
sudo service nginx reload
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last