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 01eeaa1..3051ccc 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,16 @@ 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:** 3.14.1~ynh1 +Bludit is a Flat-File CMS. +Bludit supports Markdown and HTML code for the content. + +**Shipped version:** 3.14.1~ynh2 + + +**Demo:** https://demo.bludit.com ## Screenshots diff --git a/README_fr.md b/README_fr.md index 2c6431f..b93b222 100644 --- a/README_fr.md +++ b/README_fr.md @@ -15,10 +15,16 @@ 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 :** 3.14.1~ynh1 +Bludit is a Flat-File CMS. +Bludit supports Markdown and HTML code for the content. + +**Version incluse :** 3.14.1~ynh2 + + +**Démo :** https://demo.bludit.com ## Captures d'écran diff --git a/check_process b/check_process index a6c65c9..1767cc9 100644 --- a/check_process +++ b/check_process @@ -11,13 +11,15 @@ setup_private=1 setup_public=1 upgrade=1 + upgrade=1 from_commit=c619ee29991f96e53e5dfb91ad9eb2a6003359f0 backup_restore=1 multi_instance=1 + port_already_use=0 change_url=1 ;;; Options Email= Notification=none ;;; Upgrade options - ; commit=CommitHash - name=Name and date of the commit. + ; commit=c619ee29991f96e53e5dfb91ad9eb2a6003359f0 + name=Testing (#12) manifest_arg=domain=DOMAIN&path=PATH&is_public=1& diff --git a/conf/app.src b/conf/app.src index 9626f7f..a2441b7 100644 --- a/conf/app.src +++ b/conf/app.src @@ -3,3 +3,5 @@ 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/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..45ff103 --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1,5 @@ +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. + +Bludit is a Flat-File CMS. + +Bludit supports Markdown and HTML code for the content. \ No newline at end of file diff --git a/manifest.json b/manifest.json index fd90fb8..82d7603 100644 --- a/manifest.json +++ b/manifest.json @@ -1,53 +1,54 @@ { - "name": "Bludit", - "id": "bludit", - "packaging_format": 1, - "description": { - "en": "Simple, Fast, Secure, Flat-File CMS", - "fr": "CMS simple, rapide, sécurisé et à fichier plat" - }, - "version": "3.14.1~ynh1", - "url": "www.bludit.com", - "upstream": { + "name": "Bludit", + "id": "bludit", + "packaging_format": 1, + "description": { + "en": "Simple, Fast, Secure, Flat-File CMS", + "fr": "CMS simple, rapide, sécurisé et à fichier plat" + }, + "version": "3.14.1~ynh2", + "url": "www.bludit.com", + "upstream": { "license": "MIT", "website": "www.bludit.com", + "demo": "https://demo.bludit.com", "admindoc": "https://docs.bludit.com/en/", "code": "https://github.com/bludit/bludit" }, - "license": "MIT", - "maintainer": { - "name": "eric_G", - "email": "" - }, - "requirements": { - "yunohost": ">= 11.0.9" - }, - "multi_instance": true, - "services": [ - "nginx", - "php7.4-fpm" - ], - "arguments": { - "install" : [ - { - "name": "domain", - "type": "domain" + "license": "MIT", + "maintainer": { + "name": "eric_G", + "email": "" }, - { - "name": "path", - "type": "path", - "example": "/bludit", - "default": "/bludit" - }, - { - "name": "is_public", - "type": "boolean", - "help": { - "en": "If enabled, Bludit will be accessible by people who do not have an account. This can be changed later via the webadmin.", - "fr": "Si cette case est cochée, Bludit sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." - }, - "default": true - } - ] - } + "requirements": { + "yunohost": ">= 11.0.9" + }, + "multi_instance": true, + "services": [ + "nginx", + "php8.0-fpm" + ], + "arguments": { + "install": [ + { + "name": "domain", + "type": "domain" + }, + { + "name": "path", + "type": "path", + "example": "/bludit", + "default": "/bludit" + }, + { + "name": "is_public", + "type": "boolean", + "help": { + "en": "If enabled, Bludit will be accessible by people who do not have an account. This can be changed later via the webadmin.", + "fr": "Si cette case est cochée, Bludit sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." + }, + "default": true + } + ] + } } diff --git a/scripts/_common.sh b/scripts/_common.sh index c9c6ad2..53fbef8 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,10 +3,14 @@ #================================================= # COMMON VARIABLES #================================================= +# PHP APP SPECIFIC +#================================================= -YNH_PHP_VERSION="7.4" +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}-json 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 88a8aa0..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 #================================================= @@ -51,4 +58,4 @@ ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for Bludit. (YunoHost will then actually copy those files to the archive)." +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 61cba03..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 #================================================= @@ -87,4 +106,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for Bludit" --last +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index a32ba47..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 @@ -32,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 @@ -90,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 @@ -112,4 +119,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of Bludit completed" --last +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index abd4725..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" #================================================= @@ -64,4 +66,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of Bludit completed" --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index bcef493..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" @@ -56,10 +61,9 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" -#================================================= -# SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES +#================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=1 # Define and install dependencies @@ -79,8 +83,6 @@ ynh_script_progression --message="Restoring the NGINX web server configuration.. ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= @@ -93,4 +95,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for Bludit" --last +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 36d5c5d..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 #================================================= @@ -119,4 +122,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of Bludit completed" --last +ynh_script_progression --message="Upgrade of $app completed" --last