diff --git a/conf/app.src b/conf/app.src index 310a01e..5f77699 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://git.tt-rss.org/git/tt-rss/archive/153cb6d30510f9804fe596ac6777bc2f35111ae2.tar.gz -SOURCE_SUM=1413d5d2ce6e4dfd63f4c69bb79f6e18287313756329eaf61928ce25085ebc13 +SOURCE_URL=https://git.tt-rss.org/git/tt-rss/archive/19.2.tar.gz +SOURCE_SUM=6a4bfa9d0706bdcdd342f1a4e89e160b7bccb9396dcdfa52da2dd6bb6b5e5ec9 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 0d4dc66..fda86fe 100644 --- a/manifest.json +++ b/manifest.json @@ -8,13 +8,13 @@ }, "url": "http://tt-rss.org", "license": "GPL-3.0-only", - "version": "153cb6d30510f9804fe596ac6777bc2f35111ae2", + "version": "19.2~ynh1", "maintainer": { "name": "titoko", "email": "titoko@titoko.fr" }, "requirements": { - "yunohost": ">= 2.7.12" + "yunohost": ">= 3.2.0" }, "multi_instance": true, "services": [ diff --git a/pull_request_template.md b/pull_request_template.md index 6c8f664..676c89a 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -19,7 +19,6 @@ - [ ] **Approval (LGTM)** : - [ ] **Approval (LGTM)** : - **CI succeeded** : -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/ttrss_ynh%20-BRANCH-%20(Official)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/ttrss_ynh%20-BRANCH-%20(Official)/) *Please replace '-BRANCH-' in this link for a PR from a local branch.* -or -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/ttrss_ynh%20PR-NUM-%20(Official_fork)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/ttrss_ynh%20PR-NUM-%20(Official_fork)/) *Replace '-NUM-' by the PR number in this link for a PR from a forked repository.* +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/ttrss_ynh%20PR-NUM-/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/ttrss_ynh%20PR-NUM-/) +*Please replace '-NUM-' in this link by the PR number.* When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. diff --git a/scripts/_common.sh b/scripts/_common.sh index d92d1ad..31bfc5a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -14,3 +14,29 @@ ynh_delete_file_checksum () { local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' ynh_app_setting_delete $app $checksum_setting_name } + +ynh_smart_mktemp () { + local min_size="${1:-300}" + # Transform the minimum size from megabytes to kilobytes + min_size=$(( $min_size * 1024 )) + + # Check if there's enough free space in a directory + is_there_enough_space () { + local free_space=$(df --output=avail "$1" | sed 1d) + test $free_space -ge $min_size + } + + if is_there_enough_space /tmp; then + local tmpdir=/tmp + elif is_there_enough_space /var; then + local tmpdir=/var + elif is_there_enough_space /; then + local tmpdir=/ + elif is_there_enough_space /home; then + local tmpdir=/home + else + ynh_die "Insufficient free space to continue..." + fi + + echo "$(sudo mktemp --directory --tmpdir="$tmpdir")" +} diff --git a/scripts/remove b/scripts/remove index a09e254..225440d 100644 --- a/scripts/remove +++ b/scripts/remove @@ -64,6 +64,17 @@ ynh_remove_fpm_config ynh_remove_systemd_config +#================================================= +# REMOVE SERVICE FROM ADMIN PANEL +#================================================= + +# Remove a service from the admin panel, added by `yunohost service add` +if yunohost service status | grep -q $app +then + echo "Remove $app service" + yunohost service remove $app +fi + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index fa8304a..ad523b7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -# source _common.sh +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -40,6 +40,10 @@ fi ynh_backup_before_upgrade # Backup the current version of the app ynh_clean_setup () { + # Delete any created temporary folder + if [ -v tmpdir ] && [ -d $tmpdir ]; then + ynh_secure_remove $tmpdir + fi ynh_restore_upgradebackup # restore it if the upgrade fails } ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée. @@ -64,8 +68,11 @@ path_url=$(ynh_normalize_url_path $path_url) # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +# Create a temporary directory +tmpdir="$(ynh_smart_mktemp 10)" + # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +ynh_setup_source "$tmpdir" #================================================= # NGINX CONFIGURATION @@ -99,6 +106,14 @@ ynh_add_fpm_config # CONFIGURE TTRSS #================================================= +# Backup the config file in the temp dir +cp -a "$final_path/config.php" "$tmpdir/config.php" + +# Replace the old ttrss by the new one +ynh_secure_remove "$final_path" +mv "$tmpdir" "$final_path" +ynh_secure_remove "$tmpdir" + # Verify the checksum and backup the file if it's different ynh_backup_if_checksum_is_different "$final_path/config.php" @@ -126,6 +141,7 @@ sudo -u $app php ${final_path}/update.php --update-schema # Set permissions to app files chown -R root: $final_path +chmod 0755 $final_path chown -R $app $final_path/{cache,feed-icons,lock} #================================================= diff --git a/sources/patches/app-login_remote_user.patch b/sources/patches/app-login_remote_user.patch new file mode 100644 index 0000000..0ae748b --- /dev/null +++ b/sources/patches/app-login_remote_user.patch @@ -0,0 +1,21 @@ +--- /include/functions.php ++++ /include/functions.php +@@ -825,6 +825,18 @@ + } + + } else { ++ /* We need to check that the "REMOTE_USER" and "uid" are same. ++ * If it has changed it's probably that the user logged out and ++ * was authenticated with a other username. ++ * In this case we need to reauthenticate the user ++ */ ++ if (AUTH_AUTO_LOGIN && $_SERVER["REMOTE_USER"] != $_SESSION["uid"]) { ++ if (authenticate_user(null, null)) { ++ $_SESSION["ref_schema_version"] = get_schema_version(true); ++ } else { ++ authenticate_user(null, null, true); ++ } ++ } + /* bump login timestamp */ + $sth = $pdo->prepare("UPDATE ttrss_users SET last_login = NOW() WHERE id = ?"); + $sth->execute([$_SESSION['uid']]);