From 1563843553194181b39366df6778e0cf410b0f95 Mon Sep 17 00:00:00 2001 From: Bastien Le Querrec <blq@laquadrature.net> Date: Thu, 30 May 2024 16:39:25 +0200 Subject: [PATCH] =?UTF-8?q?s3:=20ajoute=20un=20param=C3=A8tre=20avec=20le?= =?UTF-8?q?=20dossier=20o=C3=B9=20sont=20situ=C3=A9es=20les=20donn=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 4 ++-- s3/download-all-from-s3.sh | 9 +++++---- s3/download-from-s3.sh | 11 +++++++---- s3/upload-all-to-s3.sh | 7 ++++--- s3/upload-to-s3.sh | 9 ++++++--- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c848e6c..44b1308 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -74,10 +74,10 @@ pep8: - unprivileged needs: [install] script: - - s3/download-from-s3.sh "${PREF}" "${S3_KEY}" "${S3_SECRET}" "${S3_HOST}" "${S3_BUCKET}" || true + - s3/download-from-s3.sh "${PREF}" "${S3_KEY}" "${S3_SECRET}" "${S3_HOST}" "${S3_BUCKET}" data/ || true - /etc/init.d/tor start - make "${PREF}" - - s3/upload-to-s3.sh "${PREF}" "${S3_KEY}" "${S3_SECRET}" "${S3_HOST}" "${S3_BUCKET}" || true + - s3/upload-to-s3.sh "${PREF}" "${S3_KEY}" "${S3_SECRET}" "${S3_HOST}" "${S3_BUCKET}" data/ || true cache: key: $CI_COMMIT_REF_SLUG paths: diff --git a/s3/download-all-from-s3.sh b/s3/download-all-from-s3.sh index be63608..23e1f77 100755 --- a/s3/download-all-from-s3.sh +++ b/s3/download-all-from-s3.sh @@ -6,6 +6,7 @@ s3_key="${1}" s3_secret="${2}" s3_host="${3}" s3_bucket="${4}" +dest="${5}" root_path=$(dirname $(realpath "${BASH_SOURCE[0]}")) @@ -111,12 +112,12 @@ pref973 pref974 pref976" -if test -z "$s3_key" || test -z "$s3_secret" || test -z "$s3_host" || test -z "$s3_bucket"; then - echo "Usage: ${0} <s3_key> <s3_secret> <s3_host> <s3_bucket>" +if test -z "$s3_key" || test -z "$s3_secret" || test -z "$s3_host" || test -z "$s3_bucket" || test -z "$dest"; then + echo "Usage: ${0} <s3_key> <s3_secret> <s3_host> <s3_bucket> <dest>" exit 1 fi for i in $administrations; do - ${root_path}/download-from-s3.sh "${i}" "$s3_key" "$s3_secret" "$s3_host" "$s3_bucket" || true - rm "${root_path}/../data/${i}.zip" || true + ${root_path}/download-from-s3.sh "${i}" "$s3_key" "$s3_secret" "$s3_host" "$s3_bucket" "$dest" || true + rm "${dest}/${i}.zip" || true done diff --git a/s3/download-from-s3.sh b/s3/download-from-s3.sh index 1a36d55..239823d 100755 --- a/s3/download-from-s3.sh +++ b/s3/download-from-s3.sh @@ -7,14 +7,17 @@ s3_key="${2}" s3_secret="${3}" s3_host="${4}" s3_bucket="${5}" +dest="${6}" -if test -z "$pref" || test -z "$s3_key" || test -z "$s3_secret" || test -z "$s3_host" || test -z "$s3_bucket"; then - echo "Usage: ${0} <pref> <s3_key> <s3_secret> <s3_host> <s3_bucket>" +if test -z "$pref" || test -z "$s3_key" || test -z "$s3_secret" || test -z "$s3_host" || test -z "$s3_bucket" || test -z "$dest"; then + echo "Usage: ${0} <pref> <s3_key> <s3_secret> <s3_host> <s3_bucket> <dest>" exit 1 fi -mkdir -p "$(dirname $(realpath "${BASH_SOURCE[0]}"))/../data/" -cd "$(dirname $(realpath "${BASH_SOURCE[0]}"))/../data/" +dest=$(realpath "${dest}") + +mkdir -p "${dest}/" +cd "${dest}/" file="${pref}.zip" diff --git a/s3/upload-all-to-s3.sh b/s3/upload-all-to-s3.sh index 8062253..7b48c00 100755 --- a/s3/upload-all-to-s3.sh +++ b/s3/upload-all-to-s3.sh @@ -6,6 +6,7 @@ s3_key="${1}" s3_secret="${2}" s3_host="${3}" s3_bucket="${4}" +data="${5}" root_path=$(dirname $(realpath "${BASH_SOURCE[0]}")) @@ -111,11 +112,11 @@ pref973 pref974 pref976" -if test -z "$s3_key" || test -z "$s3_secret" || test -z "$s3_host" || test -z "$s3_bucket"; then - echo "Usage: ${0} <s3_key> <s3_secret> <s3_host> <s3_bucket>" +if test -z "$s3_key" || test -z "$s3_secret" || test -z "$s3_host" || test -z "$s3_bucket" || test -z "$data"; then + echo "Usage: ${0} <s3_key> <s3_secret> <s3_host> <s3_bucket> <data>" exit 1 fi for i in $administrations; do - ${root_path}/upload-to-s3.sh "${i}" "$s3_key" "$s3_secret" "$s3_host" "$s3_bucket" || true + ${root_path}/upload-to-s3.sh "${i}" "$s3_key" "$s3_secret" "$s3_host" "$s3_bucket" "$data" || true done diff --git a/s3/upload-to-s3.sh b/s3/upload-to-s3.sh index 90a2ac4..7d0d378 100755 --- a/s3/upload-to-s3.sh +++ b/s3/upload-to-s3.sh @@ -7,13 +7,16 @@ s3_key="${2}" s3_secret="${3}" s3_host="${4}" s3_bucket="${5}" +data="${6}" -if test -z "$pref" || test -z "$s3_key" || test -z "$s3_secret" || test -z "$s3_host" || test -z "$s3_bucket"; then - echo "Usage: ${0} <pref> <s3_key> <s3_secret> <s3_host> <s3_bucket>" +if test -z "$pref" || test -z "$s3_key" || test -z "$s3_secret" || test -z "$s3_host" || test -z "$s3_bucket" || test -z "$data"; then + echo "Usage: ${0} <pref> <s3_key> <s3_secret> <s3_host> <s3_bucket> <data>" exit 1 fi -cd "$(dirname $(realpath "${BASH_SOURCE[0]}"))/../data/${pref}/raa" +data=$(realpath "${data}") + +cd "${data}/${pref}/raa" cd "../../" file="${pref}.zip" -- GitLab