diff --git a/conf/nginx.conf b/conf/nginx.conf index 216e7dd..82bf4b1 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -23,7 +23,7 @@ location / { #proxy_cache cache1; proxy_cache_lock on; proxy_cache_use_stale updating; - add_header X-Cache $upstream_cache_status; + more_set_headers "X-Cache: $upstream_cache_status"; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/scripts/restore b/scripts/restore index b92d080..b8c4594 100755 --- a/scripts/restore +++ b/scripts/restore @@ -38,7 +38,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." +ynh_script_progression --message="Validating restoration parameters..." --weight=1 ynh_webpath_available --domain=$domain --path_url=$path_url \ || ynh_die --message="Path not available: ${domain}${path_url}" @@ -50,19 +50,19 @@ test ! -d $final_path \ # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" --weight=1 #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." +ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" @@ -79,7 +79,7 @@ chown -R $app: $final_path #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." +ynh_script_progression --message="Reinstalling dependencies..." --weight=1 # Define and install dependencies ynh_install_nodejs --nodejs_version=$NODEJS_VERSION @@ -91,7 +91,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd @@ -100,7 +100,7 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." +ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet @@ -108,14 +108,14 @@ systemctl enable $app.service --quiet #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --description="A interplanetary blogging platform" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action=start --log_path="systemd" --line_match="All workers started" diff --git a/scripts/upgrade b/scripts/upgrade index 156729c..d4bda93 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -31,7 +31,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # If db_name doesn't exist, create it if [ -z "$db_name" ]; then @@ -55,7 +55,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 # Backup the current version of the app ynh_backup_before_upgrade @@ -71,10 +71,18 @@ ynh_abort_if_errors #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." +ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action=stop --log_path=systemd --line_match="Stopped" +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -84,16 +92,16 @@ then ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$final_path" --keep="$final_path/.config/default.yml" fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1 # Create a dedicated nginx config -ynh_add_nginx_config 'port' +ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES @@ -107,52 +115,20 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - -#================================================= -# SPECIFIC UPGRADE -#================================================= -# ADD SWAP IF NEEDED -#================================================= -# ynh_script_progression --message="Adding swap if needed..." - -# total_memory=$(ynh_get_ram --total) -# swap_needed=0 - -# if [ $total_memory -lt $MEMORY_NEEDED ]; then -# # Need a minimum of 8Go of memory -# swap_needed=$(($MEMORY_NEEDED - $total_memory)) -# fi - -# ynh_script_progression --message="Adding $swap_needed Mo to swap..." -# ynh_add_swap --size=$swap_needed - -#================================================= -# SPECIFIC UPGRADE -#================================================= - -ynh_add_config --template="../conf/default.yml" --destination="$final_path/.config/default.yml" - #================================================= # Updating process MISSKEY #================================================= pushd "$final_path" - ynh_exec_warn_lessyarn add ts-node webpack + ynh_exec_warn_less yarn install ynh_exec_warn_less NODE_ENV=production yarn build - ynh_exec_warn_less yarn run init + ynh_exec_warn_less yarn migrate popd #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." +ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config @@ -169,21 +145,21 @@ chown -R $app: $final_path #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --description="A interplanetary blogging platform" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="All workers started" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -191,4 +167,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" +ynh_script_progression --message="Upgrade of $app completed" --last