forked from Git/send_ynh
		
	Apply last example_ynh
This commit is contained in:
		@@ -24,9 +24,25 @@ port=$(ynh_app_setting_get --app=$app --key=port)
 | 
			
		||||
#=================================================
 | 
			
		||||
# CHECK VERSION
 | 
			
		||||
#=================================================
 | 
			
		||||
ynh_script_progression --message="Checking version..."
 | 
			
		||||
 | 
			
		||||
upgrade_type=$(ynh_check_app_version_changed)
 | 
			
		||||
 | 
			
		||||
#=================================================
 | 
			
		||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
 | 
			
		||||
#=================================================
 | 
			
		||||
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10
 | 
			
		||||
 | 
			
		||||
# Backup the current version of the app
 | 
			
		||||
ynh_backup_before_upgrade
 | 
			
		||||
ynh_clean_setup () {
 | 
			
		||||
	ynh_clean_check_starting
 | 
			
		||||
	# Restore it if the upgrade fails
 | 
			
		||||
	ynh_restore_upgradebackup
 | 
			
		||||
}
 | 
			
		||||
# Exit if an error occurs during the execution of the script
 | 
			
		||||
ynh_abort_if_errors
 | 
			
		||||
 | 
			
		||||
#=================================================
 | 
			
		||||
# STANDARD UPGRADE STEPS
 | 
			
		||||
#=================================================
 | 
			
		||||
@@ -36,20 +52,6 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1
 | 
			
		||||
 | 
			
		||||
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd"
 | 
			
		||||
 | 
			
		||||
#=================================================
 | 
			
		||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
 | 
			
		||||
#=================================================
 | 
			
		||||
ynh_script_progression --message="Backing up $app before upgrading (may take a while)..." --weight=10
 | 
			
		||||
 | 
			
		||||
# Backup the current version of the app
 | 
			
		||||
ynh_backup_before_upgrade
 | 
			
		||||
ynh_clean_setup () {
 | 
			
		||||
	# restore it if the upgrade fails
 | 
			
		||||
	ynh_restore_upgradebackup
 | 
			
		||||
}
 | 
			
		||||
# Exit if an error occurs during the execution of the script
 | 
			
		||||
ynh_abort_if_errors
 | 
			
		||||
 | 
			
		||||
#=================================================
 | 
			
		||||
# CREATE DEDICATED USER
 | 
			
		||||
#=================================================
 | 
			
		||||
@@ -75,6 +77,14 @@ chmod -R o-rwx "$final_path"
 | 
			
		||||
chown -R $app:www-data "$final_path"
 | 
			
		||||
chmod +x "$final_path/server/bin/prod.js"
 | 
			
		||||
 | 
			
		||||
#=================================================
 | 
			
		||||
# UPGRADE DEPENDENCIES
 | 
			
		||||
#=================================================
 | 
			
		||||
ynh_script_progression --message="Upgrading dependencies..." --weight=18
 | 
			
		||||
 | 
			
		||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
 | 
			
		||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
 | 
			
		||||
 | 
			
		||||
#=================================================
 | 
			
		||||
# NGINX CONFIGURATION
 | 
			
		||||
#=================================================
 | 
			
		||||
@@ -83,19 +93,11 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
 | 
			
		||||
# Create a dedicated NGINX config
 | 
			
		||||
ynh_add_nginx_config
 | 
			
		||||
 | 
			
		||||
#=================================================
 | 
			
		||||
# UPGRADE DEPENDENCIES
 | 
			
		||||
#=================================================
 | 
			
		||||
ynh_script_progression --message="Upgrading dependencies..." --weight=18
 | 
			
		||||
 | 
			
		||||
# Install Nodejs
 | 
			
		||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
 | 
			
		||||
 | 
			
		||||
#=================================================
 | 
			
		||||
# SPECIFIC UPGRADE
 | 
			
		||||
#================================================
 | 
			
		||||
#=================================================
 | 
			
		||||
# INSTALL SEND
 | 
			
		||||
#================================================
 | 
			
		||||
#=================================================
 | 
			
		||||
 | 
			
		||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
 | 
			
		||||
then
 | 
			
		||||
@@ -105,17 +107,21 @@ then
 | 
			
		||||
		ynh_use_nodejs
 | 
			
		||||
		ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install
 | 
			
		||||
		ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm run build
 | 
			
		||||
		ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm ci --production
 | 
			
		||||
		ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm cache clean --force
 | 
			
		||||
	popd
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
#=================================================
 | 
			
		||||
# SETUP SYSTEMD
 | 
			
		||||
#=================================================
 | 
			
		||||
ynh_script_progression --message="Configuring a systemd service..." --weight=2
 | 
			
		||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
 | 
			
		||||
 | 
			
		||||
# Create a dedicated systemd config
 | 
			
		||||
ynh_add_systemd_config
 | 
			
		||||
 | 
			
		||||
#=================================================
 | 
			
		||||
# GENERIC FINALIZATION
 | 
			
		||||
#=================================================
 | 
			
		||||
# SETUP LOGROTATE
 | 
			
		||||
#=================================================
 | 
			
		||||
@@ -136,7 +142,7 @@ yunohost service add $app --description="Simple, private file sharing" --log="/v
 | 
			
		||||
#=================================================
 | 
			
		||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
 | 
			
		||||
 | 
			
		||||
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd"
 | 
			
		||||
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started"
 | 
			
		||||
 | 
			
		||||
#=================================================
 | 
			
		||||
# RELOAD NGINX
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user