Add cleanup.
This commit is contained in:
parent
13b1d7f0b1
commit
01401759b7
4 changed files with 30 additions and 10 deletions
3
check
3
check
|
@ -1,7 +1,10 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
[ -e /opt/resource/common ] && cd /opt/resource/
|
||||
. ./common
|
||||
|
||||
compute_version "$(fetch_file_infos get_files)"
|
||||
cleanup
|
||||
|
|
6
common
6
common
|
@ -45,6 +45,10 @@ write_config() {
|
|||
return 0
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
rm -r /tmp/*
|
||||
}
|
||||
|
||||
INPUT_PATH="$(save_input)"
|
||||
read_config "$INPUT_PATH"
|
||||
CONFIG_PATH="$(write_config)"
|
||||
|
@ -65,7 +69,7 @@ get_command() {
|
|||
}
|
||||
|
||||
get_directory() {
|
||||
jq -r '.params.directory // "/"' < "$INPUT_PATH"
|
||||
jq -r '.params.directory // ""' < "$INPUT_PATH"
|
||||
}
|
||||
|
||||
get_workdir() {
|
||||
|
|
3
in
3
in
|
@ -3,6 +3,7 @@
|
|||
set -e
|
||||
set -o pipefail
|
||||
|
||||
[ -e /opt/resource/common ] && cd /opt/resource/
|
||||
. ./common
|
||||
|
||||
cd "$1"
|
||||
|
@ -37,3 +38,5 @@ jq -r tostring << EOF
|
|||
"version": $(get_version)
|
||||
}
|
||||
EOF
|
||||
|
||||
cleanup
|
||||
|
|
22
out
22
out
|
@ -3,19 +3,24 @@
|
|||
set -e
|
||||
set -o pipefail
|
||||
|
||||
[ -e /opt/resource/common ] && cd /opt/resource/
|
||||
. ./common
|
||||
|
||||
cd "$1"
|
||||
files="$(find . | sed -e '/^\.$/d' -e 's|^./||')"
|
||||
tarfile="$(mktemp -tp /tmp)"
|
||||
remote_tarfile="$(mktemp -u)"
|
||||
tar -cf "$tarfile" ./*
|
||||
scp -F "$CONFIG_PATH" "$tarfile" "$HOSTNAME:$remote_tarfile"
|
||||
if [ -n "$(get_directory)" ]; then
|
||||
files="$(find . | sed -e '/^\.$/d' -e 's|^./||')"
|
||||
tarfile="$(mktemp -tp /tmp)"
|
||||
remote_tarfile="$(mktemp -u)"
|
||||
tar -cf "$tarfile" ./*
|
||||
scp -F "$CONFIG_PATH" "$tarfile" "$HOSTNAME:$remote_tarfile"
|
||||
fi
|
||||
ssh -F "$CONFIG_PATH" "$HOSTNAME" sh -s << EOF
|
||||
set -e
|
||||
if [ -n "$(get_directory)" ]; then
|
||||
cd "$(get_directory)"
|
||||
tar xf "$remote_tarfile"
|
||||
rm "$remote_tarfile"
|
||||
fi
|
||||
if [ "$(get_command)" = "null" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
@ -32,6 +37,11 @@ version="$(compute_version "$(fetch_file_infos get_files_for_new_version)")"
|
|||
|
||||
jq -r tostring << EOF
|
||||
{
|
||||
"version": $version
|
||||
"version": {
|
||||
"files": $version,
|
||||
"command": true
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
cleanup
|
||||
|
|
Loading…
Reference in a new issue