diff --git a/README.md b/README.md index 2359a5f..67479e0 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in 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.08.2~ynh1 +**Shipped version:** 21.11.2~ynh1 **Demo:** https://demo.bookstackapp.com @@ -37,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 147e1b7..0237f66 100644 --- a/README_fr.md +++ b/README_fr.md @@ -14,7 +14,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour 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.08.2~ynh1 +**Version incluse :** 21.11.2~ynh1 **Démo :** https://demo.bookstackapp.com @@ -31,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/conf/.env.example b/conf/.env.example index c829544..b7c1110 100644 --- a/conf/.env.example +++ b/conf/.env.example @@ -52,11 +52,18 @@ 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__ diff --git a/conf/app.src b/conf/app.src index 2ee3e63..72ec5a2 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/BookStackApp/BookStack/archive/refs/tags/v21.08.2.tar.gz -SOURCE_SUM=da3de3ad238596be7ef9b3ed83c745babf2844e82628cabad339643064d9a0b3 +SOURCE_URL=https://github.com/BookStackApp/BookStack/archive/refs/tags/v21.11.2.tar.gz +SOURCE_SUM=82f3632d2e6b0d29ce4e7806e19b678014e9c82f97356465226dbf89f2baba82 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true 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/manifest.json b/manifest.json index 31c158d..965b4bb 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.08.2~ynh1", + "version": "21.11.2~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,12 +21,12 @@ "email": "liberodark@gmail.com" }, "requirements": { - "yunohost": ">= 4.2.4" + "yunohost": ">= 4.3.0" }, "multi_instance": false, "services": [ "nginx", - "php8.0-fpm", + "php7.3-fpm", "mysql" ], "arguments": { diff --git a/scripts/_common.sh b/scripts/_common.sh index 4471fe0..e9fac5a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,9 @@ # COMMON VARIABLES #================================================= -YNH_PHP_VERSION="8.0" +YNH_PHP_VERSION="7.3" -extra_php_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" +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/install b/scripts/install index 4b21d41..1a7a80d 100644 --- a/scripts/install +++ b/scripts/install @@ -24,6 +24,7 @@ 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 app=$YNH_APP_INSTANCE_NAME @@ -46,6 +47,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=phpversion --value=$phpversion + +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE A MYSQL DATABASE @@ -93,8 +102,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 @@ -108,7 +116,11 @@ ynh_install_composer --phpversion=$phpversion --workdir=$final_path --install_ar # MODIFY A CONFIG FILE #================================================= +# Configure redis +redis_db=$(ynh_redis_get_free_db) +ynh_app_setting_set --app="$app" --key=redis_db --value="$redis_db" 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 8622189..fde38c3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -34,8 +34,7 @@ phpversion=$YNH_PHP_VERSION #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=1 -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 @@ -66,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 #================================================= @@ -73,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 e09a2ec..ac26ebf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -62,29 +62,31 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 # Create a temporary directory - #tmpdir="$(mktemp -d)" + tmpdir="$(mktemp -d)" - # Backup the config file in the temp dir - #cp -a "$final_path/.env" "$tmpdir/.env" + cp -a "$final_path/.env " "$tmpdir/.env " + cp -a "$final_path/public/uploads" "$tmpdir/public/uploads" + cp -a "$final_path/storage/uploads" "$tmpdir/storage/uploads" + # Remove the app directory securely - # Remove the app directory securely - #ynh_secure_remove --file="$final_path" + ynh_secure_remove --file=$final_path + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" + + cp -a "$tmpdir/.env " "$final_path/.env " + cp -a "$tmpdir/public/uploads" "$final_path/public/uploads" + cp -a "$tmpdir/storage/uploads" "$final_path/storage/uploads" + + # Remove the tmp directory securely + ynh_secure_remove --file="$tmpdir" # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" --keep="$final_path/.env" - - # 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 -# Set permissions on app files chmod 755 $final_path chmod -R o-rwx $final_path chown -R $app:www-data $final_path -chmod 600 $final_path/.env #================================================= # NGINX CONFIGURATION @@ -94,13 +96,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 @@ -116,9 +125,10 @@ 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 --no-interaction + php$phpversion artisan cache:clear --no-interaction + php$phpversion artisan config:clear --no-interaction + php$phpversion artisan view:clear --no-interaction popd #=================================================