diff --git a/check_process b/check_process index 1f3045d..8f35af4 100644 --- a/check_process +++ b/check_process @@ -1,12 +1,8 @@ -# See here for more information -# https://github.com/YunoHost/package_check#syntax-check_process-file - -# Move this file from check_process.default to check_process when you have filled it. - ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - is_public=1 (PUBLIC|public=1|private=0) + domain="domain.tld" + is_public=1 + instance_name="MyTrillium" ; Checks pkg_linter=1 setup_sub_dir=0 @@ -15,7 +11,8 @@ setup_private=1 setup_public=1 upgrade=1 - upgrade=0 from_commit=CommitHash + # 0.50.2~ynh1 + upgrade=0 from_commit=1a944e70223108bc16a28d236eca6e7efd25018e backup_restore=1 multi_instance=1 port_already_use=0 @@ -23,8 +20,3 @@ ;;; Options Email= Notification=none -;;; Upgrade options - ; commit=CommitHash - name=Name and date of the commit. - manifest_arg=domain=DOMAIN&admin=USER&is_public=1& - diff --git a/conf/config.ini b/conf/config.ini index faabe82..eb32532 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -20,4 +20,4 @@ port=__PORT__ https=false # path to certificate (run "bash bin/generate-cert.sh" to generate self-signed certificate). Relevant only if https=true certPath= -keyPath= \ No newline at end of file +keyPath= diff --git a/conf/systemd.service b/conf/systemd.service index bcbe28b..2e1b097 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,10 +6,12 @@ After=network.target Type=simple User=__APP__ Group=__APP__ -Environment=TRILIUM_DATA_DIR=/home/yunohost.app/__APP__ +Environment=TRILIUM_DATA_DIR=__DATADIR__ +Environment=TRILIUM_PORT=__PORT__ +Environment="__YNH_NODE_LOAD_PATH__" Environment=NODE_ENV=production WorkingDirectory=__FINALPATH__/ -ExecStart=/usr/bin/env bash -c "PATH=__NODEJS_PATH__:$PATH node __FINALPATH__/src/www" +ExecStart=__YNH_NODE__ __FINALPATH__/src/www [Install] WantedBy=multi-user.target diff --git a/doc/.gitkeep b/doc/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..f4c081d --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +Trilium Notes is an Evernote-like hierarchical note taking application with many advanced features, focused on building a large personal knowledge base. diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..d98b9b6 --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1 @@ +Trilium Notes est une application de prise de note hiérarchique semblable a Evernote, avec maintes fonctions avancées, centrée sur la construction d'une large base de connaissances personnelle. diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 0000000..06cde09 --- /dev/null +++ b/doc/DISCLAIMER.md @@ -0,0 +1,3 @@ +## Configuration + +You will be asked to choose a username and password when you first access the app. You can configure Trillium from the settings menu of the app interface. diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md new file mode 100644 index 0000000..f3cd78b --- /dev/null +++ b/doc/DISCLAIMER_fr.md @@ -0,0 +1,3 @@ +## Configuration + +On vous demandera de choisir un nom d'utilisateur et mot de passe quand vous installez l'application. Vous pouvez configurer Trillium depuis le menu de configuration de l'interface web. diff --git a/doc/screenshots/.gitkeep b/doc/screenshots/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/doc/screenshots/example.jpg b/doc/screenshots/example.jpg new file mode 100644 index 0000000..a1efa1a Binary files /dev/null and b/doc/screenshots/example.jpg differ diff --git a/doc/screenshots/screenshot.png b/doc/screenshots/screenshot.png new file mode 100644 index 0000000..479906b Binary files /dev/null and b/doc/screenshots/screenshot.png differ diff --git a/manifest.json b/manifest.json index 5def2e0..01900fe 100644 --- a/manifest.json +++ b/manifest.json @@ -6,26 +6,31 @@ "en": "A hierarchical note taking application with focus on building large personal knowledge base", "fr": "Une application de prise de note hiérarchique centrée sur la construction d'une large base de connaissances personnelle" }, - "version": "0.52.3~ynh1", + "version": "0.52.3~ynh2", "url": "https://github.com/zadam/trilium", + "upstream": { + "license": "AGPL-3.0-only", + "website": "https://github.com/zadam/trilium", + "admindoc": "https://github.com/zadam/trilium/wiki", + "code": "https://github.com/zadam/trilium" + }, "license": "AGPL-3.0-only", "maintainer": { "name": "Jules Bertholet", "email": "jules.bertholet@gmail.com" }, "requirements": { - "yunohost": ">= 4.1.3" + "yunohost": ">= 4.3.0" }, "multi_instance": true, "services": [ "nginx" ], "arguments": { - "install" : [ + "install": [ { "name": "domain", - "type": "domain", - "example": "example.com" + "type": "domain" }, { "name": "is_public", diff --git a/scripts/_common.sh b/scripts/_common.sh index 13f7970..d508ada 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,52 +4,15 @@ # COMMON VARIABLES #================================================= +nodejs_version=16 + # dependencies used by the app -pkg_dependencies="nodejs npm libpng16-16 libpng-dev pkg-config autoconf libtool build-essential nasm libx11-dev libxkbfile-dev" +pkg_dependencies="libpng16-16 libpng-dev pkg-config autoconf libtool build-essential nasm libx11-dev libxkbfile-dev" #================================================= # PERSONAL HELPERS #================================================= -function set_node_vars { - nodejs_version=$(ynh_app_setting_get --app=$app --key=nodejs_version) - if [ "$nodejs_version" -ne 16 ]; then - ynh_exec_warn_less ynh_remove_nodejs - fi - ynh_exec_warn_less ynh_install_nodejs --nodejs_version=16 - ynh_use_nodejs - node_path="$nodejs_path:$(sudo -u $app sh -c 'echo $PATH')" -} - -function build_node_app { - set_node_vars - - grep -v electron "$final_path/package.json" > "$final_path/server-package.json" - mv "$final_path/server-package.json" "$final_path/package.json" - pushd "$final_path" - chown -R $app:$app "$final_path" - sudo -u $app touch "$final_path/.yarnrc" - sudo -u $app env "PATH=$node_path" yarn --cache-folder "$final_path/yarn-cache" --use-yarnrc "$final_path/.yarnrc" import 2>&1 - sudo -u $app env "PATH=$node_path" yarn --cache-folder "$final_path/yarn-cache" --use-yarnrc "$final_path/.yarnrc" install --production 2>&1 - chown -R root:root "$final_path" - popd - - set_permissions -} - -function set_permissions { - chown -R root:$app "$final_path" - chmod -R g=u,g-w,o-rwx "$final_path" - chown -R $app:$app "$data_path" - chmod -R g=u,g-w,o-rwx "$data_path" -} - -function setup_sources { - ynh_secure_remove "$final_path" - ynh_setup_source --dest_dir="$final_path" - mkdir -p "$data_path" -} - #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 6654eab..d8cb0be 100755 --- a/scripts/backup +++ b/scripts/backup @@ -27,9 +27,9 @@ ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -data_path=$(ynh_app_setting_get --app=$app --key=data_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -42,6 +42,12 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$final_path" +#================================================= +# BACKUP THE DATA DIR +#================================================= + +ynh_backup --src_path="$datadir" --is_big + #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= @@ -56,12 +62,6 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/systemd/system/$app.service" -#================================================= -# BACKUP VARIOUS FILES -#================================================= - -ynh_backup --src_path="$data_path" --is_big - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index af84f3a..6beabb0 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -30,13 +30,14 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=15 # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + ynh_clean_check_starting # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" @@ -57,6 +58,10 @@ then fi change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi #================================================= # STANDARD MODIFICATIONS @@ -91,7 +96,7 @@ fi #================================================= 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="Listening on port" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index eaef17c..473d9f3 100755 --- a/scripts/install +++ b/scripts/install @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - true + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -27,6 +27,7 @@ domain=$YNH_APP_ARG_DOMAIN path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC instance_name=$YNH_APP_ARG_INSTANCE_NAME + app=$YNH_APP_INSTANCE_NAME #================================================= @@ -36,8 +37,6 @@ ynh_script_progression --message="Validating installation parameters..." --weigh final_path=/opt/yunohost/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" -data_path=/home/yunohost.app/$app -test ! -e "$data_path" || ynh_die --message="This path already contains a folder" # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url @@ -59,7 +58,7 @@ ynh_app_setting_set --app=$app --key=instance_name --value=$instance_name ynh_script_progression --message="Finding an available port..." --weight=1 # Find an available port -port=$(ynh_find_port --port=8080) +port=$(ynh_find_port --port=8095) ynh_app_setting_set --app=$app --key=port --value=$port #================================================= @@ -67,8 +66,17 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= ynh_script_progression --message="Installing dependencies..." --weight=60 -ynh_install_app_dependencies $pkg_dependencies -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_exec_warn_less 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="Configuring system user..." --weight=1 + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -76,9 +84,15 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st ynh_script_progression --message="Setting up source files..." --weight=5 ynh_app_setting_set --app=$app --key=final_path --value=$final_path -ynh_app_setting_set --app=$app --key=data_path --value=$data_path +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source --dest_dir="$final_path" -setup_sources +grep -v electron "$final_path/package.json" > "$final_path/server-package.json" +mv "$final_path/server-package.json" "$final_path/package.json" + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION @@ -88,15 +102,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -ynh_system_user_create --username=$app -usermod -d $final_path $app 2>&1 - #================================================= # SPECIFIC SETUP #================================================= @@ -104,7 +109,36 @@ usermod -d $final_path $app 2>&1 #================================================= ynh_script_progression --message="Installing Node.js packages ..." --weight=45 -build_node_app +pushd "$final_path" + ynh_use_nodejs + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm rebuild +popd + +#================================================= +# CREATE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Creating a data directory..." + +datadir=/home/yunohost.app/$app +ynh_app_setting_set --app=$app --key=datadir --value=$datadir + +mkdir -p $datadir + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" + +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." + +ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini" +ln -sf $final_path/config.ini $datadir/config.ini + +chmod 400 "$final_path/config.ini" +chown $app:$app "$final_path/config.ini" #================================================= # SETUP SYSTEMD @@ -114,22 +148,8 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# ADD A CONFIGURATION -#================================================= - -ynh_add_config --template="config.ini" --destination="$final_path/config.ini" -ln -sf $final_path/config.ini $data_path/config.ini - #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions to app files -set_permissions - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -143,7 +163,7 @@ yunohost service add $app --description="Trilium Notes app" --log="systemd" ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Listening on port" #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index 5179fed..3e1214b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -19,7 +19,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -data_path=$(ynh_app_setting_get --app=$app --key=data_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # STANDARD REMOVE @@ -42,14 +42,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=30 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - #================================================= # REMOVE APP MAIN DIR #================================================= @@ -58,6 +50,17 @@ ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely ynh_secure_remove --file="$final_path" +#================================================= +# REMOVE DATA DIR +#================================================= + +# Remove the data directory if --purge option is used +if [ "${YNH_APP_PURGE:-0}" -eq 1 ] +then + ynh_script_progression --message="Removing app data directory..." + ynh_secure_remove --file="$datadir" +fi + #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -67,21 +70,14 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- ynh_remove_nginx_config #================================================= -# REMOVE NODE +# REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing Node.js version..." --weight=1 +ynh_script_progression --message="Removing dependencies..." --weight=30 +# Remove metapackage and its dependencies +ynh_remove_app_dependencies ynh_remove_nodejs -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE VARIOUS FILES -#================================================= - -# Remove the data directory -ynh_secure_remove --file="$data_path" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index c22dd52..9304fe7 100755 --- a/scripts/restore +++ b/scripts/restore @@ -15,8 +15,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - #### Remove this function if there's nothing to clean before calling the remove script. - true + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -31,55 +30,49 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -data_path=$(ynh_app_setting_get --app=$app --key=data_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= 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}" test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= -ynh_script_progression --message="Restoring the app directories..." --weight=1 - -ynh_restore_file --origin_path="$final_path" - -#================================================= -# RESTORE THE APP DATA DIR -#================================================= - -ynh_restore_file --origin_path="$data_path" --not_mandatory -mkdir -p $data_path - #================================================= # RECREATE THE DEDICATED 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 -usermod -d $final_path $app 2>&1 +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= -# RESTORE USER RIGHTS +# RESTORE THE APP MAIN DIR #================================================= +ynh_script_progression --message="Restoring the app main directory..." --weight=1 -# Restore permissions on app files -set_permissions +ynh_restore_file --origin_path="$final_path" + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + +#================================================= +# RESTORE THE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Restoring the data directory..." + +ynh_restore_file --origin_path="$datadir" --not_mandatory + +mkdir -p $datadir + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" #================================================= # SPECIFIC RESTORATION @@ -89,15 +82,16 @@ set_permissions ynh_script_progression --message="Reinstalling dependencies..." --weight=40 # Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" #================================================= -# REINSTALL DEPENDENCIES +# RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring Node.js installation..." --weight=1 +ynh_script_progression --message="Restoring the NGINX web server configuration..." -set_node_vars +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE SYSTEMD @@ -119,7 +113,7 @@ yunohost service add $app --description="Trilium Notes app" --log="systemd" #================================================= 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="Listening on port" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index d8a0eb7..c1de86b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,14 +20,14 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) admin=$(ynh_app_setting_get --app=$app --key=admin) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -data_path=$(ynh_app_setting_get --app=$app --key=data_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) port=$(ynh_app_setting_get --app=$app --key=port) -instance_name="" instance_name=$(ynh_app_setting_get --app=$app --key=instance_name) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -39,6 +39,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # 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 } @@ -54,17 +55,54 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=60 ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." + +# If datadir doesn't exist, create it +if [ -z "$datadir" ]; then + datadir=$(ynh_app_setting_get --app=$app --key=data_path) + ynh_app_setting_set --app=$app --key=datadir --value=$datadir + ynh_app_setting_delete --app=$app --key=data_path +fi + +#================================================= +# 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 --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --weight=5 + ynh_script_progression --message="Upgrading source files..." - setup_sources + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" --keep="config.ini" + + grep -v electron "$final_path/package.json" > "$final_path/server-package.json" + mv "$final_path/server-package.json" "$final_path/package.json" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=5 + +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" + #================================================= # NGINX CONFIGURATION #================================================= @@ -73,31 +111,29 @@ 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=5 - -ynh_install_app_dependencies $pkg_dependencies -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..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app -usermod -d $final_path $app 2>&1 - #================================================= # SPECIFIC UPGRADE #================================================= # INSTALL NODE PACKAGES #================================================= -ynh_script_progression --message="Installing Node.js packages ..." --weight=1 +ynh_script_progression --message="Installing Node.js packages ..." --weight=45 -build_node_app +pushd "$final_path" + ynh_use_nodejs + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install + ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm rebuild +popd + +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." + +ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini" +ln -sf $final_path/config.ini $datadir/config.ini + +chmod 400 "$final_path/config.ini" +chown $app:$app "$final_path/config.ini" #================================================= # SETUP SYSTEMD @@ -107,22 +143,8 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# UPDATE A CONFIG FILE -#================================================= - -ynh_add_config --template="config.ini" --destination="$final_path/config.ini" -ln -sf $final_path/config.ini $data_path/config.ini - #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions on app files -set_permissions - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -135,7 +157,7 @@ yunohost service add $app --description="Trilium Notes app" --log="systemd" #================================================= 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="Listening on port" #================================================= # RELOAD NGINX diff --git a/sources/extra_files/app/.gitignore b/sources/extra_files/app/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/extra_files/app/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] diff --git a/sources/patches/.gitignore b/sources/patches/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/patches/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op]