From 161654aa713d93a3f8c3471d17a6d86d09db2d9b Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 26 Mar 2020 09:15:54 +0100 Subject: [PATCH 1/7] 4.1.1 --- README.md | 2 +- conf/app.src | 4 ++-- manifest.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 39f7165..d91b7c7 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to Jirafeau is a web site permitting to upload a file in a simple way and give an unique link to it. -**Shipped version:** 3.4.1 +**Shipped version:** 4.1.1 ## Screenshots diff --git a/conf/app.src b/conf/app.src index a5bd3c5..3d97ab1 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://gitlab.com/mojo42/Jirafeau/repository/3.4.1/archive.tar.gz -SOURCE_SUM=7719dcac5080ebfb65500b64c24e358d +SOURCE_URL=https://gitlab.com/mojo42/Jirafeau/repository/4.1.1/archive.tar.gz +SOURCE_SUM=37f1754dfa3e8fc1ed81904a3dc33752 SOURCE_SUM_PRG=md5sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 2a347ff..11f0f9f 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Upload a file in a simple way and give a unique link to it", "fr": "Hébergez simplement un fichier et partagez-le avec un lien unique" }, - "version": "3.4.1~ynh3", + "version": "4.1.1~ynh1", "url": "https://gitlab.com/mojo42/Jirafeau", "license": "AGPL-3.0-only", "maintainer": { From f632f8c53034b2fca0f7d290c2197bbbbbfd0776 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 26 Mar 2020 12:22:13 +0100 Subject: [PATCH 2/7] prevent un-authorized access to var --- conf/nginx.conf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conf/nginx.conf b/conf/nginx.conf index 4b8549c..297ec9f 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -32,6 +32,11 @@ location __PATH__/ { deny all; } + location ~ ^__PATH__/var-.* { + deny all; + return 404; + } + location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; From 3edb29ef1ca35d69c8f78aa2032ddcd829af3834 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 26 Mar 2020 12:29:39 +0100 Subject: [PATCH 3/7] Migrate files and links to var- --- scripts/_common.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index a9bf588..88dd601 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1 +1,7 @@ #!/bin/bash + +# Migrate files folder +find files -type f ! -name "*_count" | while read f; do bn="$(basename "$f")"; dst="files/${bn:0:8}/${bn:8:8}/${bn:16:8}/${bn:24:8}/"; mkdir -p "$dst"; mv "$f" "$dst" ; mv "${f}_count" "$dst"; done; find files -maxdepth 1 -type d -iname "?" -exec rm -rf {} \; + +# Migrate links folder +find links -type f | while read link; do bn="$(basename "$link")"; mkdir "links/$bn"; mv "$link" "links/$bn/"; done; find links -maxdepth 1 -type d -iname "?" -exec rm -rf {} \; From 46251563065e531d95d7cd4cd33a3074037ad8f1 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 26 Mar 2020 12:44:04 +0100 Subject: [PATCH 4/7] undo changes --- conf/nginx.conf | 4 ---- scripts/_common.sh | 6 ------ 2 files changed, 10 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 297ec9f..edefb01 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -32,10 +32,6 @@ location __PATH__/ { deny all; } - location ~ ^__PATH__/var-.* { - deny all; - return 404; - } location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; diff --git a/scripts/_common.sh b/scripts/_common.sh index 88dd601..a9bf588 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,7 +1 @@ #!/bin/bash - -# Migrate files folder -find files -type f ! -name "*_count" | while read f; do bn="$(basename "$f")"; dst="files/${bn:0:8}/${bn:8:8}/${bn:16:8}/${bn:24:8}/"; mkdir -p "$dst"; mv "$f" "$dst" ; mv "${f}_count" "$dst"; done; find files -maxdepth 1 -type d -iname "?" -exec rm -rf {} \; - -# Migrate links folder -find links -type f | while read link; do bn="$(basename "$link")"; mkdir "links/$bn"; mv "$link" "links/$bn/"; done; find links -maxdepth 1 -type d -iname "?" -exec rm -rf {} \; From 8a3449ec64847af7281005e6d7e1937e624a29d7 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 26 Mar 2020 18:45:03 +0100 Subject: [PATCH 5/7] Files migration for 4.1.1 --- scripts/upgrade | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 8aaae53..c3f2e20 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -51,6 +51,67 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi +# Migrate files from 3.4.1 to 4.1.1 +current_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$app/manifest.json")" +update_version="$(ynh_app_upstream_version)" +# If the upgrade if from a version 3 or less to 4 or more. Migrate the files +if [ ${current_version:0:1} -le 3 ] && [ ${update_version:0:1} -ge 4 ] +then + ynh_script_progression --message="Migrating files..." --weight=5 + + var_root=/home/yunohost.app/$app + + # Migrate files and links to the new directory structure + for type in files links + do + while read file + do + # Ignore _count files + if echo "$file" | grep --quiet "_count$"; then + continue + fi + + # Remove all directories before the file name + full_file="$file" + file=$(basename $file) + + # Split the file name every 8 characters + split=0 + full_path="$var_root/$type" + while [ $split -le ${#file} ] + do + part_dir="${file:$split:8}" + # Increment the point where with start reading of 8. + split=$((split+8)) + full_path="$full_path/$part_dir" + done + + # Create the new crazy directory structure + mkdir -p "$full_path" + # And move the file to this place + mv "$full_file" "$full_path/$file" + if [ "$type" = "files" ]; then + mv "${full_file}_count" "$full_path" + fi + done <<< "$(sudo find "$var_root/$type" -type f)" # List all files, without directories + done + + # And clean the old directories + for type in files links + do + while read file + do + # Remove all directories before the last one + dirname="$(basename $file)" + # Delete the directory if it's only one character long + if [ ${#dirname} -eq 1 ] + then + rm -r "$file" + fi + done <<< "$(sudo find "$var_root/$type" -maxdepth 1 -mindepth 1 -type d)" # List all first level directories + done +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= From 7d4d0c9d51288802b591a352e0e50b32bd8d149e Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 27 Mar 2020 11:05:33 +0100 Subject: [PATCH 6/7] remove sudo --- scripts/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index c3f2e20..5f2e454 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -93,7 +93,7 @@ then if [ "$type" = "files" ]; then mv "${full_file}_count" "$full_path" fi - done <<< "$(sudo find "$var_root/$type" -type f)" # List all files, without directories + done <<< "$(find "$var_root/$type" -type f)" # List all files, without directories done # And clean the old directories @@ -108,7 +108,7 @@ then then rm -r "$file" fi - done <<< "$(sudo find "$var_root/$type" -maxdepth 1 -mindepth 1 -type d)" # List all first level directories + done <<< "$(find "$var_root/$type" -maxdepth 1 -mindepth 1 -type d)" # List all first level directories done fi From 94754fc9d4d22f31635783109eded96b8c7bce1d Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 29 Mar 2020 13:47:08 +0200 Subject: [PATCH 7/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 39f7165..fc9cbe9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Jirafeau for YunoHost -[![Integration level](https://dash.yunohost.org/integration/jirafeau.svg)](https://dash.yunohost.org/appci/app/jirafeau) +[![Integration level](https://dash.yunohost.org/integration/jirafeau.svg)](https://dash.yunohost.org/appci/app/jirafeau) ![](https://ci-apps.yunohost.org/ci/badges/jirafeau.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/jirafeau.maintain.svg) [![Install Jirafeau with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=jirafeau) > *This package allow you to install Jirafeau quickly and simply on a YunoHost server.