From 1521553b5b4f2af0c81473c2c686b0d0c0d4eab8 Mon Sep 17 00:00:00 2001 From: Florent Date: Sun, 3 Mar 2024 12:42:45 +0100 Subject: [PATCH] Fix upgrade, cleanup and option to select an admin --- doc/POST_INSTALL.md | 11 +++++++---- manifest.toml | 3 +++ scripts/backup | 2 +- scripts/install | 14 +++++++++++--- scripts/restore | 2 +- scripts/upgrade | 15 +++++++++++++++ 6 files changed, 38 insertions(+), 9 deletions(-) diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md index 357fd23..17a83d3 100644 --- a/doc/POST_INSTALL.md +++ b/doc/POST_INSTALL.md @@ -1,6 +1,9 @@ Now login to Joplin - - Url: https://__DOMAIN____PATH__ - - Email: admin@localhost - - Password: __ADMIN_PASS__ -Then you may change the default email and password at this page: https://joplin.local/admin/users +- Url: https://**DOMAIN\_\_**PATH\_\_ +- Email: **ADMIN_MAIL** +- Password: **ADMIN_PASS** + +Then you may change the default password at this page: https://**DOMAIN\_\_**PATH\_\_/admin/users + +Then download one of these Joplin apps and configure the synchronisation with your server: https://joplinapp.org/help/install/ diff --git a/manifest.toml b/manifest.toml index 3ae4901..f8889ff 100644 --- a/manifest.toml +++ b/manifest.toml @@ -38,6 +38,9 @@ ram.runtime = "50M" type = "group" default = "visitors" + [install.admin] + type = "user" + [resources] [resources.sources] diff --git a/scripts/backup b/scripts/backup index 59c90ce..f11e868 100755 --- a/scripts/backup +++ b/scripts/backup @@ -34,7 +34,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= -# BACKUP THE MYSQL DATABASE +# BACKUP THE PostgreSQL DATABASE #================================================= ynh_print_info --message="Backing up the PostgreSQL database..." diff --git a/scripts/install b/scripts/install index 8bdd170..2b8266c 100755 --- a/scripts/install +++ b/scripts/install @@ -10,7 +10,12 @@ source _common.sh source /usr/share/yunohost/helpers admin_pass=$(ynh_string_random --length=24) +admin_mail=$(ynh_user_get_info --username=$admin --key="mail") +admin_name=$(ynh_user_get_info --username=$admin --key="fullname") + +# Store these values even if we don't need them, so they are printed in the post-install message ynh_app_setting_set --app=$app --key=admin_pass --value=$admin_pass +ynh_app_setting_set --app=$app --key=admin_mail --value=$admin_mail #================================================= # INSTALL DEPENDENCIES @@ -60,7 +65,7 @@ chown $app:$app "$install_dir/.env" #================================================= # INSTALL JOPLIN #================================================= -ynh_script_progression --message="Installing $app..." --weight=10 +ynh_script_progression --message="Building $app..." --weight=10 pushd $install_dir ynh_use_nodejs @@ -87,8 +92,11 @@ ynh_script_progression --message="Changing default admin password..." --weight=1 hashed_pwd=$(bcrypt_password "$admin_pass") -ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" <<< \ - "UPDATE users SET password='$hashed_pwd' WHERE email='admin@localhost'" +ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" <<< " + UPDATE users + SET password='$hashed_pwd', email='$admin_mail', full_name='$admin_name' + WHERE email='admin@localhost' +" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index e89b8f0..c9b4674 100755 --- a/scripts/restore +++ b/scripts/restore @@ -20,7 +20,7 @@ ynh_restore_file --origin_path="$install_dir" chown -R $app:www-data "$install_dir" #================================================= -# RESTORE THE MYSQL DATABASE +# RESTORE THE PostgreSQL DATABASE #================================================= ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 diff --git a/scripts/upgrade b/scripts/upgrade index c95d7e8..972aea2 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -42,6 +42,21 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=5 # Install Nodejs ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +#================================================= +# BUILD +#================================================= + +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Building $app..." --weight=10 + pushd $install_dir + ynh_use_nodejs + sudo -u $app env $ynh_node_load_PATH BUILD_SEQUENCIAL=1 yarn install --inline-builds + # sudo -u $app env $ynh_node_load_PATH yarn cache clean + # ynh_secure_remove .yarn/berry + popd +fi + #================================================= # REAPPLY SYSTEM CONFIGURATIONS #=================================================