From 7067e8fb47a0d492e578ecbf8e815cd4cea7a861 Mon Sep 17 00:00:00 2001 From: leafee98 Date: Tue, 4 Apr 2023 11:43:17 +0800 Subject: [PATCH] Add scripts as example or tool to create and upload tar --- scripts/create_archive.sh | 11 +++++++++++ scripts/deploy.sh | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 scripts/create_archive.sh create mode 100644 scripts/deploy.sh diff --git a/scripts/create_archive.sh b/scripts/create_archive.sh new file mode 100644 index 0000000..f64ac3c --- /dev/null +++ b/scripts/create_archive.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# Create an archive named with "$2", containing all files under "$1" +# and no subdir containing all others + +if (( $# != 2 )) ; then + echo "parameters not meet" + exit 1 +fi + +find "$1" -mindepth 1 -not -type d -printf "%P\n" | tar -C "$1" -cf "$2" --gzip -T - diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100644 index 0000000..e2be567 --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# The http server not support data-form or x-www-url-encoded-form, +# so the archive file must just in the post body, so use --data-binary +# as curl argument. +# +# $1 is the archive path to be sent to http server +# $2 is the http server (including schema, host, port and path) +# +# Example: +# curl --data-binary @public.tar.gz http://localhost:8080/ + +if (( $# != 2 )) ; then + echo "parameter not meet" + exit 1 +fi + +curl --data-binary @"$1" "$2"