diff --git a/README.md b/README.md index c024043..fd0e04d 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,15 @@ If you want a user to have administration rights (= to have the power to add/rem Also, if you need, you can make use of the password reset feature to allow users to modify their passwords, you will just need to send them the generated password reset link. +## A note about dato + +Please be aware that dato is a Progressive Web App. In a nutshell, this means that browsers cache the whole app, so it doesn't have to be requested to the server every time a user is visiting it. +This lowers solicitation of the server, and also allow users to use dato offline. + +When the app is upgraded, the user's browser will automatically detect that there is a new version, and propose to reload the page to update. However, sometimes it seems a bit random how browsers notice the new version, so if you want to make sure you're using the latest version, click on the "?" button (top-right in the web interface), and choose "credits" to verify the version you're using. +You can also force reloading the app from the server opening "about:serviceworkers" in your browser and unregistering the worker for the domain in which you installed dato. + + ## Documentation * Official documentation: https://squeak.eauchat.org/dato/ diff --git a/README_fr.md b/README_fr.md index 3ea0728..a5ec0dd 100644 --- a/README_fr.md +++ b/README_fr.md @@ -46,6 +46,15 @@ Si vous voulez donner le droit à un utilisateur d'administrer (= d'ajouter/supp Si besoin, vous pouvez créer des liens pour permettre à un utilisateur de modifier son mot de passe. Il suffira alors d'envoyer ce lien manuellement à l'utilisateur. +## Note sur dato + +Dato est une application web progressive (PWA). En deux mots, cela veut dire que les navigateurs gardent en cache l'applcation entière, afin de ne pas avoir à la demander au serveur à chaque visite. +Cela permet de moins soliciter le serveur, et d'utiliser l'application en l'absence de connexion internet. + +Quand l'application est mises à jour, le navigateur des utilisateurs détecte automatiquement la nouvelle version et propose de recharcher la page pour mettre à jour l'application. Cependant, certains navigateurs ne semblent pas toujours se rendre compte qu'une nouvelle version est disponible instantanément. Pour vérifier la version que vous utilisez, vous pouvez cliquer sur "?" (en haut à droite dans l'interface de dato), et choisir crédit pour y trouver le numéro de version actuellement installé. +Vous pouvez aussi forcer une mise à jour de l'application depuis le serveur en ouvrant la page "about:serviceworker" dans votre navigateur, et en cliquant sur le bouton "unregister" du service du domaine sur lequel vous avez installé dato. + + ## Documentation * Documentation officielle : https://squeak.eauchat.org/dato/ diff --git a/conf/couch.ini b/conf/couch.ini index c3ca60d..e1b7992 100644 --- a/conf/couch.ini +++ b/conf/couch.ini @@ -6,4 +6,4 @@ enable_cors = true credentials = true headers = accept, authorization, content-type, origin, referer methods = GET, PUT, POST, HEAD, DELETE -origins = https://{{{domain}}} +origins = https://__DOMAIN__ diff --git a/conf/private-autosync.js b/conf/private-autosync.js index aa004c5..116e72a 100644 --- a/conf/private-autosync.js +++ b/conf/private-autosync.js @@ -6,18 +6,18 @@ module.exports = { debug: false, refreshServiceWorkerScriptAtEachRequest: false, - port: "{{{port}}}", + port: "__PORT__", authentication: { - couchUrl: "{{{couch_url}}}", + couchUrl: "__COUCH_URL__", }, couchAdminAuthentication: { // couch admin user: - username: "{{{couch_admin_name}}}", + username: "__COUCH_ADMIN_NAME__", // couch admin user's password: - password: "{{{couch_admin_password}}}", + password: "__COUCH_ADMIN_PASSWORD__", // the url where your couchdb server is accessible from the internet: - customCouchUrl: "{{{couch_url}}}", + customCouchUrl: "__COUCH_URL__", }, }; diff --git a/conf/private.js b/conf/private.js index ab5c49c..8646c73 100644 --- a/conf/private.js +++ b/conf/private.js @@ -6,6 +6,6 @@ module.exports = { debug: false, refreshServiceWorkerScriptAtEachRequest: false, - port: "{{{port}}}", + port: "__PORT__", }; diff --git a/conf/public.js b/conf/public.js index 361fd28..d031f6c 100644 --- a/conf/public.js +++ b/conf/public.js @@ -1,7 +1,7 @@ module.exports = { - adminEmail: "{{{admin_email}}}", + adminEmail: "__ADMIN_EMAIL__", otherOptionsThanLogin: [ "If you have no dato account, you should request one to the administrator of this server.", diff --git a/manifest.json b/manifest.json index 192862c..8a52a26 100644 --- a/manifest.json +++ b/manifest.json @@ -121,12 +121,12 @@ "name": "admin_email", "type": "string", "ask": { - "en": "If you want the dato administrator email to be displayed in login page, so that users can contact you to create accounts... you can set your email here. Otherwise leave this to 'none'. (only if autosynchronization is enabled)", - "fr": "Si tu souhaites que l'email de l'administrateur de dato soit visible sur la page de login, afin que les utilisateurs puissent le contacter pour des demandes de compte... tu peux le spécifier ici. Sinon, choisis 'none'. (nécessaire uniquement si l'autosynchronisation a été activée)" + "en": "If you want the dato administrator email to be displayed in login page, so that users can contact you to create accounts... you can set your email here. Otherwise leave this empty. (only useful if autosynchronization is enabled)", + "fr": "Si tu souhaites que l'email de l'administrateur de dato soit visible sur la page de login, afin que les utilisateurs puissent le contacter pour des demandes de compte... tu peux le spécifier ici. Sinon, laisser ce champ vide. (utile uniquement si l'autosynchronisation a été activée)" }, "example": "datoadmin((at))domain.tld", "optional": true, - "default" : "none" + "default" : "" } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index 334a230..e30d72c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -16,8 +16,8 @@ nodejs_version=12 dato_setup_config_files() { - # create config directory - mkdir "$final_path/config/" + # create config directory (if it doesn't exist yet) + [ -d "$final_path/config/" ] || mkdir "$final_path/config/" # setup public dato config ynh_add_config --template="../conf/public.js" --destination="$final_path/config/public.js" @@ -25,22 +25,9 @@ dato_setup_config_files() { # setup private dato config if [[ $autosynchronize == true ]]; then ynh_add_config --template="../conf/private-autosync.js" --destination="$final_path/config/private.js" - # setup couch url, admin name and password - ynh_replace_string --match_string="{{{couch_url}}}" --replace_string="$couch_url" --target_file="$final_path/config/private.js" - ynh_replace_string --match_string="{{{couch_admin_name}}}" --replace_string="$couch_admin_name" --target_file="$final_path/config/private.js" - ynh_replace_string --match_string="{{{couch_admin_password}}}" --replace_string="$couch_admin_password" --target_file="$final_path/config/private.js" else ynh_add_config --template="../conf/private.js" --destination="$final_path/config/private.js" fi - # setup port to use - ynh_replace_string --match_string="{{{port}}}" --replace_string="$port" --target_file="$final_path/config/private.js" - - # add admin email to public config if it was set - if [[ $admin_email != "none" ]]; then - ynh_replace_string --match_string="{{{admin_email}}}" --replace_string="$admin_email" --target_file="$final_path/config/public.js" - else - ynh_replace_string --match_string="{{{admin_email}}}" --replace_string="" --target_file="$final_path/config/public.js" - fi } diff --git a/scripts/change_url b/scripts/change_url index 534e92b..9be1a3a 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -111,9 +111,9 @@ fi #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=40 +ynh_script_progression --message="Starting dato app service and building pages..." --weight=60 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="electrode server listening on port" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600 #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index 70c5510..f547500 100755 --- a/scripts/install +++ b/scripts/install @@ -159,15 +159,6 @@ ynh_script_progression --message="Generating dato config files..." --weight=3 dato_setup_config_files -#================================================= -# STORE THE CONFIG FILES CHECKSUM -#================================================= -ynh_script_progression --message="Storing config files checksums..." --weight=2 - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$final_path/config/public.js" -ynh_store_file_checksum --file="$final_path/config/private.js" - #================================================= # CUSTOMIZE SETUP FOR AUTOSYNCHRONIZATION #================================================= @@ -181,9 +172,6 @@ if [[ $autosynchronize == true ]]; then # make sure that couchdb has CORS enabled and that it accepts requests from dato domain ynh_add_config --template="../conf/couch.ini" --destination="/opt/couchdb/etc/local.d/$app.ini" - ynh_replace_string --match_string="{{{domain}}}" --replace_string="$domain" --target_file="/opt/couchdb/etc/local.d/$app.ini" - - ynh_store_file_checksum --file="/opt/couchdb/etc/local.d/$app.ini" #================================================= # SETUP A COUCHDB DATO ADMIN USER @@ -202,6 +190,8 @@ if [[ $autosynchronize == true ]]; then # display error message if there was an error creating dato admin user in couch if [[ $curlResult != '{"ok":true,'* ]]; then ynh_print_err --message="There was an error creating the dato admin user for in couch. You will probably have to do it manually (check the last section of this page for instructions: https://squeak.eauchat.org/apps/dato/?setups)." + ynh_print_err --message="Here is the error message from couchdb:" + ynh_print_err --message="$curlResult" ynh_print_err --message="Please make sure that your couchdb instance is accessible from the url you provided, with a proper SSL certificate (not a self-signed one), otherwise you will not be able to login to dato!" ynh_print_err --message="$curlResult" fi @@ -239,10 +229,10 @@ yunohost service add $app --description="Data storage with a convenient and flex #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=60 +ynh_script_progression --message="Starting dato app service and building pages..." --weight=60 -# Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="electrode server listening on port" +# Start a systemd service (increased timeout, because on some systems the pages could take quite some time to build?) +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600 #================================================= # SETUP FAIL2BAN diff --git a/scripts/restore b/scripts/restore index f0eba73..ed4c7d3 100755 --- a/scripts/restore +++ b/scripts/restore @@ -118,9 +118,9 @@ yunohost service add $app --description="Data storage with a convenient and flex #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=60 +ynh_script_progression --message="Starting dato app service and building pages..." --weight=60 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="electrode server listening on port" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600 #================================================= # RESTORE THE LOGROTATE CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 3e724ac..c72712b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -38,31 +38,6 @@ admin_email=$(ynh_app_setting_get --app=$app --key=admin_email) ### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=2 - -### If nobody installed your app before 4.1, -### then you may safely remove these lines - -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -if ! ynh_permission_exists --permission="admin"; then - # Create the required permissions - ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin -fi - -# Create a permission if needed -if ! ynh_permission_exists --permission="api"; then - ynh_permission_create --permission="api" --url "/api" --allowed="visitors" --show_tile="false" --protected="true" -fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -92,10 +67,14 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --weight=3 - # Download, check integrity, uncompress and patch the source from app.src + ynh_script_progression --message="Upgrading source files..." --weight=3 ynh_setup_source --dest_dir="$final_path" + + # Regenerate config files removed in upgrade + ynh_script_progression --message="Regenerating dato config files..." --weight=3 + dato_setup_config_files + fi #================================================= @@ -118,7 +97,6 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= ynh_script_progression --message="Installing NodeJS..." --weight=15 -# Install Nodejs ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= @@ -136,46 +114,20 @@ ynh_system_user_create --username=$app #================================================= ynh_script_progression --message="Building node dependencies..." --weight=90 +chown -R "$app":"$app" $final_path + pushd "$final_path" ynh_use_nodejs sudo -u $app env $ynh_node_load_PATH npm install --loglevel warn popd -#================================================= -# GENERATE CONFIG FILES -#================================================= -ynh_script_progression --message="Generating dato config files..." --weight=3 - -dato_setup_config_files - #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 # Create a dedicated systemd config -ynh_add_systemd_config - -#================================================= -# VERIFY CONFIG FILES CHECKSUMS -#================================================= -ynh_script_progression --message="Verifying config files checksums..." --weight=2 - -### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. -### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. -ynh_backup_if_checksum_is_different --file="$final_path/config/public.js" -ynh_backup_if_checksum_is_different --file="$final_path/config/private.js" - -# ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/CONFIG_FILE" - -# Recalculate and store the checksum of the config files for the next upgrade. -ynh_store_file_checksum --file="$final_path/config/public.js" -ynh_store_file_checksum --file="$final_path/config/private.js" - -if [[ $autosynchronize == true ]]; then - ynh_backup_if_checksum_is_different --file="/opt/couchdb/etc/local.d/$app.ini" - ynh_store_file_checksum --file="/opt/couchdb/etc/local.d/$app.ini" -fi +ynh_add_systemd_config --others_var="ynh_node_load_PATH" #================================================= # GENERIC FINALIZATION @@ -204,9 +156,9 @@ yunohost service add $app --description="Data storage with a convenient and flex #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=60 +ynh_script_progression --message="Starting dato app service and building pages..." --weight=60 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="electrode server listening on port" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600 # #================================================= # # UPGRADE FAIL2BAN