diff --git a/README.md b/README.md index ca79108..1b5993f 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ This version of Etherpad is preconfigured with a collection of plugins: - [ep_subscript_and_superscript](https://www.npmjs.com/package/ep_subscript_and_superscript) - *Support for subscript and superscript* -**Shipped version:** 1.9.3~ynh1 +**Shipped version:** 1.9.4~ynh1 **Demo:** https://video.etherpad.com @@ -47,6 +47,7 @@ This version of Etherpad is preconfigured with a collection of plugins: * Official app website: * Official admin documentation: * Upstream app code repository: +* YunoHost Store: * Report a bug: ## Developer info diff --git a/README_fr.md b/README_fr.md index aa4d64f..3837642 100644 --- a/README_fr.md +++ b/README_fr.md @@ -34,7 +34,7 @@ Cette version d'Etherpad est préconfigurée avec une collection de plugins: - [ep_subscript_and_superscript](https://www.npmjs.com/package/ep_subscript_and_superscript) - *Support des exposants et indices* -**Version incluse :** 1.9.3~ynh1 +**Version incluse :** 1.9.4~ynh1 **Démo :** https://video.etherpad.com @@ -47,6 +47,7 @@ Cette version d'Etherpad est préconfigurée avec une collection de plugins: * Site officiel de l’app : * Documentation officielle de l’admin : * Dépôt de code officiel de l’app : +* YunoHost Store: * Signaler un bug : ## Informations pour les développeurs diff --git a/conf/settings.json b/conf/settings.json index bac69b4..d51e36c 100644 --- a/conf/settings.json +++ b/conf/settings.json @@ -246,29 +246,29 @@ "highlightSelectedText": false }, // ep_mypads -//noldap "ep_mypads": { -//noldap "ldap": { -//noldap // Your LDAP URL -//noldap "url": "ldap://127.0.0.1", -//noldap // Where to search your users -//noldap "searchBase": "ou=users,dc=yunohost,dc=org", -//noldap // A LDAP filter ({{username}} is replaced by user's login) -//noldap "searchFilter": "(&(|(objectclass=posixAccount))(uid={{username}}))", -//noldap // LDAP properties mapping for MyPads -//noldap "properties": { -//noldap // Which LDAP property will be used as user's login? -//noldap "login": "uid", -//noldap // as user's email -//noldap "email": "mail", -//noldap // as user's firstname -//noldap "firstname": "givenName", -//noldap // as users's lastname -//noldap "lastname": "sn" -//noldap }, -//noldap // Default langage for LDAP created users -//noldap "defaultLang": "__LANGUAGE__" -//noldap } -//noldap }, +__COMMENT_IF_LDAP_DISABLED__ "ep_mypads": { +__COMMENT_IF_LDAP_DISABLED__ "ldap": { +__COMMENT_IF_LDAP_DISABLED__ // Your LDAP URL +__COMMENT_IF_LDAP_DISABLED__ "url": "ldap://127.0.0.1", +__COMMENT_IF_LDAP_DISABLED__ // Where to search your users +__COMMENT_IF_LDAP_DISABLED__ "searchBase": "ou=users,dc=yunohost,dc=org", +__COMMENT_IF_LDAP_DISABLED__ // A LDAP filter ({{username}} is replaced by user's login) +__COMMENT_IF_LDAP_DISABLED__ "searchFilter": "(&(|(objectclass=posixAccount))(uid={{username}}))", +__COMMENT_IF_LDAP_DISABLED__ // LDAP properties mapping for MyPads +__COMMENT_IF_LDAP_DISABLED__ "properties": { +__COMMENT_IF_LDAP_DISABLED__ // Which LDAP property will be used as user's login? +__COMMENT_IF_LDAP_DISABLED__ "login": "uid", +__COMMENT_IF_LDAP_DISABLED__ // as user's email +__COMMENT_IF_LDAP_DISABLED__ "email": "mail", +__COMMENT_IF_LDAP_DISABLED__ // as user's firstname +__COMMENT_IF_LDAP_DISABLED__ "firstname": "givenName", +__COMMENT_IF_LDAP_DISABLED__ // as users's lastname +__COMMENT_IF_LDAP_DISABLED__ "lastname": "sn" +__COMMENT_IF_LDAP_DISABLED__ }, +__COMMENT_IF_LDAP_DISABLED__ // Default langage for LDAP created users +__COMMENT_IF_LDAP_DISABLED__ "defaultLang": "__LANGUAGE__" +__COMMENT_IF_LDAP_DISABLED__ } +__COMMENT_IF_LDAP_DISABLED__ }, /* * Should we suppress errors from being visible in the default Pad Text? @@ -312,7 +312,7 @@ * it to null disables Abiword and will only allow plain text and HTML * import/exports. */ - "abiword" : null, + "abiword" : __ABIWORD_PATH__, /* * This is the absolute path to the soffice executable. @@ -320,7 +320,7 @@ * LibreOffice can be used in lieu of Abiword to export pads. * Setting it to null disables LibreOffice exporting. */ - "soffice" : null, + "soffice" : __SOFFICE_PATH__, /* * Path to the Tidy executable. diff --git a/conf/systemd.service b/conf/systemd.service index e92b888..0684052 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,10 +7,9 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__INSTALL_DIR__/ -Environment=NODE_ENV=production +Environment=ETHERPAD_PRODUCTION=true Environment="__YNH_NODE_LOAD_PATH__" -ExecStart=__INSTALL_DIR__/src/bin/run.sh -#ExecStart=__YNH_NODE__ __INSTALL_DIR__/src/node/server.js +ExecStart=__YNH_NODE__ __INSTALL_DIR__/src/node/server.js StandardOutput=append:/var/log/__APP__/etherpad.log StandardError=inherit Restart=always diff --git a/config_panel.toml.example b/config_panel.toml.example deleted file mode 100644 index 604bb12..0000000 --- a/config_panel.toml.example +++ /dev/null @@ -1,84 +0,0 @@ -version = "1.0" - -[main] -name = "Etherpad configuration" - - - [main.export] - name = "Export" - - [main.export.export] - ask = "Use AbiWord (~260 Mo) or LibreOffice (~400 Mo) (more stable) to expand export possibilities (PDF, doc)?" - choices = ["none", "abiword", "libreoffice"] - default = "none" - - - [main.pad_configuration] - name = "Default pad configuration" - - [main.pad_configuration.pad_config_nocolors] - ask = "Hide authorship colors?" - type = "boolean" - default = false - - [main.pad_configuration.pad_config_showlinenumbers] - ask = "Show line numbers?" - type = "boolean" - default = true - - [main.pad_configuration.pad_config_chatandusers] - ask = "Show chat and users?" - type = "boolean" - default = false - - [main.pad_configuration.pad_config_alwaysshowchat] - ask = "Always show chat?" - type = "boolean" - default = false - - [main.pad_configuration.pad_config_show_markdown] - ask = "Show markdown syntax?" - type = "boolean" - default = false - - - [main.mypads_configuration] - name = "MyPads configuration" - - [main.mypads_configuration.mypads] - ask = "Enable MyPads plugin?" - type = "boolean" - default = true - - [main.mypads_configuration.useldap] - ask = "Use LDAP with MyPads?" - type = "boolean" - default = true - - - [main.overwrite_files] - name = "Overwriting config files during an upgrade" - - [main.overwrite_files.overwrite_settings] - ask = "Overwrite the config file settings.json?" - type = "boolean" - default = true - help = "If the file is overwritten, a backup will be created." - - [main.overwrite_files.overwrite_credentials] - ask = "Overwrite the config file credentials.json?" - type = "boolean" - default = true - help = "If the file is overwritten, a backup will be created." - - [main.overwrite_files.overwrite_nginx] - ask = "Overwrite the NGINX config file?" - type = "boolean" - default = true - help = "If the file is overwritten, a backup will be created." - - [main.overwrite_files.overwrite_systemd] - ask = "Overwrite the systemd config file?" - type = "boolean" - default = true - help = "If the file is overwritten, a backup will be created." diff --git a/manifest.toml b/manifest.toml index 84f5eef..2cfbc3f 100644 --- a/manifest.toml +++ b/manifest.toml @@ -80,8 +80,8 @@ ram.runtime = "50M" [resources.sources] [resources.sources.main] - url = "https://github.com/ether/etherpad-lite/archive/1.9.4.tar.gz" - sha256 = "5b8ccf2a3c92cbd9bb578f684bc52d2ea27fc3fb30cdc76341f9ccffe0c0ff7f" + url = "https://github.com/ether/etherpad-lite/archive/1.9.1.tar.gz" + sha256 = "667741235a2bcd8d28a32f5e611b82fb2ea7d11525ff41b8b5478b05a987b047" autoupdate.strategy = "latest_github_tag" [resources.system_user] @@ -112,4 +112,4 @@ ram.runtime = "50M" [resources.database] type = "mysql" - \ No newline at end of file + diff --git a/scripts/_common.sh b/scripts/_common.sh index 53abd29..d8e6290 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # NodeJS version -nodejs_version=16 +nodejs_version=14 # MyPads version # This variable is mostly used to force an upgrade of the package in case of new versions of MyPads. @@ -33,14 +33,6 @@ ep_font_size_version=0.4.44 #================================================= ynh_maintenance_mode_ON () { - # Load value of $path and $domain from the config if their not set - if [ -z $path ]; then - path=$(ynh_app_setting_get $app path) - fi - if [ -z $domain ]; then - domain=$(ynh_app_setting_get $app domain) - fi - mkdir -p /var/www/html/ # Create an html to serve as maintenance notice @@ -89,14 +81,6 @@ include conf.d/yunohost_panel.conf.inc; } ynh_maintenance_mode_OFF () { - # Load value of $path and $domain from the config if their not set - if [ -z $path ]; then - path=$(ynh_app_setting_get $app path) - fi - if [ -z $domain ]; then - domain=$(ynh_app_setting_get $app domain) - fi - # Rewrite the nginx config file to redirect from ${path}_maintenance to the real url of the app. echo "rewrite ^${path}_maintenance/(.*)$ ${path}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" systemctl reload nginx diff --git a/scripts/config b/scripts/config deleted file mode 100644 index fc3a7d0..0000000 --- a/scripts/config +++ /dev/null @@ -1,264 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -# Load common variables for all scripts. -source _common.sh -source /usr/share/yunohost/helpers - -#================================================= -# SPECIFIC CODE -#================================================= -# DECLARE GENERIC FUNCTION -#================================================= - -config_file="$final_path/settings.json" - -get_config_value() { - option_name="$1" - # Get the value of this option in the config file - grep "^ *\"$option_name\" *:" "$config_file" | cut -d':' -f2 | sed s'/[ \"]//g' | cut -d',' -f1 -} - -#================================================= -# LOAD VALUES -#================================================= - -# Load the real value from the app config or elsewhere. -# Then get the value from the form. -# If the form has a value for a variable, take the value from the form, -# Otherwise, keep the value from the app config. - -# Export -old_export="$(ynh_app_setting_get $app export)" -export="${YNH_CONFIG_MAIN_EXPORT_EXPORT:-$old_export}" - -# padOptions noColors -old_pad_config_nocolors="$(get_config_value noColors)" -pad_config_nocolors="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_NOCOLORS:-$old_pad_config_nocolors}" - -# padOptions showLineNumbers -old_pad_config_showlinenumbers="$(get_config_value showLineNumbers)" -pad_config_showlinenumbers="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOWLINENUMBERS:-$old_pad_config_showlinenumbers}" - -# padOptions chatAndUsers -old_pad_config_chatandusers="$(get_config_value chatAndUsers)" -pad_config_chatandusers="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_CHATANDUSERS:-$old_pad_config_chatandusers}" - -# padOptions alwaysShowChat -old_pad_config_alwaysshowchat="$(get_config_value alwaysShowChat)" -pad_config_alwaysshowchat="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_ALWAYSSHOWCHAT:-$old_pad_config_alwaysshowchat}" - -# Plugin option ep_markdown_default -old_pad_config_show_markdown="$(get_config_value ep_markdown_default)" -pad_config_show_markdown="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOW_MARKDOWN:-$old_pad_config_show_markdown}" - -# MyPads -if [ -d $final_path/node_modules/ep_mypads ] -then - # Enable - old_mypads=1 -else - # Disable - old_mypads=0 -fi -mypads="${YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_MYPADS:-$old_mypads}" - -# LDAP for MyPads -if grep -q "//noldap" $config_file -then - # Disable - old_useldap=0 -else - # Enable - old_useldap=1 -fi -useldap="${YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP:-$old_useldap}" - -# Overwrite settings.json file -old_overwrite_settings="$(ynh_app_setting_get --app=$app --key=overwrite_settings)" -overwrite_settings="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS:-$old_overwrite_settings}" - -# Overwrite credentials.json file -old_overwrite_credentials="$(ynh_app_setting_get --app=$app --key=overwrite_credentials)" -overwrite_credentials="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_CREDENTIALS:-$old_overwrite_credentials}" - -# Overwrite nginx configuration -old_overwrite_nginx="$(ynh_app_setting_get --app=$app --key=overwrite_nginx)" -overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}" - -# Overwrite systemd configuration -old_overwrite_systemd="$(ynh_app_setting_get --app=$app --key=overwrite_systemd)" -overwrite_systemd="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD:-$old_overwrite_systemd}" - -#================================================= -# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND -#================================================= - -show_config() { - # here you are supposed to read some config file/database/other then print the values - # ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value" - - ynh_return "YNH_CONFIG_MAIN_EXPORT_EXPORT=$export" - - ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_NOCOLORS=$pad_config_nocolors" - ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOWLINENUMBERS=$pad_config_showlinenumbers" - ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_CHATANDUSERS=$pad_config_chatandusers" - ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_ALWAYSSHOWCHAT=$pad_config_alwaysshowchat" - ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOW_MARKDOWN=$pad_config_show_markdown" - ynh_return "YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_MYPADS=$mypads" - ynh_return "YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP=$useldap" - ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings" - ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_CREDENTIALS=$overwrite_credentials" - ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx" - ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD=$overwrite_systemd" -} - -#================================================= -# MODIFY THE CONFIGURATION -#================================================= - -apply_config() { - - #================================================= - # MODIFY ETHERPAD CONFIG - #================================================= - - restart_etherpad=0 - - # Change configuration if needed - # padOptions noColors - if [ "$pad_config_nocolors" != "$old_pad_config_nocolors" ] - then - ynh_replace_string --match_string="\(\"noColors\" *: \).*," --replace_string="\1$pad_config_nocolors," --target_file="$config_file" - ynh_app_setting_set --app=$app --key=pad_config_nocolors --value="$pad_config_nocolors" - restart_etherpad=1 - fi - - # padOptions showLineNumbers - if [ "$pad_config_showlinenumbers" != "$old_pad_config_showlinenumbers" ] - then - ynh_replace_string --match_string="\(\"showLineNumbers\" *: \).*," --replace_string="\1$pad_config_showlinenumbers," --target_file="$config_file" - ynh_app_setting_set --app=$app --key=pad_config_showlinenumbers --value="$pad_config_showlinenumbers" - restart_etherpad=1 - fi - - # padOptions chatAndUsers - if [ "$pad_config_chatandusers" != "$old_pad_config_chatandusers" ] - then - ynh_replace_string --match_string="\(\"chatAndUsers\" *: \).*," --replace_string="\1$pad_config_chatandusers," --target_file="$config_file" - ynh_app_setting_set --app=$app --key=pad_config_chatandusers --value="$pad_config_chatandusers" - restart_etherpad=1 - fi - - # padOptions alwaysShowChat - if [ "$pad_config_alwaysshowchat" != "$old_pad_config_alwaysshowchat" ] - then - ynh_replace_string --match_string="\(\"alwaysShowChat\" *: \).*," --replace_string="\1$pad_config_alwaysshowchat," --target_file="$config_file" - ynh_app_setting_set --app=$app --key=pad_config_alwaysshowchat --value="$pad_config_alwaysshowchat" - restart_etherpad=1 - fi - - # Plugin option ep_markdown_default - if [ "$pad_config_show_markdown" != "$old_pad_config_show_markdown" ] - then - ynh_replace_string --match_string="\(\"ep_markdown_default\" *: \).*," --replace_string="\1$pad_config_show_markdown," --target_file="$config_file" - ynh_app_setting_set --app=$app --key=pad_config_show_markdown --value="$pad_config_show_markdown" - restart_etherpad=1 - fi - - # Export - if [ "$export" != "$old_export" ] - then - if [ "$export" = "abiword" ] - then - # if Abiword isn't installed, call the action add_remove_abiword. - if ! which abiword > /dev/null - then - yunohost app action run $app add_remove_abiword - fi - ynh_replace_string --match_string="\(\"abiword\" *: \).*," --replace_string="\1\"$(which abiword)\"," --target_file="$config_file" - ynh_replace_string --match_string="\(\"soffice\" *: \).*," --replace_string="\1null," --target_file="$config_file" - elif [ "$export" = "libreoffice" ] - then - # if LibreOffice isn't installed, call the action add_remove_libreoffice. - if ! which soffice > /dev/null - then - yunohost app action run $app add_remove_libreoffice - fi - ynh_replace_string --match_string="\(\"abiword\" *: \).*," --replace_string="\1null," --target_file="$config_file" - ynh_replace_string --match_string="\(\"soffice\" *: \).*," --replace_string="\1\"$(which soffice)\"," --target_file="$config_file" - else - ynh_replace_string --match_string="\(\"abiword\" *: \).*," --replace_string="\1null," --target_file="$config_file" - ynh_replace_string --match_string="\(\"soffice\" *: \).*," --replace_string="\1null," --target_file="$config_file" - fi - - ynh_app_setting_set --app=$app --key=export --value="$export" - - restart_etherpad=1 - fi - - # MyPads - if [ "$mypads" != "$old_mypads" ] - then - ynh_use_nodejs - #pushd "$final_path/src" - #ynh_secure_remove --file="$final_path/src/package-lock.json" #added to fix saveError ENOENT: no such file or directory - if [ "$mypads" = "1" ] - then - ynh_exec_as $app env "$ynh_node_load_PATH" npm install ep_mypads@${mypads_version} - else - ynh_exec_as $app env "$ynh_node_load_PATH" npm uninstall ep_mypads - fi - popd - chown -R $app: $final_path/node_modules - - ynh_app_setting_set --app=$app --key=mypads --value="$mypads" - - restart_etherpad=1 - fi - - # LDAP for MyPads - if [ "$useldap" != "$old_useldap" ] - then - if [ "$useldap" = "1" ] - then - ynh_replace_string --match_string="//noldap\(.*\)" --replace_string="\1 //useldap" --target_file="$final_path/settings.json" - else - ynh_replace_string --match_string="\(.*\) //useldap" --replace_string="//noldap\1" --target_file="$final_path/settings.json" - fi - - ynh_app_setting_set --app=$app --key=useldap --value="$useldap" - - restart_etherpad=1 - fi - - - if [ $restart_etherpad -eq 1 ] - then - # Wait for etherpad to be fully started - ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" - fi - - #================================================= - # MODIFY OVERWRITTING SETTINGS - #================================================= - - # Set overwrite_settings - ynh_app_setting_set --app=$app --key=overwrite_settings --value="$overwrite_settings" - # Set overwrite_credentials - ynh_app_setting_set --app=$app --key=overwrite_credentials --value="$overwrite_credentials" - # Set overwrite_nginx - ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx" - # Set overwrite_systemd - ynh_app_setting_set --app=$app --key=overwrite_systemd --value="$overwrite_systemd" -} - -#================================================= -# GENERIC FINALIZATION -#================================================= -ynh_app_config_run $1 diff --git a/scripts/install b/scripts/install index 27f6a55..99e7840 100644 --- a/scripts/install +++ b/scripts/install @@ -1,28 +1,14 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then - sleep 60 + sleep 10 fi source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -password="$YNH_APP_ARG_PASSWORD" - -ynh_app_setting_set --app=$app --key=overwrite_settings --value="1" -ynh_app_setting_set --app=$app --key=overwrite_credentials --value="1" -ynh_app_setting_set --app=$app --key=overwrite_nginx --value="1" -ynh_app_setting_set --app=$app --key=overwrite_systemd --value="1" +# Save the passord (not saved automatically by the core) +ynh_app_setting_set --app=$app --key=password --value="$password" #================================================= # INSTALL DEPENDENCIES @@ -73,34 +59,30 @@ chown $app -R /var/log/$app #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=6 +ynh_script_progression --message="Configure etherpad..." -ynh_add_config --template="../conf/settings.json" --destination="$install_dir/settings.json" +abiword_path="null" +soffice_path="null" -if [ "$export" = "abiword" ] +if [[ "$export" == "abiword" ]] then - # Get Abiword binary path - abiword_path=`which abiword` - # Set the path of abiword into Etherpad config - ynh_replace_string --match_string="\"abiword\" : null" --replace_string="\"abiword\" : \"$abiword_path\"" --target_file="$install_dir/settings.json" -elif [ "$export" = "libreoffice" ] + abiword_path="\"$(which abiword)\"" +elif [[ "$export" == "libreoffice" ]] then - # Get soffice binary path - soffice_path=`which soffice` - # Set the path of soffice into Etherpad config - ynh_replace_string --match_string="\"soffice\" : null" --replace_string="\"soffice\" : \"$soffice_path\"" --target_file="$install_dir/settings.json" + soffice_path="\"$(which soffice)\"" fi # Use ldap for mypads +comment_if_ldap_disabled="//ldap_disabled" if [ $mypads -eq 1 ] && [ $useldap -eq 1 ] then - ynh_replace_string --match_string="//noldap\(.*\)" --replace_string="\1 //useldap" --target_file="$install_dir/settings.json" + comment_if_ldap_disabled="" fi # Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$install_dir/settings.json" -ynh_add_config --template="../conf/credentials.json" --destination="$install_dir/credentials.json" +ynh_add_config --template="settings.json" --destination="$install_dir/settings.json" +ynh_add_config --template="credentials.json" --destination="$install_dir/credentials.json" chmod 600 "$install_dir/settings.json" chown $app:$app "$install_dir/settings.json" @@ -156,7 +138,7 @@ popd ynh_script_progression --message="Installing Etherpad..." --weight=90 pushd $install_dir - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH src/bin/installDeps.sh + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH ETHERPAD_PRODUCTION=true src/bin/installDeps.sh popd #================================================= diff --git a/scripts/remove b/scripts/remove index 5008d7e..60e0cd2 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,13 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=3 - -export=$(ynh_app_setting_get --app=$app --key=export) - #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= diff --git a/scripts/restore b/scripts/restore index 7005a1c..78789ad 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,26 +1,13 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# 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 -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=3 - -password=$(ynh_app_setting_get --app=$app --key=password) - #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=2 +# +ynh_script_progression --message="Restoring the app main directory..." --weight=5 ynh_restore_file --origin_path="$install_dir" @@ -38,11 +25,7 @@ chown $app:$app "$install_dir/credentials.json" #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 - -ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" -ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" -ynh_systemd_action --action=restart --service_name=fail2ban +ynh_script_progression --message="Restoring system configurations related to $app..." ynh_install_nodejs --nodejs_version=$nodejs_version ynh_use_nodejs @@ -60,10 +43,14 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" yunohost service add $app --description="Collaborative editor" --log="/var/log/$app/etherpad.log" +ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" +ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" +ynh_systemd_action --action=restart --service_name=fail2ban + #================================================= # RESTORE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --weight=2 +ynh_script_progression --message="Restoring the MySQL database..." --weight=5 echo "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci" | ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql @@ -73,7 +60,7 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./ #================================================= # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and $app's service..." ynh_systemd_action --service_name=$app --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" diff --git a/scripts/upgrade b/scripts/upgrade index b9d3dfc..6a43c06 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,44 +1,8 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=20 - -export=$(ynh_app_setting_get --app=$app --key=export) -password=$(ynh_app_setting_get --app=$app --key=password) -mypads=$(ynh_app_setting_get --app=$app --key=mypads) -useldap=$(ynh_app_setting_get --app=$app --key=useldap) -abiword=$(ynh_app_setting_get --app=$app --key=abiword) -overwrite_settings=$(ynh_app_setting_get --app=$app --key=overwrite_settings) -overwrite_credentials=$(ynh_app_setting_get --app=$app --key=overwrite_credentials) -overwrite_nginx=$(ynh_app_setting_get --app=$app --key=overwrite_nginx) -overwrite_systemd=$(ynh_app_setting_get --app=$app --key=overwrite_systemd) - -# Optional parameters from config-panel feature -pad_config_nocolors=$(ynh_app_setting_get --app=$app --key=pad_config_nocolors) -pad_config_showlinenumbers=$(ynh_app_setting_get --app=$app --key=pad_config_showlinenumbers) -pad_config_chatandusers=$(ynh_app_setting_get --app=$app --key=pad_config_chatandusers) -pad_config_alwaysshowchat=$(ynh_app_setting_get --app=$app --key=pad_config_alwaysshowchat) -pad_config_show_markdown=$(ynh_app_setting_get --app=$app --key=pad_config_show_markdown) - -#================================================= -# CHECK VERSION -#================================================= -ynh_script_progression --message="Checking version..." --weight=1 - -# Wait for etherpad to be fully started -ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" - upgrade_type=$(ynh_check_app_version_changed) #================================================= @@ -46,6 +10,9 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Activating maintenance mode..." --weight=2 +# Wait for etherpad to be fully started # (... but why ???) +ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" + ynh_maintenance_mode_ON #================================================= @@ -62,67 +29,35 @@ ynh_systemd_action --service_name=$app --action="stop" #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=2 -# If abiword setting doesn't exist -if [ -z "${abiword:-}" ]; then - abiword=0 - ynh_app_setting_set --app=$app --key=abiword --value=$abiword +if [ -z "${language:-}" ]; then + # If upgrading from a version which doesn't support translations, set language to English by default + language=en + ynh_app_setting_set --app=$app --key=language --value=$language fi -# If abiword setting exists -if [ -n "${abiword:-}" ]; then - if [ $abiword -eq 1 ]; then - export=abiword - fi - ynh_app_setting_set --app=$app --key=export --value=$export - ynh_app_setting_delete --app=$app --key=abiword -fi - -# If export setting doesn't exist if [ -z "${export:-}" ]; then export=none ynh_app_setting_set --app=$app --key=export --value=$export fi -# If mypads setting doesn't exist if [ -z "${mypads:-}" ]; then mypads=1 ynh_app_setting_set --app=$app --key=mypads --value=$mypads fi -# If useldap setting doesn't exist if [ -z "${useldap:-}" ]; then useldap=0 ynh_app_setting_set --app=$app --key=useldap --value=$useldap fi -# If path setting doesn't exist if [ -z "${path:-}" ]; then path="/" ynh_app_setting_set --app=$app --key=path --value=$path fi -# If overwrite_settings doesn't exist, create it -if [ -z "${overwrite_settings:-}" ]; then - overwrite_settings=1 - ynh_app_setting_set --app=$app --key=overwrite_settings --value=$overwrite_settings -fi - -# If overwrite_credentials doesn't exist, create it -if [ -z "${overwrite_credentials:-}" ]; then - overwrite_credentials=1 - ynh_app_setting_set --app=$app --key=overwrite_credentials --value=$overwrite_credentials -fi - -# If overwrite_nginx doesn't exist, create it -if [ -z "${overwrite_nginx:-}" ]; then - overwrite_nginx=1 - ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx -fi - -# If overwrite_systemd doesn't exist, create it -if [ -z "${overwrite_systemd:-}" ]; then - overwrite_systemd=1 - ynh_app_setting_set --app=$app --key=overwrite_systemd --value=$overwrite_systemd +if [ -z "${password:-}" ]; then + password=$(ynh_string_random --length=32) + ynh_app_setting_set --app=$app --key=password --value="$password" fi # Support full Unicode in MySQL databases @@ -157,11 +92,7 @@ ynh_use_nodejs #================================================= ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 -# Overwrite the NGINX configuration only if it's allowed -if [ $overwrite_nginx -eq 1 ] -then - ynh_add_nginx_config -fi +ynh_add_nginx_config #================================================= # SPECIFIC UPGRADE @@ -177,72 +108,31 @@ chown $app -R /var/log/$app # CONFIGURE ETHERPAD #================================================= -if [ "$upgrade_type" == "UPGRADE_APP" ] +ynh_script_progression --message="Configure etherpad..." + +abiword_path="null" +soffice_path="null" + +if [[ "$export" == "abiword" ]] then - ynh_script_progression --message="Reconfiguring Etherpad..." --weight=3 - - # Overwrite the settings config file only if it's allowed - if [ $overwrite_settings -eq 1 ] - then - # Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. - ynh_backup_if_checksum_is_different --file="$install_dir/settings.json" - - ynh_add_config --template="../conf/settings.json" --destination="$install_dir/settings.json" - - if [ "$export" = "abiword" ] - then - # Get abiword binary path - abiword_path=`which abiword` - # Set the path of Abiword into Etherpad config - ynh_replace_string --match_string="\"abiword\" : null" --replace_string="\"abiword\" : \"$abiword_path\"" --target_file="$install_dir/settings.json" - elif [ "$export" = "libreoffice" ] - then - # Get soffice binary path - soffice_path=`which soffice` - # Set the path of soffice into Etherpad config - ynh_replace_string --match_string="\"soffice\" : null" --replace_string="\"soffice\" : \"$soffice_path\"" --target_file="$install_dir/settings.json" - fi - - if test -z "$language"; then - # If upgrading from a version which doesn't support translations, set language to English by default - language=en - ynh_app_setting_set --app=$app --key=language --value=$language - fi - - # Use LDAP for MyPads - if [ $mypads -eq 1 ] && [ $useldap -eq 1 ] - then - ynh_replace_string --match_string="//noldap" --replace_string="" --target_file="$install_dir/settings.json" - fi - - # Optional parameters from config-panel feature - if [ -n "$pad_config_nocolors" ]; then - ynh_replace_string --match_string="\(\"noColors\" *: \).*," --replace_string="\1$pad_config_nocolors," --target_file="$install_dir/settings.json" - fi - if [ -n "$pad_config_showlinenumbers" ]; then - ynh_replace_string --match_string="\(\"showLineNumbers\" *: \).*," --replace_string="\1$pad_config_showlinenumbers," --target_file="$install_dir/settings.json" - fi - if [ -n "$pad_config_chatandusers" ]; then - ynh_replace_string --match_string="\(\"chatAndUsers\" *: \).*," --replace_string="\1$pad_config_chatandusers," --target_file="$install_dir/settings.json" - fi - if [ -n "$pad_config_alwaysshowchat" ]; then - ynh_replace_string --match_string="\(\"alwaysShowChat\" *: \).*," --replace_string="\1$pad_config_alwaysshowchat," --target_file="$install_dir/settings.json" - fi - if [ -n "$pad_config_show_markdown" ]; then - ynh_replace_string --match_string="\(\"ep_markdown_default\" *: \).*," --replace_string="\1$pad_config_show_markdown," --target_file="$install_dir/settings.json" - fi - - # Recalculate and store the checksum of the file for the next upgrade. - ynh_store_file_checksum --file="$install_dir/settings.json" - fi - - # Overwrite the credentials config file only if it's allowed - if [ $overwrite_credentials -eq 1 ] - then - ynh_add_config --template="../conf/credentials.json" --destination="$install_dir/credentials.json" - fi + abiword_path="\"$(which abiword)\"" +elif [[ "$export" == "libreoffice" ]] +then + soffice_path="\"$(which soffice)\"" fi +# Use ldap for mypads +comment_if_ldap_disabled="//ldap_disabled" +if [ $mypads -eq 1 ] && [ $useldap -eq 1 ] +then + comment_if_ldap_disabled="" +fi + +# Calculate and store the config file checksum into the app settings + +ynh_add_config --template="settings.json" --destination="$install_dir/settings.json" +ynh_add_config --template="credentials.json" --destination="$install_dir/credentials.json" + chmod 600 "$install_dir/settings.json" chown $app:$app "$install_dir/settings.json" @@ -254,11 +144,7 @@ chown $app:$app "$install_dir/credentials.json" #================================================= ynh_script_progression --message="Upgrading systemd configuration..." --weight=2 -# Create a dedicated systemd config -if [ $overwrite_systemd -eq 1 ] -then - ynh_add_systemd_config -fi +ynh_add_systemd_config #================================================= # INSTALL ETHERPAD'S PLUGINS @@ -300,7 +186,7 @@ popd ynh_script_progression --message="Upgrading Etherpad..." --weight=10 pushd $install_dir - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH src/bin/installDeps.sh + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH ETHERPAD_PRODUCTION=true src/bin/installDeps.sh popd #================================================= diff --git a/tests.toml b/tests.toml index 2d300eb..acca843 100644 --- a/tests.toml +++ b/tests.toml @@ -2,37 +2,38 @@ test_format = 1.0 [default] + exclude = ["install.private"] + # ------------------------------- # Default args to use for install # ------------------------------- - - args.export = "libreoffice" + + args.export = "none" args.mypads = 0 args.useldap = 0 - args.password = "admin!42" + args.password = "##SuperAdminPassword##" # ------------------------------- # Commits to test upgrade from # ------------------------------- - test_upgrade_from.4d613658.name = "Upgrade from 1.8.17" + test_upgrade_from.4d613658.name = "1.8.17" -# This is an additional test suite [with_mypads] args.export = "libreoffice" args.mypads = 1 args.useldap = 1 only = ["install.root"] -#[with_abiword] -# args.export = "abiword" -# args.mypads = 1 -# args.useldap = 1 -# only = ["install.root"] +[with_abiword] + args.export = "libreoffice" + args.mypads = 0 + args.useldap = 0 + only = ["install.root"] -#[without_export] -# args.export = "none" -# args.mypads = 1 -# args.useldap = 0 -# only = ["install.root"] +[with_libreoffice] + args.export = "libreoffice" + args.mypads = 0 + args.useldap = 0 + only = ["install.root"]