From 40bdbe870b4eae96382b9274f0d78b775e5f879a Mon Sep 17 00:00:00 2001 From: Claudius Coenen Date: Thu, 2 May 2019 00:54:38 +0200 Subject: [PATCH 01/27] Repository has changed Hi, the repository for CodiMD has changed, the community project can now be found here: https://github.com/codimd/server If you wish to know more about this change, we've written a few things about it here: https://github.com/codimd/server/issues/10 --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 1181a5f..6faf26f 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,7 @@ CodiMD Server **Shipped version:** 1.2.1 - [Yunohost project](https://yunohost.org) -- [CodiMD website](https://github.com/hackmdio/codimd/) - -![](https://res-4.cloudinary.com/crunchbase-production/image/upload/c_lpad,h_256,w_256,f_auto,q_auto:eco/xk9kzyfebpc16ryhpxlk) - +- [CodiMD website](https://github.com/codimd/server/) [![Install CodiMD with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=codimd) From d4d53b51e1357a343921f2dcd7c57dd8f6fbb160 Mon Sep 17 00:00:00 2001 From: lapineige Date: Fri, 31 May 2019 10:40:26 +0200 Subject: [PATCH 02/27] Update to 1.4.0 Release notes https://github.com/codimd/server/releases/tag/1.4.0 --- conf/app.src | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/app.src b/conf/app.src index 8acf5cd..56d4691 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/hackmdio/codimd/archive/1.2.1.tar.gz -SOURCE_SUM=850fe2e4aed30eb3f83d77f1d9d8421ad0ab52f24ec7faaa07d4269cc440d4e4 +SOURCE_URL=https://github.com/codimd/server/archive/1.4.0.tar.gz +SOURCE_SUM=a39c1e0ac603c8b1a4abbe63e1db170ecbb3014813b88cc265e6ab218fd0ab24 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true From 12b1564a363ce5f937fe73022e63d532c685d368 Mon Sep 17 00:00:00 2001 From: lapineige Date: Fri, 31 May 2019 18:33:37 +0200 Subject: [PATCH 03/27] Update readme - 1.4.0 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6faf26f..c6ed9ca 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # CodiMD app for YunoHost CodiMD Server -**Shipped version:** 1.2.1 +**Shipped version:** 1.4.0 - [Yunohost project](https://yunohost.org) - [CodiMD website](https://github.com/codimd/server/) From 6d230822e46152cd06e82490b74c24c27559ab6c Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 13 Oct 2019 17:34:22 +0200 Subject: [PATCH 04/27] Improve description, don't just say it's "$app for Yunohost" which is implicit --- manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 887c8b8..546b7b2 100644 --- a/manifest.json +++ b/manifest.json @@ -3,8 +3,8 @@ "id": "codimd", "packaging_format": 1, "description": { - "en": "CodiMD package for YunoHost.", - "fr": "CodiMD pour YunoHost." + "en": "Platform for realtime collaborative work on markdown documents", + "fr": "Travaillez collaborativement et en temps réel sur des documents markdown" }, "version": "1.2.1", "url": "https://github.com/hackmdio/codimd/", From 90512c7d08f43b9738d0fd6af57a7174aeebacb1 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 27 Nov 2019 16:11:07 +0100 Subject: [PATCH 05/27] Remove these unecessary stuff... --- scripts/install | 27 --------------------------- scripts/remove | 19 ------------------- 2 files changed, 46 deletions(-) diff --git a/scripts/install b/scripts/install index b4d5b9d..75f12a7 100644 --- a/scripts/install +++ b/scripts/install @@ -13,10 +13,6 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -41,8 +37,6 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder" # Normalize the url path syntax path_url=$(ynh_normalize_url_path $path_url) -# Check web path availability -ynh_webpath_available $domain $path_url # Register (book) web path ynh_webpath_register $app $domain $path_url @@ -54,21 +48,6 @@ ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url ynh_app_setting_set $app is_public $is_public -#================================================= -# FIND AND OPEN A PORT -#================================================= - -### Use these lines if you have to open a port for the application -### `ynh_find_port` will find the first available port starting from the given port. -### If you're not using these lines: -### - Remove the section "CLOSE A PORT" in the remove script - -# Find a free port -port=$(ynh_find_port 3000) -# Open this port -yunohost firewall allow --no-upnp TCP $port 2>&1 -ynh_app_setting_set $app port $port - #============================================== # INSTALL POSTGRES #============================================== @@ -142,12 +121,6 @@ ynh_add_nginx_config # SETUP SYSTEMD #================================================= -#cp ../conf/systemd.service /etc/systemd/system/$app.service -#ynh_replace_string "__NODEJS__" "$nodejs_use_version" "/etc/systemd/system/$app.service" -#ynh_replace_string "__ENV_PATH__" "$PATH" "/etc/systemd/system/$app.service" -#ynh_replace_string "__NODE__" "$nodejs_path" "/etc/systemd/system/$app.service" -#ynh_add_systemd_config - ynh_replace_string "__APP__" "$app" "../conf/systemd.service" ynh_replace_string "__FINALPATH__" "$final_path" "../conf/systemd.service" ynh_replace_string "__NODEJS__" "$nodejs_use_version" "../conf/systemd.service" diff --git a/scripts/remove b/scripts/remove index a186acc..538d593 100644 --- a/scripts/remove +++ b/scripts/remove @@ -17,7 +17,6 @@ ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) -port=$(ynh_app_setting_get $app port) db_name=$(ynh_app_setting_get $app db_name) db_user=$db_name final_path=$(ynh_app_setting_get $app final_path) @@ -75,14 +74,6 @@ ynh_print_info "Removing nginx web server configuration" # Remove the dedicated nginx config ynh_remove_nginx_config -#================================================= -# REMOVE PHP-FPM CONFIGURATION -#================================================= -#ynh_print_info "Removing php-fpm configuration" - -# Remove the dedicated php-fpm config -#ynh_remove_fpm_config - #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= @@ -91,16 +82,6 @@ ynh_print_info "Removing logrotate configuration" # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_print_info "Closing port $port" - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - #================================================= # SPECIFIC REMOVE #================================================= From b5fecb6677c7e2adcbcb2061f181d92af4f83e14 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 27 Nov 2019 16:11:27 +0100 Subject: [PATCH 06/27] Use nodejs 8 as advised by the documentation --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 75f12a7..051b32a 100644 --- a/scripts/install +++ b/scripts/install @@ -59,7 +59,7 @@ ynh_install_app_dependencies postgresql apt-transport-https #================================================= # Use Helper instead of package from the repo -ynh_install_nodejs 6 +ynh_install_nodejs 8 #============================================== # CREATE DB From b98286b87269e26222a13130b8576f3f5d657a36 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 27 Nov 2019 16:16:06 +0100 Subject: [PATCH 07/27] Bump to version 1.5.0 --- conf/app.src | 4 ++-- manifest.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index 56d4691..79beb92 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/codimd/server/archive/1.4.0.tar.gz -SOURCE_SUM=a39c1e0ac603c8b1a4abbe63e1db170ecbb3014813b88cc265e6ab218fd0ab24 +SOURCE_URL=https://github.com/codimd/server/archive/1.5.0.tar.gz +SOURCE_SUM=2321fb054c85e5ffcb73443e3ea9fbf8c370387f2b5709a23c21f71233fdb454 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 887c8b8..b31e53c 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "CodiMD package for YunoHost.", "fr": "CodiMD pour YunoHost." }, - "version": "1.2.1", + "version": "1.5.0~ynh1", "url": "https://github.com/hackmdio/codimd/", "license": "free", "maintainer": { From 6e8953b582f7b6333feaa9e59feec3df98985308 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 27 Nov 2019 16:27:54 +0100 Subject: [PATCH 08/27] Remove / fix nonsense --- check_process | 42 -------- manifest.json | 28 ++--- scripts/_common.sh | 260 --------------------------------------------- scripts/backup | 33 ------ scripts/install | 3 +- scripts/restore | 52 --------- scripts/upgrade | 57 ---------- 7 files changed, 8 insertions(+), 467 deletions(-) delete mode 100644 check_process delete mode 100644 scripts/_common.sh delete mode 100644 scripts/backup delete mode 100644 scripts/restore delete mode 100644 scripts/upgrade diff --git a/check_process b/check_process deleted file mode 100644 index 0cbeae3..0000000 --- a/check_process +++ /dev/null @@ -1,42 +0,0 @@ -# See here for more informations -# 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) - path="/" (PATH) - is_public=1 (PUBLIC|public=1|private=0) -# password="pass" -# nextclouddomain="domain.tld" - port="9980" (PORT) - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=1 - setup_nourl=0 - setup_private=0 - setup_public=1 - upgrade=1 - backup_restore=1 - multi_instance=1 - incorrect_path=1 - port_already_use=0 - change_url=0 -;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto -# Level 4: - Level 4=1 (This app supports the Nextcloud LDAP auth) -# Level 5: - Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 -;;; Options -Email= -Notification=none diff --git a/manifest.json b/manifest.json index b31e53c..82d4564 100644 --- a/manifest.json +++ b/manifest.json @@ -3,24 +3,22 @@ "id": "codimd", "packaging_format": 1, "description": { - "en": "CodiMD package for YunoHost.", - "fr": "CodiMD pour YunoHost." + "en": "A collaborative editor to work on notes written in Markdown", + "fr": "Un éditeur collaboratif pour travailler sur des notes en Markdown" }, "version": "1.5.0~ynh1", - "url": "https://github.com/hackmdio/codimd/", - "license": "free", + "url": "https://github.com/codimd/server", + "license": "AGPL-v3", "maintainer": { "name": "liberodark", "email": "liberodark@gmail.com" }, "requirements": { - "yunohost": ">= 2.7.2" + "yunohost": ">= 3.6" }, - "multi_instance": true, + "multi_instance": false, "services": [ - "nginx", - "php5-fpm", - "mysql" + "nginx" ], "arguments": { "install": [{ @@ -32,18 +30,6 @@ }, "example": "example.com" }, - - { - "name": "path", - "type": "path", - "ask": { - "en": "Choose a path for CodiMD only / is accepted", - "fr": "Choisissez un chemin pour CodiMD seulement / est accepté" - }, - "example": "/", - "default": "/" - }, - { "name": "is_public", "type": "boolean", diff --git a/scripts/_common.sh b/scripts/_common.sh deleted file mode 100644 index 367dafb..0000000 --- a/scripts/_common.sh +++ /dev/null @@ -1,260 +0,0 @@ -#!/bin/bash - -# ============================================================================= -# YUNOHOST 2.7 FORTHCOMING HELPERS -# ============================================================================= - -# Create a dedicated nginx config -# -# usage: ynh_add_nginx_config -ynh_add_nginx_config () { - finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf" - ynh_backup_if_checksum_is_different "$finalnginxconf" - sudo cp ../conf/nginx.conf "$finalnginxconf" - - # To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable. - # Substitute in a nginx config file only if the variable is not empty - if test -n "${path_url:-}"; then - ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf" - fi - if test -n "${domain:-}"; then - ynh_replace_string "__DOMAIN__" "$domain" "$finalnginxconf" - fi - if test -n "${port:-}"; then - ynh_replace_string "__PORT__" "$port" "$finalnginxconf" - fi - if test -n "${app:-}"; then - ynh_replace_string "__NAME__" "$app" "$finalnginxconf" - fi - if test -n "${final_path:-}"; then - ynh_replace_string "__FINALPATH__" "$final_path" "$finalnginxconf" - fi - ynh_store_file_checksum "$finalnginxconf" - - sudo systemctl reload nginx -} - -# Remove the dedicated nginx config -# -# usage: ynh_remove_nginx_config -ynh_remove_nginx_config () { - ynh_secure_remove "/etc/nginx/conf.d/$domain.d/$app.conf" - sudo systemctl reload nginx -} - -# Create a dedicated php-fpm config -# -# usage: ynh_add_fpm_config -ynh_add_fpm_config () { - finalphpconf="/etc/php5/fpm/pool.d/$app.conf" - ynh_backup_if_checksum_is_different "$finalphpconf" - sudo cp ../conf/php-fpm.conf "$finalphpconf" - ynh_replace_string "__NAMETOCHANGE__" "$app" "$finalphpconf" - ynh_replace_string "__FINALPATH__" "$final_path" "$finalphpconf" - ynh_replace_string "__USER__" "$app" "$finalphpconf" - sudo chown root: "$finalphpconf" - ynh_store_file_checksum "$finalphpconf" - - if [ -e "../conf/php-fpm.ini" ] - then - finalphpini="/etc/php5/fpm/conf.d/20-$app.ini" - ynh_backup_if_checksum_is_different "$finalphpini" - sudo cp ../conf/php-fpm.ini "$finalphpini" - sudo chown root: "$finalphpini" - ynh_store_file_checksum "$finalphpini" - fi - - sudo systemctl reload php5-fpm -} - -# Remove the dedicated php-fpm config -# -# usage: ynh_remove_fpm_config -ynh_remove_fpm_config () { - ynh_secure_remove "/etc/php5/fpm/pool.d/$app.conf" - ynh_secure_remove "/etc/php5/fpm/conf.d/20-$app.ini" 2>&1 - sudo systemctl reload php5-fpm -} - -# Create a dedicated systemd config -# -# usage: ynh_add_systemd_config -ynh_add_systemd_config () { - finalsystemdconf="/etc/systemd/system/$app.service" - ynh_backup_if_checksum_is_different "$finalsystemdconf" - sudo cp ../conf/systemd.service "$finalsystemdconf" - - # To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable. - # Substitute in a nginx config file only if the variable is not empty - if test -n "${final_path:-}"; then - ynh_replace_string "__FINALPATH__" "$final_path" "$finalsystemdconf" - fi - if test -n "${app:-}"; then - ynh_replace_string "__APP__" "$app" "$finalsystemdconf" - fi - ynh_store_file_checksum "$finalsystemdconf" - - sudo chown root: "$finalsystemdconf" - sudo systemctl enable $app - sudo systemctl daemon-reload -} - -# Remove the dedicated systemd config -# -# usage: ynh_remove_systemd_config -ynh_remove_systemd_config () { - finalsystemdconf="/etc/systemd/system/$app.service" - if [ -e "$finalsystemdconf" ]; then - sudo systemctl stop $app - sudo systemctl disable $app - ynh_secure_remove "$finalsystemdconf" - fi -} - -#================================================= -# POSTGRES HELPERS -#================================================= - -# Open a connection as a user -# -# example: ynh_psql_connect_as 'user' 'pass' <<< "UPDATE ...;" -# example: ynh_psql_connect_as 'user' 'pass' < /path/to/file.sql -# -# usage: ynh_psql_connect_as user pwd [db] -# | arg: user - the user name to connect as -# | arg: pwd - the user password -# | arg: db - the database to connect to -ynh_psql_connect_as() { - user="$1" - pwd="$2" - db="$3" - su --command="PGUSER=\"${user}\" PGPASSWORD=\"${pwd}\" psql \"${db}\"" postgres -} - -# # Execute a command as root user -# -# usage: ynh_psql_execute_as_root sql [db] -# | arg: sql - the SQL command to execute -# | arg: db - the database to connect to -ynh_psql_execute_as_root () { - sql="$1" - su --command="psql" postgres <<< "$sql" -} - -# Execute a command from a file as root user -# -# usage: ynh_psql_execute_file_as_root file [db] -# | arg: file - the file containing SQL commands -# | arg: db - the database to connect to -ynh_psql_execute_file_as_root() { - file="$1" - db="$2" - su -c "psql $db" postgres < "$file" -} - -# Create a database, an user and its password. Then store the password in the app's config -# -# After executing this helper, the password of the created database will be available in $db_pwd -# It will also be stored as "psqlpwd" into the app settings. -# -# usage: ynh_psql_setup_db user name [pwd] -# | arg: user - Owner of the database -# | arg: name - Name of the database -# | arg: pwd - Password of the database. If not given, a password will be generated -ynh_psql_setup_db () { - db_user="$1" - app="$1" - db_name="$2" - new_db_pwd=$(ynh_string_random) # Generate a random password - # If $3 is not given, use new_db_pwd instead for db_pwd. - db_pwd="${3:-$new_db_pwd}" - ynh_psql_create_db "$db_name" "$db_user" "$db_pwd" # Create the database - ynh_app_setting_set "$app" psqlpwd "$db_pwd" # Store the password in the app's config -} - -# Create a database and grant optionnaly privilegies to a user -# -# usage: ynh_psql_create_db db [user [pwd]] -# | arg: db - the database name to create -# | arg: user - the user to grant privilegies -# | arg: pwd - the user password -ynh_psql_create_db() { - db="$1" - user="$2" - pwd="$3" - ynh_psql_create_user "$user" "$pwd" - su --command="createdb --owner=\"${user}\" \"${db}\"" postgres -} - -# Drop a database -# -# usage: ynh_psql_drop_db db user -# | arg: db - the database name to drop -# | arg: user - the user to drop -ynh_psql_remove_db() { - db="$1" - user="$2" - su --command="dropdb \"${db}\"" postgres - ynh_psql_drop_user "${user}" -} - -# Dump a database -# -# example: ynh_psql_dump_db 'roundcube' > ./dump.sql -# -# usage: ynh_psql_dump_db db -# | arg: db - the database name to dump -# | ret: the psqldump output -ynh_psql_dump_db() { - db="$1" - su --command="pg_dump \"${db}\"" postgres -} - - -# Create a user -# -# usage: ynh_psql_create_user user pwd [host] -# | arg: user - the user name to create -ynh_psql_create_user() { - user="$1" - pwd="$2" - su --command="psql -c\"CREATE USER ${user} WITH PASSWORD '${pwd}'\"" postgres -} - -# Drop a user -# -# usage: ynh_psql_drop_user user -# | arg: user - the user name to drop -ynh_psql_drop_user() { - user="$1" - su --command="dropuser \"${user}\"" postgres -} - -ynh_psql_test_if_first_run() { - if [ -f /etc/yunohost/psql ]; - then - echo "PostgreSQL is already installed, no need to create master password" - else - pgsql=$(ynh_string_random) - pg_hba="" - echo "$pgsql" >> /etc/yunohost/psql - - if [ -e /etc/postgresql/9.4/ ] - then - pg_hba=/etc/postgresql/9.4/main/pg_hba.conf - elif [ -e /etc/postgresql/9.6/ ] - then - pg_hba=/etc/postgresql/9.6/main/pg_hba.conf - else - ynh_die "postgresql shoud be 9.4 or 9.6" - fi - - systemctl start postgresql - su --command="psql -c\"ALTER user postgres WITH PASSWORD '${pgsql}'\"" postgres - # we can't use peer since YunoHost create users with nologin - sed -i '/local\s*all\s*all\s*peer/i \ - local all all password' "$pg_hba" - systemctl enable postgresql - systemctl reload postgresql - fi -} diff --git a/scripts/backup b/scripts/backup deleted file mode 100644 index af8ccd9..0000000 --- a/scripts/backup +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# Exit on command errors and treat unset variables as an error -set -eu - -# See comments in install script -app=$YNH_APP_INSTANCE_NAME - -# Source YunoHost helpers -source /usr/share/yunohost/helpers - -# Backup sources & data -# Note: the last argument is where to save this path, see the restore script. -ynh_backup "/var/www/${app}" "sources" - -### MySQL (remove if not used) ### -# If a MySQL database is used: -# # Dump the database -# dbname=$app -# dbuser=$app -# dbpass=$(ynh_app_setting_get "$app" mysqlpwd) -# mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql -### MySQL end ### - -# Copy NGINX configuration -domain=$(ynh_app_setting_get "$app" domain) -ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" - -### PHP (remove if not used) ### -# If a dedicated php-fpm process is used: -# # Copy PHP-FPM pool configuration -# ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf" -### PHP end ### diff --git a/scripts/install b/scripts/install index 051b32a..39dfcce 100644 --- a/scripts/install +++ b/scripts/install @@ -6,7 +6,6 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -21,7 +20,7 @@ ynh_abort_if_errors #================================================= domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH +path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME diff --git a/scripts/restore b/scripts/restore deleted file mode 100644 index 93169e9..0000000 --- a/scripts/restore +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -# Note: each files and directories you've saved using the ynh_backup helper -# will be located in the current directory, regarding the last argument. - -# Exit on command errors and treat unset variables as an error -set -eu - -# See comments in install script -app=$YNH_APP_INSTANCE_NAME - -# Source YunoHost helpers -source /usr/share/yunohost/helpers - -# Retrieve old app settings -domain=$(ynh_app_setting_get "$app" domain) -path_url=$(ynh_app_setting_get "$app" path_url) - -# Check domain/path availability -sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \ - || ynh_die "Path not available: ${domain}${path_url}" - -# Restore sources & data -src_path="/var/www/${app}" -sudo cp -a ./sources "$src_path" - -# Restore permissions to app files -# you may need to make some file and/or directory writeable by www-data (nginx user) -sudo chown -R root: "$src_path" - -### MySQL (remove if not used) ### -# If a MySQL database is used: -# # Create and restore the database -# dbname=$app -# dbuser=$app -# dbpass=$(ynh_app_setting_get "$app" mysqlpwd) -# ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" -# ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql -### MySQL end ### - -# Restore NGINX configuration -sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" - -### PHP (remove if not used) ### -# If a dedicated php-fpm process is used: -# # Copy PHP-FPM pool configuration and reload the service -# sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf" -# sudo service php5-fpm reload -### PHP end ### - -# Restart webserver -sudo service nginx reload diff --git a/scripts/upgrade b/scripts/upgrade deleted file mode 100644 index 3d706e4..0000000 --- a/scripts/upgrade +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -# Exit on command errors and treat unset variables as an error -set -eu - -# See comments in install script -app=$YNH_APP_INSTANCE_NAME - -# Source YunoHost helpers -source /usr/share/yunohost/helpers -source _common.sh - -# Retrieve app settings -domain=$(ynh_app_setting_get "$app" domain) -password=$(ynh_app_setting_get "$app" password) -is_public=$(ynh_app_setting_get "$app" is_public) -nextclouddomain=$(ynh_app_setting_get "$app" nextclouddomain) - - -# Set permissions to app files -# you may need to make some file and/or directory writeable by www-data (nginx user) -sudo chown -R root: $src_path - -#================================================= -# UPGRADE COLLABORA -#================================================= -ynh_package_update -ynh_install_app_dependencies loolwsd code-brand - -#================================================= -# NGINX CONFIGURATION -#================================================= - -# Create a dedicated nginx config -ynh_add_nginx_config - - -#================================================= -# UPGRADE CONFIG -#================================================= -cp -a ../conf/loolwsd.xml /etc/loolwsd -ynh_replace_string "__NEXTCLOUDDOMAIN__" "$nextcloud_domain" "/etc/loolwsd/loolwsd.xml" -ynh_replace_string "__PASSWORD__" "$password" "/etc/loolwsd/loolwsd.xml" -systemctl restart loolwsd - - - -# If app is public, add url to SSOWat conf as skipped_uris -if [[ $is_public -eq 1 ]]; then - # See install script - ynh_app_setting_set "$app" unprotected_uris "/" -fi - -# Reload nginx service -systemctl restart nginx -systemctl restart loolwsd - From bd271f217012fb0e0d92f7d2e10c484fc17e9b61 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 28 Nov 2019 02:05:34 +0100 Subject: [PATCH 09/27] Make this app actually work ~_~ --- conf/config.json.example | 107 +---------- conf/nginx.conf | 11 +- conf/systemd.service | 6 +- manifest.json | 2 - scripts/install | 131 ++++++------- scripts/remove | 46 ++--- scripts/ynh_add_extra_apt_repos__3 | 294 +++++++++++++++++++++++++++++ 7 files changed, 390 insertions(+), 207 deletions(-) create mode 100644 scripts/ynh_add_extra_apt_repos__3 diff --git a/conf/config.json.example b/conf/config.json.example index 8442e68..6143584 100644 --- a/conf/config.json.example +++ b/conf/config.json.example @@ -1,24 +1,15 @@ + { - "test": { - "db": { - "dialect": "sqlite", - "storage": ":memory:" - } - }, - "development": { - "hsts": { - "enable": false - }, - "db": { - "dialect": "sqlite", - "storage": "./db.codimd.sqlite" - } - }, "production": { - "domain": "localhost", + "protocolUseSSL": true, + "domain": "__DOMAIN__", + "port": __PORT__, + "loglevel": "info", + "useCDN": false, + "allowGravatar": false, "hsts": { "enable": true, - "maxAgeSeconds": "31536000", + "maxAgeSeconds": 31536000, "includeSubdomains": true, "preload": true }, @@ -38,88 +29,6 @@ "host": "localhost", "port": "5432", "dialect": "postgres" - }, - "facebook": { - "clientID": "change this", - "clientSecret": "change this" - }, - "twitter": { - "consumerKey": "change this", - "consumerSecret": "change this" - }, - "github": { - "clientID": "change this", - "clientSecret": "change this" - }, - "gitlab": { - "baseURL": "change this", - "clientID": "change this", - "clientSecret": "change this", - "scope": "use 'read_user' scope for auth user only or remove this property if you need gitlab snippet import/export support (will result to be default scope 'api')", - "version": "use 'v4' if gitlab version > 11, 'v3' otherwise. Default to 'v4'" - }, - "mattermost": { - "baseURL": "change this", - "clientID": "change this", - "clientSecret": "change this" - }, - "dropbox": { - "clientID": "change this", - "clientSecret": "change this", - "appKey": "change this" - }, - "google": { - "clientID": "change this", - "clientSecret": "change this", - "apiKey": "change this" - }, - "ldap": { - "url": "ldap://change_this", - "bindDn": null, - "bindCredentials": null, - "searchBase": "change this", - "searchFilter": "change this", - "searchAttributes": ["change this"], - "usernameField": "change this e.g. cn", - "useridField": "change this e.g. uid", - "tlsOptions": { - "changeme": "See https://nodejs.org/api/tls.html#tls_tls_connect_options_callback" - } - }, - "saml": { - "idpSsoUrl": "change: authentication endpoint of IdP", - "idpCert": "change: certificate file path of IdP in PEM format", - "issuer": "change or delete: identity of the service provider (default: serverurl)", - "identifierFormat": "change or delete: name identifier format (default: 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress')", - "groupAttribute": "change or delete: attribute name for group list (ex: memberOf)", - "requiredGroups": [ "change or delete: group names that allowed" ], - "externalGroups": [ "change or delete: group names that not allowed" ], - "attribute": { - "id": "change or delete this: attribute map for `id` (default: NameID)", - "username": "change or delete this: attribute map for `username` (default: NameID)", - "email": "change or delete this: attribute map for `email` (default: NameID)" - } - }, - "imgur": { - "clientID": "change this" - }, - "minio": { - "accessKey": "change this", - "secretKey": "change this", - "endPoint": "change this", - "secure": true, - "port": 9000 - }, - "s3": { - "accessKeyId": "change this", - "secretAccessKey": "change this", - "region": "change this" - }, - "s3bucket": "change this", - "azure": - { - "connectionString": "change this", - "container": "change this" } } } diff --git a/conf/nginx.conf b/conf/nginx.conf index 4193bce..3c181aa 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,5 +1,10 @@ -location ^~ __PATH__/ { - proxy_pass http://127.0.0.1:__PORT__; +location ^~ / { + # Force usage of https + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } + + proxy_pass http://127.0.0.1:__PORT__/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -10,4 +15,4 @@ location ^~ __PATH__/ { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; -} \ No newline at end of file +} diff --git a/conf/systemd.service b/conf/systemd.service index e0aab0d..7113896 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,5 +1,5 @@ [Unit] -Description=CodiMD service. +Description=__APP__ daemon After=syslog.target network.target [Service] @@ -8,8 +8,8 @@ User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__ Environment="PATH=__ENV_PATH__" -#ExecStart=__NODE__ __NODEJS__ app.js -ExecStart=/opt/node_n/n/versions/node/6/bin/node app.js +Environment="NODE_ENV=production" +ExecStart=/usr/bin/yarn start Restart=always [Install] diff --git a/manifest.json b/manifest.json index 82d4564..717fe98 100644 --- a/manifest.json +++ b/manifest.json @@ -10,8 +10,6 @@ "url": "https://github.com/codimd/server", "license": "AGPL-v3", "maintainer": { - "name": "liberodark", - "email": "liberodark@gmail.com" }, "requirements": { "yunohost": ">= 3.6" diff --git a/scripts/install b/scripts/install index 39dfcce..1b0a551 100644 --- a/scripts/install +++ b/scripts/install @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +source ynh_add_extra_apt_repos__3 source /usr/share/yunohost/helpers #================================================= @@ -27,59 +28,57 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +ynh_script_progression --message="Validating installation parameters..." -### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". -### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app" final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) - # Register (book) web path ynh_webpath_register $app $domain $path_url +port=$(ynh_find_port 3000) + +db_user=$app +db_name=$app +db_pass=$(ynh_string_random 20) + #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url ynh_app_setting_set $app is_public $is_public +ynh_app_setting_set $app port $port +ynh_app_setting_set $app db_pass $db_pass +ynh_app_setting_set $app final_path $final_path #============================================== # INSTALL POSTGRES #============================================== +ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies postgresql apt-transport-https -#================================================= -# INSTALL NODEJS -#================================================= -# Use Helper instead of package from the repo +# Install Yarn +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_install_nodejs 8 #============================================== # CREATE DB #============================================== +ynh_script_progression --message="Creating a database..." -db_user=$app -db_name=$app -db_pass=$(ynh_string_random 20) -ynh_app_setting_set $app db_pass $db_pass - -# Create postgresql database ynh_psql_test_if_first_run -ynh_psql_create_user $db_user $db_pass -ynh_psql_execute_as_root \ -"CREATE DATABASE $db_name ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $db_user;" +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pass #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Setting up source files..." -ynh_app_setting_set $app final_path $final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" @@ -88,10 +87,14 @@ ynh_setup_source "$final_path" #================================================= # Main config File -ynh_replace_string "__DB_USER__" "$db_user" "../conf/config.json.example" -ynh_replace_string "__DB_NAME__" "$db_name" "../conf/config.json.example" -ynh_replace_string "__DB_PASS__" "$db_pass" "../conf/config.json.example" +ynh_replace_string "__PORT__" "$port" "../conf/config.json.example" +ynh_replace_string "__DOMAIN__" "$domain" "../conf/config.json.example" +ynh_replace_string "__PATH__" "${path_url:1}" "../conf/config.json.example" +ynh_replace_string "__DB_USER__" "$db_user" "../conf/config.json.example" +ynh_replace_string "__DB_NAME__" "$db_name" "../conf/config.json.example" +ynh_replace_string "__DB_PASS__" "$db_pass" "../conf/config.json.example" cp ../conf/config.json.example $final_path/config.json +ynh_store_file_checksum "$final_path/config.json" # DB Config File ynh_replace_string "__DB_USER__" "$db_user" "../conf/.sequelizerc.example" @@ -102,76 +105,74 @@ cp ../conf/.sequelizerc.example $final_path/.sequelizerc #============================================== # INSTALL CODIMD #============================================== +ynh_script_progression --message="Building application... (this may take some time and resources!)" pushd $final_path -npm install -npm run build -node_modules/.bin/sequelize db:migrate +./bin/setup +yarn run build +#node_modules/.bin/sequelize db:migrate popd #================================================= # NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config -#================================================= -# SETUP SYSTEMD -#================================================= - -ynh_replace_string "__APP__" "$app" "../conf/systemd.service" -ynh_replace_string "__FINALPATH__" "$final_path" "../conf/systemd.service" -ynh_replace_string "__NODEJS__" "$nodejs_use_version" "../conf/systemd.service" -ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service" -ynh_replace_string "__NODE__" "$nodejs_path" "../conf/systemd.service" -cp ../conf/systemd.service /etc/systemd/system/$app.service -ynh_add_systemd_config - #================================================= # CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Configuring system user..." # Create a system user ynh_system_user_create $app - -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= - -### `ynh_store_file_checksum` is used to store the checksum of a file. -### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`, -### you can make a backup of this file before modifying it again if the admin had modified it. - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum "$final_path/config.json" - - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -### For security reason, any app should set the permissions to root: before anything else. -### Then, if write authorization is needed, any access should be given only to directories -### that really need such authorization. - -# Set permissions to app files chown -R $app:$app $final_path +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." + +ynh_replace_string "__APP__" "$app" "../conf/systemd.service" +ynh_replace_string "__FINALPATH__" "$final_path" "../conf/systemd.service" +ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service" +ynh_replace_string "__NODE__" "$nodejs_path" "../conf/systemd.service" +ynh_add_systemd_config + +yunohost service add $app --description "CodiMD daemon" + +#================================================= +# START SYSTEMD SERVICE +#================================================= + +ynh_script_progression --message="Starting $app..." + +ynh_systemd_action --service_name=$app --action="start" #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Configuring SSOwat..." + # If app is public, add url to SSOWat conf as skipped_uris if [ $is_public -eq 1 ]; then # unprotected_uris allows SSO credentials to be passed anyway. ynh_app_setting_set "$app" unprotected_uris "/" fi -# Reload services -systemctl enable codimd -systemctl start codimd -systemctl restart nginx +#================================================= +# RELOAD NGINX +#================================================= + +ynh_script_progression --message="Reloading nginx web server..." + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 538d593..45b34e8 100644 --- a/scripts/remove +++ b/scripts/remove @@ -6,19 +6,18 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) -db_name=$(ynh_app_setting_get $app db_name) -db_user=$db_name +db_name=$app +db_user=$app final_path=$(ynh_app_setting_get $app final_path) #================================================= @@ -30,14 +29,14 @@ final_path=$(ynh_app_setting_get $app final_path) # Remove a service from the admin panel, added by `yunohost service add` if yunohost service status $app >/dev/null 2>&1 then - ynh_print_info "Removing $app service" + ynh_script_progression --message="Removing $app service" yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_print_info "Stopping and removing the systemd service" +ynh_script_progression --message="Stopping and removing the systemd service" # Remove the dedicated systemd config ynh_remove_systemd_config @@ -45,7 +44,7 @@ ynh_remove_systemd_config #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_print_info "Removing the PostgreSQL database" +ynh_script_progression --message="Removing the PostgreSQL database" # Remove a database if it exists, along with the associated user ynh_psql_remove_db $db_name $db_name @@ -53,7 +52,7 @@ ynh_psql_remove_db $db_name $db_name #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_print_info "Removing dependencies" +ynh_script_progression --message="Removing dependencies" # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -61,7 +60,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info "Removing app main directory" +ynh_script_progression --message="Removing app main directory" # Remove the app directory securely ynh_secure_remove "$final_path" @@ -69,40 +68,17 @@ ynh_secure_remove "$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_print_info "Removing nginx web server configuration" +ynh_script_progression --message="Removing nginx web server configuration" # Remove the dedicated nginx config ynh_remove_nginx_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_print_info "Removing logrotate configuration" - -# Remove the app-specific logrotate config -ynh_remove_logrotate - -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE THE CRON FILE -#================================================= - -# Remove a cron file -ynh_secure_remove "/etc/cron.d/$app" - -# Remove a directory securely -ynh_secure_remove "/etc/$app/" - -# Remove the log files -ynh_secure_remove "/var/log/$app/" - #================================================= # GENERIC FINALIZATION #================================================= # REMOVE DEDICATED USER #================================================= -ynh_print_info "Removing the dedicated system user" +ynh_script_progression --message="Removing the dedicated system user" # Delete a system user ynh_system_user_delete $app @@ -111,4 +87,4 @@ ynh_system_user_delete $app # END OF SCRIPT #================================================= -ynh_print_info "Removal of $app completed" +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/ynh_add_extra_apt_repos__3 b/scripts/ynh_add_extra_apt_repos__3 new file mode 100644 index 0000000..3276f00 --- /dev/null +++ b/scripts/ynh_add_extra_apt_repos__3 @@ -0,0 +1,294 @@ +#!/bin/bash + +# Pin a repository. +# +# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append] +# | arg: -p, --package - Packages concerned by the pin. Or all, *. +# | arg: -i, --pin - Filter for the pin. +# | arg: -p, --priority - Priority for the pin +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +# +# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning. +# +ynh_pin_repo () { + # Declare an array to define the options of this helper. + local legacy_args=pirna + declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append ) + local package + local pin + local priority + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + package="${package:-*}" + priority=${priority:-50} + name="${name:-$app}" + append=${append:-0} + + if [ $append -eq 1 ] + then + append="tee -a" + else + append="tee" + fi + + mkdir -p "/etc/apt/preferences.d" + echo "Package: $package +Pin: $pin +Pin-Priority: $priority" \ + | $append "/etc/apt/preferences.d/$name" +} + +# Add a repository. +# +# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append] +# | arg: -u, --uri - Uri of the repository. +# | arg: -s, --suite - Suite of the repository. +# | arg: -c, --component - Component of the repository. +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +# +# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable +# uri suite component +# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable +# +ynh_add_repo () { + # Declare an array to define the options of this helper. + local legacy_args=uscna + declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append ) + local uri + local suite + local component + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + append=${append:-0} + + if [ $append -eq 1 ] + then + append="tee -a" + else + append="tee" + fi + + mkdir -p "/etc/apt/sources.list.d" + # Add the new repo in sources.list.d + echo "deb $uri $suite $component" \ + | $append "/etc/apt/sources.list.d/$name.list" +} + +# Add an extra repository correctly, pin it and get the key. +# +# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append] +# | arg: -r, --repo - Complete url of the extra repository. +# | arg: -k, --key - url to get the public key. +# | arg: -p, --priority - Priority for the pin +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +ynh_install_extra_repo () { + # Declare an array to define the options of this helper. + local legacy_args=rkpna + declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append ) + local repo + local key + local priority + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + append=${append:-0} + key=${key:-0} + priority=${priority:-} + + if [ $append -eq 1 ] + then + append="--append" + wget_append="tee -a" + else + append="" + wget_append="tee" + fi + + # Split the repository into uri, suite and components. + # Remove "deb " at the beginning of the repo. + repo="${repo#deb }" + + # Get the uri + local uri="$(echo "$repo" | awk '{ print $1 }')" + + # Get the suite + local suite="$(echo "$repo" | awk '{ print $2 }')" + + # Get the components + local component="${repo##$uri $suite }" + + # Add the repository into sources.list.d + ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append + + # Pin the new repo with the default priority, so it won't be used for upgrades. + # Build $pin from the uri without http and any sub path + local pin="${uri#*://}" + pin="${pin%%/*}" + # Set a priority only if asked + if [ -n "$priority" ] + then + priority="--priority=$priority" + fi + ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append + + # Get the public key for the repo + if [ -n "$key" ] + then + mkdir -p "/etc/apt/trusted.gpg.d" + wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null + fi + + # Update the list of package with the new repo + ynh_package_update +} + +# Remove an extra repository and the assiociated configuration. +# +# usage: ynh_remove_extra_repo [--name=name] +# | arg: -n, --name - Name for the files for this repo, $app as default value. +ynh_remove_extra_repo () { + # Declare an array to define the options of this helper. + local legacy_args=n + declare -Ar args_array=( [n]=name= ) + local name + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + + ynh_secure_remove "/etc/apt/sources.list.d/$name.list" + ynh_secure_remove "/etc/apt/preferences.d/$name" + ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg" + ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc" + + # Update the list of package to exclude the old repo + ynh_package_update +} + +# Install packages from an extra repository properly. +# +# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name] +# | arg: -r, --repo - Complete url of the extra repository. +# | arg: -p, --package - The packages to install from this extra repository +# | arg: -k, --key - url to get the public key. +# | arg: -n, --name - Name for the files for this repo, $app as default value. +ynh_install_extra_app_dependencies () { + # Declare an array to define the options of this helper. + local legacy_args=rpkn + declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= ) + local repo + local package + local key + local name + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + key=${key:-0} + + # Set a key only if asked + if [ -n "$key" ] + then + key="--key=$key" + fi + # Add an extra repository for those packages + ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name + + # Install requested dependencies from this extra repository. + ynh_add_app_dependencies --package="$package" + + # Remove this extra repository after packages are installed + ynh_remove_extra_repo --name=$app +} + +#================================================= + +# patched version of ynh_install_app_dependencies to be used with ynh_add_app_dependencies + +# Define and install dependencies with a equivs control file +# This helper can/should only be called once per app +# +# usage: ynh_install_app_dependencies dep [dep [...]] +# | arg: dep - the package name to install in dependence +# You can give a choice between some package with this syntax : "dep1|dep2" +# Example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5" +# This mean in the dependence tree : dep1 & dep2 & (dep3 | dep4 | dep5) +# +# Requires YunoHost version 2.6.4 or higher. +ynh_install_app_dependencies () { + local dependencies=$@ + dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')" + dependencies=${dependencies//|/ | } + local manifest_path="../manifest.json" + if [ ! -e "$manifest_path" ]; then + manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place + fi + + local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file. + if [ ${#version} -eq 0 ]; then + version="1.0" + fi + local dep_app=${app//_/-} # Replace all '_' by '-' + + # Handle specific versions + if [[ "$dependencies" =~ [\<=\>] ]] + then + # Replace version specifications by relationships syntax + # https://www.debian.org/doc/debian-policy/ch-relationships.html + # Sed clarification + # [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice. + # [\<=\>] matches < = or > + # \+ matches one or more occurence of the previous characters, for >= or >>. + # [^,]\+ matches all characters except ',' + # Ex: package>=1.0 will be replaced by package (>= 1.0) + dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')" + fi + + cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build +Section: misc +Priority: optional +Package: ${dep_app}-ynh-deps +Version: ${version} +Depends: ${dependencies} +Architecture: all +Description: Fake package for $app (YunoHost app) dependencies + This meta-package is only responsible of installing its dependencies. +EOF + ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \ + || ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies + rm /tmp/${dep_app}-ynh-deps.control + ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies" +} + +ynh_add_app_dependencies () { + # Declare an array to define the options of this helper. + local legacy_args=pr + declare -Ar args_array=( [p]=package= [r]=replace) + local package + local replace + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + replace=${replace:-0} + + local current_dependencies="" + if [ $replace -eq 0 ] + then + local dep_app=${app//_/-} # Replace all '_' by '-' + if ynh_package_is_installed --package="${dep_app}-ynh-deps" + then + current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) " + fi + + current_dependencies=${current_dependencies// | /|} + fi + + ynh_install_app_dependencies "${current_dependencies}${package}" +} From d03bc6b275946c34d5a55f29db8b902a25b4a520 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 28 Nov 2019 02:12:47 +0100 Subject: [PATCH 10/27] Update README.md --- README.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index c6ed9ca..b12af41 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,18 @@ -# CodiMD app for YunoHost -CodiMD Server +# CodiMD for YunoHost -**Shipped version:** 1.4.0 +A collaborative editor to work on notes written in Markdown + +**Shipped version:** 1.5.0 - [Yunohost project](https://yunohost.org) - [CodiMD website](https://github.com/codimd/server/) +- [Demo](https://demo.codimd.org/) [![Install CodiMD with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=codimd) -### Installing guide - 1. App can be installed by YunoHost **admin web-interface** or by **running following command**: +### Screenshot - $ sudo yunohost app install https://github.com/YunoHost-Apps/codimd_ynh +![](https://demo.codimd.org/screenshot.png) - -### Upgrade this package: - - $ sudo yunohost app upgrade codimd -u https://github.com/YunoHost-Apps/codimd_ynh From d17dacc5d2601182f79380b71f3e795f8dcf2870 Mon Sep 17 00:00:00 2001 From: liberodark Date: Thu, 28 Nov 2019 10:29:31 +0100 Subject: [PATCH 11/27] Update ynh_add_extra_apt_repos__3 --- scripts/ynh_add_extra_apt_repos__3 | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/ynh_add_extra_apt_repos__3 b/scripts/ynh_add_extra_apt_repos__3 index 3276f00..ef9ba2d 100644 --- a/scripts/ynh_add_extra_apt_repos__3 +++ b/scripts/ynh_add_extra_apt_repos__3 @@ -27,7 +27,7 @@ ynh_pin_repo () { name="${name:-$app}" append=${append:-0} - if [ $append -eq 1 ] + if [ "$append" -eq 1 ] then append="tee -a" else @@ -128,7 +128,7 @@ ynh_install_extra_repo () { local component="${repo##$uri $suite }" # Add the repository into sources.list.d - ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append + ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" "$append" # Pin the new repo with the default priority, so it won't be used for upgrades. # Build $pin from the uri without http and any sub path @@ -139,13 +139,13 @@ ynh_install_extra_repo () { then priority="--priority=$priority" fi - ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append + ynh_pin_repo --package="*" --pin="origin \"$pin\"" "$priority" --name="$name" "$append" # Get the public key for the repo if [ -n "$key" ] then mkdir -p "/etc/apt/trusted.gpg.d" - wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null + wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/"$name".gpg > /dev/null fi # Update the list of package with the new repo @@ -200,13 +200,13 @@ ynh_install_extra_app_dependencies () { key="--key=$key" fi # Add an extra repository for those packages - ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name + ynh_install_extra_repo --repo="$repo" "$key" --priority=995 --name="$name" # Install requested dependencies from this extra repository. ynh_add_app_dependencies --package="$package" # Remove this extra repository after packages are installed - ynh_remove_extra_repo --name=$app + ynh_remove_extra_repo --name="$app" } #================================================= @@ -252,7 +252,7 @@ ynh_install_app_dependencies () { dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')" fi - cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build + cat > /tmp/"${dep_app}"-ynh-deps.control << EOF # Make a control file for equivs-build Section: misc Priority: optional Package: ${dep_app}-ynh-deps @@ -262,10 +262,10 @@ Architecture: all Description: Fake package for $app (YunoHost app) dependencies This meta-package is only responsible of installing its dependencies. EOF - ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \ + ynh_package_install_from_equivs /tmp/"${dep_app}"-ynh-deps.control \ || ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies - rm /tmp/${dep_app}-ynh-deps.control - ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies" + rm /tmp/"${dep_app}"-ynh-deps.control + ynh_app_setting_set --app="$app" --key=apt_dependencies --value="$dependencies" } ynh_add_app_dependencies () { @@ -279,12 +279,12 @@ ynh_add_app_dependencies () { replace=${replace:-0} local current_dependencies="" - if [ $replace -eq 0 ] + if [ "$replace" -eq 0 ] then local dep_app=${app//_/-} # Replace all '_' by '-' if ynh_package_is_installed --package="${dep_app}-ynh-deps" then - current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) " + current_dependencies="$(dpkg-query --show --showformat='${Depends}' "${dep_app}"-ynh-deps) " fi current_dependencies=${current_dependencies// | /|} From c59f779a9bee48a0cd22a9e2348b5d628bf98ca7 Mon Sep 17 00:00:00 2001 From: liberodark Date: Thu, 28 Nov 2019 10:29:55 +0100 Subject: [PATCH 12/27] Update remove --- scripts/remove | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/remove b/scripts/remove index 45b34e8..1c60fab 100644 --- a/scripts/remove +++ b/scripts/remove @@ -15,10 +15,10 @@ ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) +domain=$(ynh_app_setting_get "$app" domain) db_name=$app db_user=$app -final_path=$(ynh_app_setting_get $app final_path) +final_path=$(ynh_app_setting_get "$app" final_path) #================================================= # STANDARD REMOVE @@ -27,10 +27,10 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # Remove a service from the admin panel, added by `yunohost service add` -if yunohost service status $app >/dev/null 2>&1 +if yunohost service status "$app" >/dev/null 2>&1 then ynh_script_progression --message="Removing $app service" - yunohost service remove $app + yunohost service remove "$app" fi #================================================= @@ -47,7 +47,7 @@ ynh_remove_systemd_config ynh_script_progression --message="Removing the PostgreSQL database" # Remove a database if it exists, along with the associated user -ynh_psql_remove_db $db_name $db_name +ynh_psql_remove_db "$db_name" "$db_name" #================================================= # REMOVE DEPENDENCIES @@ -81,7 +81,7 @@ ynh_remove_nginx_config ynh_script_progression --message="Removing the dedicated system user" # Delete a system user -ynh_system_user_delete $app +ynh_system_user_delete "$app" #================================================= # END OF SCRIPT From d1072f310e5aa3d26db11d1e39b2177fe7c62542 Mon Sep 17 00:00:00 2001 From: liberodark Date: Thu, 28 Nov 2019 10:30:38 +0100 Subject: [PATCH 13/27] Update install --- scripts/install | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/scripts/install b/scripts/install index 1b0a551..78743bd 100644 --- a/scripts/install +++ b/scripts/install @@ -34,7 +34,7 @@ final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" # Register (book) web path -ynh_webpath_register $app $domain $path_url +ynh_webpath_register "$app" "$domain" $path_url port=$(ynh_find_port 3000) @@ -47,12 +47,12 @@ db_pass=$(ynh_string_random 20) #================================================= ynh_script_progression --message="Storing installation settings..." -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path_url -ynh_app_setting_set $app is_public $is_public -ynh_app_setting_set $app port $port -ynh_app_setting_set $app db_pass $db_pass -ynh_app_setting_set $app final_path $final_path +ynh_app_setting_set "$app" domain "$domain" +ynh_app_setting_set "$app" path $path_url +ynh_app_setting_set "$app" is_public "$is_public" +ynh_app_setting_set "$app" port "$port" +ynh_app_setting_set "$app" db_pass "$db_pass" +ynh_app_setting_set "$app" final_path "$final_path" #============================================== # INSTALL POSTGRES @@ -72,7 +72,7 @@ ynh_install_nodejs 8 ynh_script_progression --message="Creating a database..." ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pass +ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pass" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -93,25 +93,25 @@ ynh_replace_string "__PATH__" "${path_url:1}" "../conf/config.json.example" ynh_replace_string "__DB_USER__" "$db_user" "../conf/config.json.example" ynh_replace_string "__DB_NAME__" "$db_name" "../conf/config.json.example" ynh_replace_string "__DB_PASS__" "$db_pass" "../conf/config.json.example" -cp ../conf/config.json.example $final_path/config.json +cp ../conf/config.json.example "$final_path"/config.json ynh_store_file_checksum "$final_path/config.json" # DB Config File ynh_replace_string "__DB_USER__" "$db_user" "../conf/.sequelizerc.example" ynh_replace_string "__DB_NAME__" "$db_name" "../conf/.sequelizerc.example" ynh_replace_string "__DB_PASS__" "$db_pass" "../conf/.sequelizerc.example" -cp ../conf/.sequelizerc.example $final_path/.sequelizerc +cp ../conf/.sequelizerc.example "$final_path"/.sequelizerc #============================================== # INSTALL CODIMD #============================================== ynh_script_progression --message="Building application... (this may take some time and resources!)" -pushd $final_path +pushd "$final_path" || exit ./bin/setup yarn run build #node_modules/.bin/sequelize db:migrate -popd +popd || exit #================================================= # NGINX CONFIGURATION @@ -127,8 +127,8 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create $app -chown -R $app:$app $final_path +ynh_system_user_create "$app" +chown -R "$app":"$app" "$final_path" #================================================= # SETUP SYSTEMD @@ -141,7 +141,7 @@ ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service" ynh_replace_string "__NODE__" "$nodejs_path" "../conf/systemd.service" ynh_add_systemd_config -yunohost service add $app --description "CodiMD daemon" +yunohost service add "$app" --description "CodiMD daemon" #================================================= # START SYSTEMD SERVICE @@ -149,7 +149,7 @@ yunohost service add $app --description "CodiMD daemon" ynh_script_progression --message="Starting $app..." -ynh_systemd_action --service_name=$app --action="start" +ynh_systemd_action --service_name="$app" --action="start" #================================================= # SETUP SSOWAT @@ -158,7 +158,7 @@ ynh_systemd_action --service_name=$app --action="start" ynh_script_progression --message="Configuring SSOwat..." # If app is public, add url to SSOWat conf as skipped_uris -if [ $is_public -eq 1 ]; then +if [ "$is_public" -eq 1 ]; then # unprotected_uris allows SSO credentials to be passed anyway. ynh_app_setting_set "$app" unprotected_uris "/" fi From 10532492cec895ff424f38843a9d8e39d19ebd6c Mon Sep 17 00:00:00 2001 From: lapineige Date: Thu, 28 Nov 2019 18:06:39 +0100 Subject: [PATCH 14/27] Add more state of the app information --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index b12af41..728e628 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,13 @@ A collaborative editor to work on notes written in Markdown **Shipped version:** 1.5.0 +**Status**: In progress, do *not* consider this app as stable and fully working (yet) + +**To be implemented**: +- Upgrade (right now you need to remove the app and install its new version - your documents are likely to be lost…) +- Backup and restore system + +Links: - [Yunohost project](https://yunohost.org) - [CodiMD website](https://github.com/codimd/server/) - [Demo](https://demo.codimd.org/) From eaeb9a88a17d27f2c2a2b13bb00e0777798fccea Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 18 Feb 2020 20:44:56 +0100 Subject: [PATCH 15/27] updating missing information --- manifest.json | 1 + 1 file changed, 1 insertion(+) diff --git a/manifest.json b/manifest.json index 717fe98..d8bf458 100644 --- a/manifest.json +++ b/manifest.json @@ -10,6 +10,7 @@ "url": "https://github.com/codimd/server", "license": "AGPL-v3", "maintainer": { + "name": "liberodark" }, "requirements": { "yunohost": ">= 3.6" From 71ec651eb747758a5880fc43369b3e35b3db418d Mon Sep 17 00:00:00 2001 From: Lab 8916100448256 Date: Mon, 9 Mar 2020 13:03:26 +0100 Subject: [PATCH 16/27] Use older yarn version 1.19.2-1 --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 78743bd..84df6c7 100644 --- a/scripts/install +++ b/scripts/install @@ -62,7 +62,7 @@ ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies postgresql apt-transport-https # Install Yarn -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_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn=1.19.2-1" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_install_nodejs 8 From aa9d743184ee9729fc9326a9675daf89c7dac746 Mon Sep 17 00:00:00 2001 From: Lab 8916100448256 Date: Mon, 9 Mar 2020 14:40:01 +0100 Subject: [PATCH 17/27] New attempt at pinning the version of yarn --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 84df6c7..33fecd9 100644 --- a/scripts/install +++ b/scripts/install @@ -62,7 +62,7 @@ ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies postgresql apt-transport-https # Install Yarn -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn=1.19.2-1" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn<=1.20" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_install_nodejs 8 From f1371a19e915b97695c0044fbf51820316de76e7 Mon Sep 17 00:00:00 2001 From: Lab 8916100448256 Date: Mon, 9 Mar 2020 14:58:46 +0100 Subject: [PATCH 18/27] Yet another attempt a pinning yarn version --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 33fecd9..8333b85 100644 --- a/scripts/install +++ b/scripts/install @@ -62,7 +62,7 @@ ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies postgresql apt-transport-https # Install Yarn -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn<=1.20" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn(<=1.20)" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_install_nodejs 8 From a4d1ac0d501bf0f98e14a7ef40e6c3f884afbadd Mon Sep 17 00:00:00 2001 From: Lab 8916100448256 Date: Mon, 9 Mar 2020 15:04:47 +0100 Subject: [PATCH 19/27] Again --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 8333b85..f068e36 100644 --- a/scripts/install +++ b/scripts/install @@ -62,7 +62,7 @@ ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies postgresql apt-transport-https # Install Yarn -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn(<=1.20)" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn (<1.20)" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_install_nodejs 8 From d07bdbcd170e2c003f31edbc08369bfdf106c90e Mon Sep 17 00:00:00 2001 From: Lab 8916100448256 Date: Mon, 9 Mar 2020 15:07:19 +0100 Subject: [PATCH 20/27] Another attempt a pinning yarn version --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index f068e36..100e260 100644 --- a/scripts/install +++ b/scripts/install @@ -62,7 +62,7 @@ ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies postgresql apt-transport-https # Install Yarn -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn (<1.20)" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn(<1.20)" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_install_nodejs 8 From 9dd8bb1c54d425f1b371a78d7e000787ef87e7ed Mon Sep 17 00:00:00 2001 From: Lab 8916100448256 Date: Mon, 9 Mar 2020 15:20:44 +0100 Subject: [PATCH 21/27] Revert failed attempt to pin version of yarn --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 100e260..78743bd 100644 --- a/scripts/install +++ b/scripts/install @@ -62,7 +62,7 @@ ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies postgresql apt-transport-https # Install Yarn -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn(<1.20)" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +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_install_nodejs 8 From 1a95f66b9a1997144c0803b5cda77c880d6a94ec Mon Sep 17 00:00:00 2001 From: Lab-8916100448256 <38373466+Lab-8916100448256@users.noreply.github.com> Date: Mon, 9 Mar 2020 17:31:58 +0100 Subject: [PATCH 22/27] Update CodiMD version to 1.6.0 --- conf/app.src | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/app.src b/conf/app.src index 79beb92..bb9317d 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/codimd/server/archive/1.5.0.tar.gz -SOURCE_SUM=2321fb054c85e5ffcb73443e3ea9fbf8c370387f2b5709a23c21f71233fdb454 +SOURCE_URL=https://github.com/codimd/server/archive/1.6.0.tar.gz +SOURCE_SUM=3639eaf70a37ee0513c75259c70b3d0c2c10116e9b2989dc9c571f98017120bd SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true From 871ea3c2de23909aaefd70aa735f1c07db382b11 Mon Sep 17 00:00:00 2001 From: Lab-8916100448256 <38373466+Lab-8916100448256@users.noreply.github.com> Date: Mon, 9 Mar 2020 17:38:20 +0100 Subject: [PATCH 23/27] Update CodiMD version to 1.6.0 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 728e628..60c73bb 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A collaborative editor to work on notes written in Markdown -**Shipped version:** 1.5.0 +**Shipped version:** 1.6.0 **Status**: In progress, do *not* consider this app as stable and fully working (yet) From 637fd0551d1482923a1a6bfee61f9e24c30bf19c Mon Sep 17 00:00:00 2001 From: Lab-8916100448256 <38373466+Lab-8916100448256@users.noreply.github.com> Date: Mon, 9 Mar 2020 18:06:43 +0100 Subject: [PATCH 24/27] nodejs version 10 --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 78743bd..0886114 100644 --- a/scripts/install +++ b/scripts/install @@ -64,7 +64,7 @@ ynh_install_app_dependencies postgresql apt-transport-https # Install Yarn 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_install_nodejs 8 +ynh_install_nodejs 10 #============================================== # CREATE DB From 478ab3381ae609a50fef07a4553c821526e1ea19 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 27 Apr 2020 00:49:29 +0200 Subject: [PATCH 25/27] Use a real boolean for is_public default value in manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index d8bf458..4f4b57b 100644 --- a/manifest.json +++ b/manifest.json @@ -36,7 +36,7 @@ "en": "Is it a public site ?", "fr": "Est-ce un site public ?" }, - "default": "true" + "default": true } ] } From 2f988795c4de69251f672af5da2917090c1e397d Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 27 Apr 2020 01:08:36 +0200 Subject: [PATCH 26/27] I believe it's much simpler to just copypasta the code from bin/setup into the install script --- scripts/install | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 0886114..5b62179 100644 --- a/scripts/install +++ b/scripts/install @@ -108,7 +108,21 @@ cp ../conf/.sequelizerc.example "$final_path"/.sequelizerc ynh_script_progression --message="Building application... (this may take some time and resources!)" pushd "$final_path" || exit -./bin/setup + +# ---- This is copypasta from https://raw.githubusercontent.com/codimd/server/master/bin/setup +if [ ! -f config.json ]; then + cp config.json.example config.json +fi + +if [ ! -f .sequelizerc ]; then + cp .sequelizerc.example .sequelizerc +fi + +yarn install +yarn install --production=false # FIXME: this doesn't sounds like what we want to have for a real deployment ? idk +# ---- End copypasta from https://raw.githubusercontent.com/codimd/server/master/bin/setup + + yarn run build #node_modules/.bin/sequelize db:migrate popd || exit From a152e5dc1073acec587bd00884ede9420352441f Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 27 Apr 2020 04:01:30 +0200 Subject: [PATCH 27/27] Fix stupid bug in add_extra_apt_repo... --- scripts/install | 7 +++---- scripts/ynh_add_extra_apt_repos__3 | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index 5b62179..98b906d 100644 --- a/scripts/install +++ b/scripts/install @@ -105,7 +105,7 @@ cp ../conf/.sequelizerc.example "$final_path"/.sequelizerc #============================================== # INSTALL CODIMD #============================================== -ynh_script_progression --message="Building application... (this may take some time and resources!)" +ynh_script_progression --message="Building application... (this will take some time and resources!)" pushd "$final_path" || exit @@ -118,11 +118,10 @@ if [ ! -f .sequelizerc ]; then cp .sequelizerc.example .sequelizerc fi -yarn install -yarn install --production=false # FIXME: this doesn't sounds like what we want to have for a real deployment ? idk +yarn install --non-interactive +yarn install --non-interactive --production=false # FIXME: this doesn't sounds like what we want to have for a real deployment ? idk # ---- End copypasta from https://raw.githubusercontent.com/codimd/server/master/bin/setup - yarn run build #node_modules/.bin/sequelize db:migrate popd || exit diff --git a/scripts/ynh_add_extra_apt_repos__3 b/scripts/ynh_add_extra_apt_repos__3 index ef9ba2d..3784020 100644 --- a/scripts/ynh_add_extra_apt_repos__3 +++ b/scripts/ynh_add_extra_apt_repos__3 @@ -128,7 +128,7 @@ ynh_install_extra_repo () { local component="${repo##$uri $suite }" # Add the repository into sources.list.d - ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" "$append" + ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append # Pin the new repo with the default priority, so it won't be used for upgrades. # Build $pin from the uri without http and any sub path @@ -139,7 +139,7 @@ ynh_install_extra_repo () { then priority="--priority=$priority" fi - ynh_pin_repo --package="*" --pin="origin \"$pin\"" "$priority" --name="$name" "$append" + ynh_pin_repo --package="*" --pin="origin \"$pin\"" "$priority" --name="$name" $append # Get the public key for the repo if [ -n "$key" ]