diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index 858a609..c763ffc 100644 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -9,9 +9,6 @@ # Since each app is different, maintainers can adapt its contents so as to perform # automatic actions when a new upstream release is detected. -# Remove this exit command when you are ready to run this Action -#exit 1 - #================================================= # FETCHING LATEST RELEASE AND ITS ASSETS #================================================= @@ -20,59 +17,44 @@ current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') # Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) -version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) -assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) +version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .tag_name | contains("rc") or contains("beta") or contains("alpha") | not ) | .tag_name' | sort -V | tail -1) +assets="https://github.com/bludit/bludit/archive/$version.tar.gz" -# if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then -# version=${version:1} -# fi +# Later down the script, we assume the version has only digits and dots +# Sometimes the release name starts with a "v", so let's filter it out. +# You may need more tweaks here if the upstream repository has different naming conventions. +if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then + version=${version:1} +fi # Setting up the environment variables echo "Current version: $current_version" echo "Latest release from upstream: $version" echo "VERSION=$version" >> $GITHUB_ENV +echo "REPO=$repo" >> $GITHUB_ENV # For the time being, let's assume the script will fail echo "PROCEED=false" >> $GITHUB_ENV # Proceed only if the retrieved version is greater than the current one if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then - echo "::warning ::No new version available" - exit 0 + echo "::warning ::No new version available" + exit 0 # Proceed only if a PR for this new version does not already exist elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then - echo "::warning ::A branch already exists for this update" - exit 0 + echo "::warning ::A branch already exists for this update" + exit 0 fi -# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) -echo "${#assets[@]} available asset(s)" - #================================================= # UPDATE SOURCE FILES #================================================= -# Here we use the $assets variable to get the resources published in the upstream release. -# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like. - -# Let's loop over the array of assets URLs -for asset_url in ${assets[@]}; do +# Let's download source tarball +asset_url=$assets echo "Handling asset at $asset_url" -# Assign the asset to a source file in conf/ directory -# Here we base the source file name upon a unique keyword in the assets url (admin vs. update) -# Leave $src empty to ignore the asset -case $asset_url in - *".tar.gz") - src="app" - ;; - *) - src="" - ;; -esac - -# If $src is not empty, let's process the asset -if [ ! -z "$src" ]; then +src="app" # Create the temporary directory tempdir="$(mktemp -d)" @@ -99,15 +81,11 @@ SOURCE_SUM=$checksum SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=$extension SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= +SOURCE_EXTRACT=true EOT echo "... conf/$src.src updated" -else -echo "... asset ignored" -fi - -done - #================================================= # SPECIFIC UPDATE STEPS #================================================= diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml index ca77fed..fb72ba0 100644 --- a/.github/workflows/updater.yml +++ b/.github/workflows/updater.yml @@ -40,6 +40,7 @@ jobs: committer: 'yunohost-bot ' author: 'yunohost-bot ' signoff: false + base: testing branch: ci-auto-update-v${{ env.VERSION }} delete-branch: true title: 'Upgrade to version ${{ env.VERSION }}' diff --git a/README.md b/README.md index faee10b..ede603b 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,13 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Simple, Fast, Secure, Flat-File CMS +Bludit is a web application to build your own website or blog in seconds, it's completely free and open source. Bludit uses files in JSON format to store the content, you don't need to install or configure a database. You only need a web server with PHP support. -**Shipped version:** 4.0.0-rc3~ynh1 +Bludit is a Flat-File CMS. + +Bludit supports Markdown and HTML code for the content. + +**Shipped version:** 3.14.1~ynh1 **Demo:** https://demo.bludit.com diff --git a/README_fr.md b/README_fr.md index 567f871..1aea0ae 100644 --- a/README_fr.md +++ b/README_fr.md @@ -15,9 +15,13 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble -CMS simple, rapide, sécurisé et à fichier plat +Bludit is a web application to build your own website or blog in seconds, it's completely free and open source. Bludit uses files in JSON format to store the content, you don't need to install or configure a database. You only need a web server with PHP support. -**Version incluse :** 4.0.0-rc3~ynh1 +Bludit is a Flat-File CMS. + +Bludit supports Markdown and HTML code for the content. + +**Version incluse :** 3.14.1~ynh1 **Démo :** https://demo.bludit.com diff --git a/check_process b/check_process index cd68fd7..1767cc9 100644 --- a/check_process +++ b/check_process @@ -14,6 +14,7 @@ upgrade=1 from_commit=c619ee29991f96e53e5dfb91ad9eb2a6003359f0 backup_restore=1 multi_instance=1 + port_already_use=0 change_url=1 ;;; Options Email= diff --git a/conf/app.src b/conf/app.src index ac57e2f..a2441b7 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,7 @@ -SOURCE_URL=https://github.com/bludit/bludit/archive/refs/tags/4.0.0-rc-3.tar.gz -SOURCE_SUM=aac59bd694f589d6b914623a67bed663e88f344209ebb2a5c139f77871ab190b +SOURCE_URL=https://github.com/bludit/bludit/archive/3.14.1.tar.gz +SOURCE_SUM=27f96c1cd478c0885d402ccd5192ee5c227e5293ea23f53f92d652b9e46bf7af SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= +SOURCE_EXTRACT=true diff --git a/conf/nginx.conf b/conf/nginx.conf index c02ebe4..52ba9bd 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,10 +2,11 @@ location __PATH__/ { # Path to source - alias __FINALPATH__/ ; + alias __FINALPATH__/; index index.php; + # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file client_max_body_size 10M; if (!-e $request_filename) { rewrite ^ __PATH__/index.php last; } @@ -21,6 +22,7 @@ location __PATH__/ { location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; + fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; diff --git a/doc/DECRIPTION.md b/doc/DESCRIPTION.md similarity index 100% rename from doc/DECRIPTION.md rename to doc/DESCRIPTION.md diff --git a/manifest.json b/manifest.json index d42c8a0..00c5d31 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Simple, Fast, Secure, Flat-File CMS", "fr": "CMS simple, rapide, sécurisé et à fichier plat" }, - "version": "4.0.0-rc3~ynh1", + "version": "3.14.1~ynh1", "url": "www.bludit.com", "upstream": { "license": "MIT", diff --git a/scripts/_common.sh b/scripts/_common.sh index b806ab5..53fbef8 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,10 +3,14 @@ #================================================= # COMMON VARIABLES #================================================= +# PHP APP SPECIFIC +#================================================= YNH_PHP_VERSION="8.0" +php_dependencies="php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-dom" -pkg_dependencies="php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-dom" +# dependencies used by the app (must be on a single line) +pkg_dependencies="$php_dependencies" #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index e4db463..9b12047 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,9 +1,12 @@ #!/bin/bash +#================================================= +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -11,6 +14,10 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + true +} +# Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= diff --git a/scripts/change_url b/scripts/change_url index bfb0460..0652a0f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -8,7 +8,6 @@ source _common.sh source /usr/share/yunohost/helpers -ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS @@ -27,8 +26,26 @@ app=$YNH_APP_INSTANCE_NAME #================================================= 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) +#================================================= +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= @@ -76,6 +93,8 @@ then ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi +#================================================= +# GENERIC FINALISATION #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/install b/scripts/install index 6339809..0d30983 100644 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -23,7 +26,6 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC -phpversion=$YNH_PHP_VERSION app=$YNH_APP_INSTANCE_NAME @@ -33,7 +35,7 @@ app=$YNH_APP_INSTANCE_NAME ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url @@ -91,14 +93,18 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated NGINX config ynh_add_nginx_config +#================================================= +# SPECIFIC SETUP #================================================= # SETUP SSOWAT #================================================= ynh_script_progression --message="Configuring permissions..." --weight=1 -# Make app public if necessary or protect it +# Make app public if necessary if [ $is_public -eq 1 ] then + # Everyone can access the app. + # The "main" permission is automatically created before the install script. ynh_permission_update --permission="main" --add="visitors" fi diff --git a/scripts/remove b/scripts/remove index eb4a012..31fa146 100644 --- a/scripts/remove +++ b/scripts/remove @@ -20,12 +20,14 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +#================================================= +# STANDARD REMOVE #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing Bludit main directory..." --weight=4 +ynh_script_progression --message="Removing app main directory..." --weight=4 -# Remove Bludit directory securely +# Remove the app directory securely ynh_secure_remove --file="$final_path" #================================================= diff --git a/scripts/restore b/scripts/restore index 3bbd801..4fd75c7 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -13,12 +14,16 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + true +} +# Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=1 +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -48,7 +53,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring Bludit main directory..." --weight=2 +ynh_script_progression --message="Restoring the app main directory..." --weight=2 ynh_restore_file --origin_path="$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index 5153f8b..9e70719 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,23 +24,26 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up Bludit before upgrading..." --weight=7 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=7 -# Backup the current version of Bludit +# Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -68,17 +71,15 @@ ynh_script_progression --message="Making sure dedicated system user exists..." - ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= -# SPECIFIC UPGRADE -#================================================= -# UPGRADING BLUDIT +# DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading Bludit..." --weight=2 + ynh_script_progression --message="Upgrading source files..." --weight=2 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir=$final_path + ynh_setup_source --dest_dir="$final_path" fi chmod 750 "$final_path" @@ -108,6 +109,8 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config +#================================================= +# GENERIC FINALIZATION #================================================= # RELOAD NGINX #=================================================