From 12ee6097f4f48e6fb765afbe25dd10345e9c8adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 29 Jan 2022 15:29:42 +0100 Subject: [PATCH] Testing (#38) - Upgrade to 21.12.3 - (partially) fix change_url script (we still have problems on multiple URL changes) - Now the app preseves images when updating - Update to PHP8 --- README.md | 6 ++--- README_fr.md | 6 ++--- check_process | 12 ++++------ conf/.env.example | 26 +++++++++++++++++---- conf/app.src | 6 ++--- conf/nginx.conf | 5 ---- doc/DESCRIPTION.md | 1 + manifest.json | 12 ++++------ scripts/_common.sh | 46 +++++++++++++++++++++++++++++++++++-- scripts/change_url | 16 ++++++------- scripts/install | 21 +++++++++++++---- scripts/remove | 16 +++++++++++++ scripts/restore | 17 ++++++++------ scripts/upgrade | 57 ++++++++++++++++++++++++++-------------------- 14 files changed, 166 insertions(+), 81 deletions(-) create mode 100644 doc/DESCRIPTION.md diff --git a/README.md b/README.md index 2ef0e84..617a8f5 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,10 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Platform to create documentation/wiki content +BookStack is an opinionated wiki system that provides a pleasant and simple out of the box experience. New users to an instance should find the experience intuitive and only basic word-processing skills should be required to get involved in creating content on BookStack. The platform should provide advanced power features to those that desire it but they should not interfere with the core simple user experience. -**Shipped version:** 21.05.3~ynh1 + +**Shipped version:** 21.12.3~ynh1 **Demo:** https://demo.bookstackapp.com @@ -36,7 +37,6 @@ For the first time Login, use the default credentials `admin@admin.com` and `pas ## Documentation and resources * Official app website: https://www.bookstackapp.com -* Official user documentation: https://yunohost.org/en/app_bookstack * Official admin documentation: https://www.bookstackapp.com/docs * Upstream app code repository: https://github.com/BookStackApp/BookStack * YunoHost documentation for this app: https://yunohost.org/app_bookstack diff --git a/README_fr.md b/README_fr.md index 4040c56..59bd315 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,9 +11,10 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble -Plateforme pour créer du contenu de documentation/wiki +BookStack is an opinionated wiki system that provides a pleasant and simple out of the box experience. New users to an instance should find the experience intuitive and only basic word-processing skills should be required to get involved in creating content on BookStack. The platform should provide advanced power features to those that desire it but they should not interfere with the core simple user experience. -**Version incluse :** 21.05.3~ynh1 + +**Version incluse :** 21.12.3~ynh1 **Démo :** https://demo.bookstackapp.com @@ -30,7 +31,6 @@ Login using the default admin details `admin@admin.com` with a password of `pass ## Documentations et ressources * Site officiel de l'app : https://www.bookstackapp.com -* Documentation officielle utilisateur : https://yunohost.org/en/app_bookstack * Documentation officielle de l'admin : https://www.bookstackapp.com/docs * Dépôt de code officiel de l'app : https://github.com/BookStackApp/BookStack * Documentation YunoHost pour cette app : https://yunohost.org/app_bookstack diff --git a/check_process b/check_process index b345d9a..ba78743 100644 --- a/check_process +++ b/check_process @@ -12,19 +12,15 @@ setup_private=1 setup_public=1 upgrade=1 - #Testing (#30) - upgrade=1 from_commit=b7abcc46a0c3c90c9b36d4c00e40d26a1aab429b #Testing - upgrade=1 from_commit=ad39f14ce54d80d30c2e847d0b47a7b5af6b6920 + upgrade=1 from_commit=aaa9c9534b01a210989aceb4ad4d2b9c585be6df backup_restore=1 multi_instance=0 - change_url=0 + change_url=1 ;;; Options Email= Notification=none ;;; Upgrade options - ; commit=b7abcc46a0c3c90c9b36d4c00e40d26a1aab429b - name=Testing (#30) - ; commit=ad39f14ce54d80d30c2e847d0b47a7b5af6b6920 - name=Testing + ; commit=aaa9c9534b01a210989aceb4ad4d2b9c585be6df + name=Testing (#35) manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& diff --git a/conf/.env.example b/conf/.env.example index c829544..5c09d5f 100644 --- a/conf/.env.example +++ b/conf/.env.example @@ -6,11 +6,16 @@ # NOTE: If any of your values contain a space or a hash you will need to # wrap the entire value in quotes. (eg. MAIL_FROM_NAME="BookStack Mailer") +# Enable debug mode +# Shows advanced debug information and errors. +# CAN EXPOSE OTHER VARIABLES, LEAVE DISABLED +APP_DEBUG=false + # Application key APP_KEY=SomeRandomString # Application URL -APP_URL=https://__DOMAIN____PATH__ +APP_URL=__APP_URL_DOMAIN__ # Application default language APP_LANG=__LANGUAGE__ @@ -19,12 +24,12 @@ APP_LANG=__LANGUAGE__ APP_AUTO_LANG_PUBLIC=true # Application timezone -APP_TIMEZONE=UTC +APP_TIMEZONE=__TIMEZONE__ # Database details DB_HOST=localhost DB_DATABASE=__DB_NAME__ -DB_USERNAME=__DB_NAME__ +DB_USERNAME=__DB_USER__ DB_PASSWORD=__DB_PWD__ # Mail system to use @@ -52,11 +57,22 @@ LDAP_SERVER=ldap://127.0.0.1:389 LDAP_BASE_DN=ou=users,dc=yunohost,dc=org LDAP_DN=false LDAP_PASS=false -LDAP_USER_FILTER="(&(|(objectclass=posixAccount))(uid={{username}})(permission=cn=__APP__.main,ou=permission,dc=yunohost,dc=org))" -LDAP_VERSION=false +LDAP_USER_FILTER=(&(|(objectclass=posixAccount))(uid={{username}})(permission=cn=__APP__.main,ou=permission,dc=yunohost,dc=org)) +LDAP_VERSION=3 LDAP_TLS_INSECURE=false LDAP_ID_ATTRIBUTE=uid LDAP_EMAIL_ATTRIBUTE=mail LDAP_DISPLAY_NAME_ATTRIBUTE=cn LDAP_FOLLOW_REFERRALS=true LDAP_DUMP_USER_DETAILS=false + +# Set both the cache and session to use Redis +CACHE_DRIVER=redis +SESSION_DRIVER=redis + +# Example of using a single local Redis server +REDIS_SERVERS=127.0.0.1:6379:__REDIS_DB__ + +# Storage system to use +# Can be 'local', 'local_secure' or 's3' +STORAGE_TYPE=local diff --git a/conf/app.src b/conf/app.src index a3fcf7d..3c6c530 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,9 +1,7 @@ -SOURCE_URL=https://github.com/BookStackApp/BookStack/archive/refs/tags/v21.05.3.tar.gz -SOURCE_SUM=a83e2a30ebf58e2bf6d3f0581c7be2cd94d9db531532d1862bc61b6f60f50c0d +SOURCE_URL=https://github.com/BookStackApp/BookStack/archive/refs/tags/v21.12.3.tar.gz +SOURCE_SUM=c6182009052069b62e1c70307bc030cc22439ef1da29baf6a315690093693557 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true SOURCE_EXTRACT=true SOURCE_FILENAME=bookstack.tar.gz - - diff --git a/conf/nginx.conf b/conf/nginx.conf index 269e4e5..3672207 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,11 +4,6 @@ location __PATH__/ { # Path to source alias __FINALPATH__/public/; - # Force usage of https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - client_max_body_size 100m; client_body_timeout 120s; # Default is 60, May need to be increased for very large uploads diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..4683449 --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +BookStack is an opinionated wiki system that provides a pleasant and simple out of the box experience. New users to an instance should find the experience intuitive and only basic word-processing skills should be required to get involved in creating content on BookStack. The platform should provide advanced power features to those that desire it but they should not interfere with the core simple user experience. diff --git a/manifest.json b/manifest.json index 3ef2dc8..e442dbc 100644 --- a/manifest.json +++ b/manifest.json @@ -4,16 +4,15 @@ "packaging_format": 1, "description": { "en": "Platform to create documentation/wiki content", - "fr": "Plateforme pour créer du contenu de documentation/wiki " + "fr": "Plateforme pour créer du contenu de documentation/wiki" }, - "version": "21.05.3~ynh1", + "version": "21.12.3~ynh1", "url": "https://www.bookstackapp.com/", "upstream": { "license": "MIT", "website": "https://www.bookstackapp.com", "demo": "https://demo.bookstackapp.com", "admindoc": "https://www.bookstackapp.com/docs", - "userdoc": "https://yunohost.org/en/app_bookstack", "code": "https://github.com/BookStackApp/BookStack" }, "license": "MIT", @@ -22,7 +21,7 @@ "email": "liberodark@gmail.com" }, "requirements": { - "yunohost": ">= 4.2.4" + "yunohost": ">= 4.3.0" }, "multi_instance": false, "services": [ @@ -33,8 +32,7 @@ "arguments": { "install": [{ "name": "domain", - "type": "domain", - "example": "example.com" + "type": "domain" }, { "name": "path", @@ -49,7 +47,7 @@ "en": "Choose the application language", "fr": "Choisissez la langue de l'application" }, - "choices": ["de", "en", "es", "fr", "it", "nl"], + "choices": ["de", "en", "es", "fr", "it", "nl", "pt"], "default": "en" }, { diff --git a/scripts/_common.sh b/scripts/_common.sh index 6f1c81c..289f09f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,9 @@ # COMMON VARIABLES #================================================= -YNH_PHP_VERSION="7.3" +YNH_PHP_VERSION="8.0" -extra_php_dependencies="php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-tidy php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-gd" +pkg_dependencies="php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-tidy php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-gd" YNH_COMPOSER_VERSION=2.1.1 @@ -21,3 +21,45 @@ YNH_COMPOSER_VERSION=2.1.1 #================================================= # FUTURE OFFICIAL HELPERS #================================================= + +#================================================= +# REDIS HELPERS +#================================================= + +# get the first available redis database +# +# usage: ynh_redis_get_free_db +# | returns: the database number to use +ynh_redis_get_free_db() { + local result max db + result="$(redis-cli INFO keyspace)" + + # get the num + max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+") + + db=0 + # default Debian setting is 15 databases + for i in $(seq 0 "$max") + do + if ! echo "$result" | grep -q "db$i" + then + db=$i + break 1 + fi + db=-1 + done + + test "$db" -eq -1 && ynh_die --message="No available Redis databases..." + + echo "$db" +} + +# Create a master password and set up global settings +# Please always call this script in install and restore scripts +# +# usage: ynh_redis_remove_db database +# | arg: database - the database to erase +ynh_redis_remove_db() { + local db=$1 + redis-cli -n "$db" flushall +} diff --git a/scripts/change_url b/scripts/change_url index 42ec4d0..c91cca3 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,9 +28,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) -language=$(ynh_app_setting_get --app=$app --key=language) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +phpversion=$YNH_PHP_VERSION #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP @@ -99,14 +97,16 @@ fi #================================================= # MODIFY A CONFIG FILE #================================================= +ynh_script_progression --message="Reconfiguring congif file.." --weight=1 -path_url="$new_path" -domain="$new_domain" -mail_pwd=$(ynh_string_random --length=12) +new_app_url_domain="https://${new_domain}${new_path%/}" +old_app_url_domain="https://${old_domain}${old_path%/}" -ynh_add_config --template=../conf/.env.example --destination=$final_path/.env +pushd $final_path + yes | php$phpversion artisan bookstack:update-url $old_app_url_domain $new_app_url_domain +popd -chmod 600 $final_path/.env +sed -i "/APP_URL=/c\APP_URL=$new_app_url_domain" $final_path/.env #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index 3ebf579..e431cb4 100644 --- a/scripts/install +++ b/scripts/install @@ -24,6 +24,10 @@ domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC language=$YNH_APP_ARG_LANGUAGE +phpversion=$YNH_PHP_VERSION +timezone="$(cat /etc/timezone)" +redis_db=$(ynh_redis_get_free_db) +mail_pwd=$(ynh_string_random --length=12) app=$YNH_APP_INSTANCE_NAME @@ -46,6 +50,14 @@ ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=language --value=$language +ynh_app_setting_set --app=$app --key=redis_db --value=$redis_db + +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE A MYSQL DATABASE @@ -76,8 +88,8 @@ ynh_setup_source --dest_dir="$final_path" # Set permissions to app files chmod 755 $final_path -chown -R $app:www-data $final_path chmod -R o-rwx $final_path +chown -R $app:www-data $final_path #================================================= # NGINX CONFIGURATION @@ -93,8 +105,7 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --package="$extra_php_dependencies" -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +ynh_add_fpm_config #================================================= # INSTALL LYCHEE WITH COMPOSER @@ -107,8 +118,10 @@ ynh_install_composer --phpversion=$phpversion --workdir=$final_path --install_ar #================================================= # MODIFY A CONFIG FILE #================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 + +app_url_domain="https://$domain${path_url%/}" -mail_pwd=$(ynh_string_random --length=12) ynh_add_config --template=../conf/.env.example --destination=$final_path/.env chmod 600 $final_path/.env diff --git a/scripts/remove b/scripts/remove index 5d4bbf6..1d03002 100644 --- a/scripts/remove +++ b/scripts/remove @@ -20,6 +20,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) +redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) #================================================= # REMOVE THE MYSQL DATABASE @@ -29,6 +30,13 @@ ynh_script_progression --message="Removing the MySQL database..." --weight=1 # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name +#================================================= +# REMOVE THE REDIS DATABASE +#================================================= +ynh_script_progression --message="Removing the redis database..." + +ynh_redis_remove_db "$redis_db" + #================================================= # REMOVE APP MAIN DIR #================================================= @@ -53,6 +61,14 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2 # Remove the dedicated PHP-FPM config ynh_remove_fpm_config +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 6039fae..fde38c3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -27,17 +27,14 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +phpversion=$YNH_PHP_VERSION #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=1 -ynh_webpath_available --domain=$domain --path_url=$path_url \ - || ynh_die --message="Path not available: ${domain}${path_url}" -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " +test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -68,6 +65,14 @@ chown -R $app:www-data $final_path chmod -R o-rwx $final_path chmod 600 $final_path/.env +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=1 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= @@ -75,8 +80,6 @@ ynh_script_progression --message="Reconfiguring PHP-FPM..." --weight=5 ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -ynh_add_fpm_config --package="$extra_php_dependencies" - #================================================= # RESTORE THE MYSQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index a693c39..b9e2380 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,7 +23,9 @@ language=$(ynh_app_setting_get --app=$app --key=language) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +phpversion=$YNH_PHP_VERSION +redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) +mail_pwd=$(ynh_string_random --length=12) #================================================= # CHECK VERSION @@ -45,6 +47,18 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + #================================================= # CREATE DEDICATED USER #================================================= @@ -61,23 +75,8 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=1 - # Create a temporary directory - tmpdir="$(mktemp -d)" - - # Backup the config file in the temp dir - cp -a "$final_path/.env" "$tmpdir/.env" - - # Remove the app directory securely - ynh_secure_remove --file="$final_path" - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" - - # Copy the admin saved settings from tmp directory to final path - cp -a "$tmpdir/.env" "$final_path/.env" - - # Remove the tmp directory securely - ynh_secure_remove --file="$tmpdir" + ynh_setup_source --dest_dir="$final_path" --keep="$final_path/.env $final_path/public/uploads $final_path/storage/uploads" fi #================================================= @@ -88,13 +87,20 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # PHP-FPM CONFIGURATION #================================================= ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 # Create a dedicated PHP-FPM config -ynh_add_fpm_config --package="$extra_php_dependencies" +ynh_add_fpm_config #================================================= # INSTALL LYCHEE WITH COMPOSER @@ -102,7 +108,7 @@ ynh_add_fpm_config --package="$extra_php_dependencies" ynh_script_progression --message="Installing BookStack with Composer..." --weight=5 # Install composer -ynh_install_composer --phpversion=$phpversion --workdir=$final_path --install_args="--prefer-source --no-dev" +ynh_install_composer --install_args="--no-dev" #================================================= # FINAL BOOKSTACK INSTALL @@ -110,16 +116,17 @@ ynh_install_composer --phpversion=$phpversion --workdir=$final_path --install_ar ynh_script_progression --message="Install BookStack" --weight=5 pushd $final_path - php$phpversion artisan migrate --no-interaction \ - && php$phpversion artisan cache:clear --no-interaction \ - && php$phpversion artisan view:clear --no-interaction + php$phpversion artisan migrate --force + php$phpversion artisan key:generate --force + php$phpversion artisan cache:clear + php$phpversion artisan config:clear + php$phpversion artisan view:clear popd -# Set permissions on app files chmod 755 $final_path -chown -R $app:www-data $final_path chmod -R o-rwx $final_path -chmod 600 $final_path/.env +chown -R $app:www-data $final_path +#chmod 600 $final_path/.env #================================================= # RELOAD NGINX