From 219301790e7d34cbc4272c6993a5952299c1dd47 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 29 Jun 2022 02:17:46 +0200 Subject: [PATCH] Apply last example_ynh --- check_process | 9 ++++--- conf/app.src | 2 ++ conf/config.js | 65 +++++++++++++++++++++++++++++++++++++++++++++ doc/.DS_Store | Bin 6148 -> 0 bytes manifest.json | 2 +- scripts/_common.sh | 5 +++- scripts/backup | 3 ++- scripts/change_url | 8 +++--- scripts/install | 61 +++++++++++++++++++++++------------------- scripts/remove | 22 ++++++++------- scripts/restore | 20 +++++++------- scripts/upgrade | 58 ++++++++++++++++++++++------------------ 12 files changed, 172 insertions(+), 83 deletions(-) delete mode 100644 doc/.DS_Store diff --git a/check_process b/check_process index d02340b..b1ea4c6 100644 --- a/check_process +++ b/check_process @@ -10,13 +10,14 @@ setup_private=1 setup_public=1 upgrade=1 + # 3.4.14~ynh1 upgrade=1 from_commit=6e2eba4a9b6b455b35ce9d8e558c454a001bfacf + # 3.4.18~ynh1 + upgrade=1 from_commit=674f8d3211ba98b10f169deea3127a8b378c6c3c backup_restore=1 multi_instance=1 + port_already_use=0 change_url=1 ;;; Options Email= -;;; Upgrade options - ; commit=6e2eba4a9b6b455b35ce9d8e558c454a001bfacf - name=3.4.14 - manifest_arg=domain=DOMAIN&is_public=1& \ No newline at end of file +Notification=none diff --git a/conf/app.src b/conf/app.src index 80810f7..3541b63 100644 --- a/conf/app.src +++ b/conf/app.src @@ -3,3 +3,5 @@ SOURCE_SUM=d8b485383f5f2fdca98501e1abdacec158b2eb04a7a8a4dabae2a0d4f542c6e4 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= +SOURCE_EXTRACT=true diff --git a/conf/config.js b/conf/config.js index f1e57bc..805dae7 100644 --- a/conf/config.js +++ b/conf/config.js @@ -1,8 +1,11 @@ const convict = require('convict'); +const convict_format_with_validator = require('convict-format-with-validator'); const { tmpdir } = require('os'); const path = require('path'); const { randomBytes } = require('crypto'); +convict.addFormats(convict_format_with_validator); + convict.addFormat({ name: 'positive-int-array', coerce: ints => { @@ -239,6 +242,68 @@ const conf = convict({ format: String, default: 'https://github.com/timvisee/send', env: 'SEND_FOOTER_SOURCE_URL' + }, + ui_color_primary: { + format: String, + default: '#0a84ff', + env: 'UI_COLOR_PRIMARY' + }, + ui_color_accent: { + format: String, + default: '#003eaa', + env: 'UI_COLOR_ACCENT' + }, + ui_custom_assets: { + android_chrome_192px: { + format: String, + default: '', + env: 'UI_CUSTOM_ASSETS_ANDROID_CHROME_192PX' + }, + android_chrome_512px: { + format: String, + default: '', + env: 'UI_CUSTOM_ASSETS_ANDROID_CHROME_512PX' + }, + apple_touch_icon: { + format: String, + default: '', + env: 'UI_CUSTOM_ASSETS_APPLE_TOUCH_ICON' + }, + favicon_16px: { + format: String, + default: '', + env: 'UI_CUSTOM_ASSETS_FAVICON_16PX' + }, + favicon_32px: { + format: String, + default: '', + env: 'UI_CUSTOM_ASSETS_FAVICON_32PX' + }, + icon: { + format: String, + default: '', + env: 'UI_CUSTOM_ASSETS_ICON' + }, + safari_pinned_tab: { + format: String, + default: '', + env: 'UI_CUSTOM_ASSETS_SAFARI_PINNED_TAB' + }, + facebook: { + format: String, + default: '', + env: 'UI_CUSTOM_ASSETS_FACEBOOK' + }, + twitter: { + format: String, + default: '', + env: 'UI_CUSTOM_ASSETS_TWITTER' + }, + wordmark: { + format: String, + default: '', + env: 'UI_CUSTOM_ASSETS_WORDMARK' + } } }); diff --git a/doc/.DS_Store b/doc/.DS_Store deleted file mode 100644 index 89d6be550c959cabe5cee10f79099a460aff7eae..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK-)mGy6h7Z(HM?eQCehX(t?X)O3@S0D7F5vQCQ+hBlqNCj4~)BeC&{fh_lBLD zP4H=@s4qU0QhgP%zDlw7Q43YUr$V7n8tfn7Kj4E;p1CtY($v=?GH03j=FB(e%)K9X zW_E}O{d4|jM1qKNTr_6aaP=Rid0kdm#`b7LnnO}Vil!;1WW{LL;S_KRylV>RwcEyP zwnlZ5{Cl&0Rj3-X)iACSWo}ew!$2i{eT&GnWLK?j&E?m$71kDqjtm_wbeDr#9E}8* zlv)#ETc8LJ=(;^=fa zkqgOEqGeS1jEd{YK$>hqh&d&{mYgeS$U)A?sXFy+CuVgTbxPJ1W0&U{wex>}&@MVU z*RB8XqYb4`cl3U~_dtKS7SGJcC{gEqPB2_i$%$DRN&lR7kH>y68A$)Eb_VK_YkySn zGmnLpstiXj29ZDBFtdzCl^OZx#!Z_){$xv`IL3@z7@H6LWcqYP)nw!c(bRY&P(d}6 zqO}9N^0{>M)@{Y2$cbk;<92T^76imExqQm*+|F#qa=ZJOYY`R8?fIfm6sv@96Ybky zD2S|3c@uf?OJ-M#W0oBlWR^PcDxc4FEq#1lUXN*}51;4VeG7HdUh-&^CVBI|OxNia zJ)np5i2k5OdOp894K5-<1M^tG zWqgY(xQc7|4&UPk+`vuT!fo8akGP9__zCy%Gald}e#LKij3;=C-|-ion`g}M(URJ* zMGN?c8*lk^8zc27jH4+Yu@t>L*m-ZH$+bB(oB~b(r@+4y&|7DTi$>34(_p%*a+P6M z^I47BxUKIJ8cP;Ei%o;fu)%~fno!s)2242jm+UytV$+}rC!{lT9y>Ga4F&1!++RwE z6Fh^ib_zHJmMhR=T%phZLvO$TFAs8_Q@|/dev/null then - ynh_script_progression --message="Removing $app service..." --weight=1 + ynh_script_progression --message="Removing $app service integration..." --weight=1 yunohost service remove $app fi @@ -49,13 +49,6 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight= # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -ynh_remove_nodejs - #================================================= # REMOVE THE REDIS DATABASE #================================================= @@ -76,9 +69,18 @@ ynh_secure_remove --file="$final_path" #================================================= ynh_script_progression --message="Removing NGINX web server configuration..." --weight=5 -# Remove the dedicated nginx config +# Remove the dedicated NGINX config ynh_remove_nginx_config +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies +ynh_remove_nodejs + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 1911c37..0658d8a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -40,13 +41,6 @@ test ! -d $final_path \ #================================================= # STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -74,9 +68,17 @@ chmod +x "$final_path/server/bin/prod.js" #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=7 -# Install Nodejs +# Define and install dependencies +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX configuration..." + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + #================================================= # RESTORE SYSTEMD #================================================= @@ -104,7 +106,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" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index d65b7d7..431fd9b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -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