From 1c97a6d36169f2c934b4ac97ba427d4cb3817b80 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 22 Jun 2020 18:33:34 +0200 Subject: [PATCH] various changes --- README_fr.md | 2 +- check_process | 2 +- conf/config.json.example | 6 ++++++ conf/systemd.service | 8 ++++---- manifest.json | 2 +- scripts/_common.sh | 2 +- scripts/backup | 8 +------- scripts/change_url | 1 + scripts/install | 27 ++++++++++----------------- scripts/remove | 8 -------- scripts/restore | 7 ------- scripts/upgrade | 32 ++++++-------------------------- 12 files changed, 32 insertions(+), 73 deletions(-) diff --git a/README_fr.md b/README_fr.md index 34cc5c4..44b8f3d 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,7 +5,7 @@ *[Read this readme in english.](./README.md)* -> *Ce package vous permet d'installer CodiMD rapidement et simplement sur un serveur Yunohost. +> *Ce package vous permet d'installer CodiMD rapidement et simplement sur un serveur YunoHost. Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* ## Vue d'ensemble diff --git a/check_process b/check_process index a4b4332..cd20538 100644 --- a/check_process +++ b/check_process @@ -14,7 +14,7 @@ backup_restore=1 multi_instance=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Levels Level 5=auto ;;; Options diff --git a/conf/config.json.example b/conf/config.json.example index 576c528..78f5ddc 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -3,10 +3,16 @@ "protocolUseSSL": true, "domain": "__DOMAIN__", "port": "__PORT__", + "sessionSecret": "__SESSION__", "loglevel": "info", "useCDN": false, "allowGravatar": false, "allowFreeURL": false, + "allowAnonymousEdits": true, + "defaultPermission": "locked", + "email": true, + "allowEmailRegister": true, + "imageUploadType": "filesystem", "hsts": { "enable": true, "maxAgeSeconds": 31536000, diff --git a/conf/systemd.service b/conf/systemd.service index 53450d9..f8c9c59 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,7 +1,7 @@ [Unit] -Description=__APP__: collaborative Markdown notes -After=network.target -After=postgresql.service +Description=CodiMD: collaborative Markdown notes +Documentation=https://github.com/codimd/server +After=network.target postgresql.service [Service] Type=simple @@ -10,7 +10,7 @@ Group=__APP__ WorkingDirectory=__FINALPATH__ Environment="PATH=__ENV_PATH__" Environment="NODE_ENV=production" -ExecStart=__YNH_NPM__ start +ExecStart=__YNH_NPM__ start --production Restart=always PrivateTmp=true PrivateDevices=true diff --git a/manifest.json b/manifest.json index 0ceb6c1..7a3e907 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Collaborative editor to work on notes written in Markdown", "fr": "Éditeur collaboratif pour travailler sur des notes en Markdown" }, - "version": "1.6.0~ynh2", + "version": "1.6.0~ynh3", "url": "https://github.com/codimd/server", "license": "AGPL-3.0-only", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index 4804c27..327e730 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,7 +7,7 @@ # dependencies used by the app pkg_dependencies="postgresql apt-transport-https" -nodejs_version=10 +nodejs_version=12 #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index 7065f73..8d4d217 100644 --- a/scripts/backup +++ b/scripts/backup @@ -49,12 +49,6 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= - -ynh_backup --src_path="/etc/logrotate.d/$app" - #================================================= # BACKUP SYSTEMD #================================================= @@ -64,7 +58,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Backing up the Postgresql database..." +ynh_print_info --message="Backing up the PostgreSQL database..." ynh_psql_dump_db --database="$db_name" > db.sql diff --git a/scripts/change_url b/scripts/change_url index 9b97276..d9c96f4 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,6 +28,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) +port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP diff --git a/scripts/install b/scripts/install index 60be9fe..b737c88 100644 --- a/scripts/install +++ b/scripts/install @@ -26,6 +26,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC +session=$(ynh_string_random --length=30) app=$YNH_APP_INSTANCE_NAME @@ -123,7 +124,7 @@ ynh_script_progression --message="Building $app... (this will take some time and pushd "$final_path" || ynh_die ynh_use_nodejs - yarn install --frozen-lockfile + bin/setup ynh_exec_warn_less yarn run build popd || ynh_die @@ -133,10 +134,9 @@ popd || ynh_die #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=1 -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" ynh_add_systemd_config @@ -149,11 +149,11 @@ ynh_script_progression --message="Modifying a config file..." # Main config File ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__SESSION__" --replace_string="$session" --target_file="../conf/config.json.example" cp ../conf/config.json.example "$final_path/config.json" @@ -178,14 +178,6 @@ ynh_script_progression --message="Securing files and directories..." # Set permissions to app files chown -R $app:$app $final_path -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=2 - -# Use logrotate to manage application logfile(s) -ynh_use_logrotate - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -206,11 +198,12 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= ynh_script_progression --message="Configuring SSOwat..." --weight=1 -# Make app public if necessary +# Make app public if necessary or protect it if [ $is_public -eq 1 ] then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" + # Everyone can access the app. + # The "main" permission is automatically created before the install script. + ynh_permission_update --permission "main" --add "visitors" fi #================================================= diff --git a/scripts/remove b/scripts/remove index d9cd71a..1e85068 100644 --- a/scripts/remove +++ b/scripts/remove @@ -77,14 +77,6 @@ ynh_script_progression --message="Removing Nginx web server configuration..." -- # Remove the dedicated nginx config ynh_remove_nginx_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 - -# Remove the app-specific logrotate config -ynh_remove_logrotate - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index cbba363..6ada99c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -122,13 +122,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="HTTP Server listening" -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --weight=5 - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 62a91f3..6930a2f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,6 +21,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) +session=$(ynh_app_setting_get --app=$app --key=session) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name @@ -126,7 +127,7 @@ then pushd "$final_path" || ynh_die ynh_use_nodejs - yarn install --frozen-lockfile + bin/setup ynh_exec_warn_less yarn run build popd || ynh_die @@ -142,34 +143,25 @@ ynh_backup_if_checksum_is_different --file="$final_path/config.json" # Main config File ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/config.json.example" -ynh_replace_string --match_string="__PATH__" --replace_string="${path_url:1}" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="../conf/config.json.example" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/config.json.example" +ynh_replace_string --match_string="__SESSION__" --replace_string="$session" --target_file="../conf/config.json.example" cp ../conf/config.json.example "$final_path/config.json" # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$final_path/config.json" -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=2 - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=2 -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" # Create a dedicated systemd config @@ -185,18 +177,6 @@ ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R $app:$app $final_path -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 - -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # unprotected_uris allows SSO credentials to be passed anyway - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -fi - #================================================= # INTEGRATE SERVICE IN YUNOHOST #=================================================