Improve deplay.sh script to check against exact matches instead of regex-matching the searched string against the entire collapsed array to avoid incorrect partial matches
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
25a1d06834
commit
6b531e7c27
17
deploy.sh
17
deploy.sh
|
@ -42,11 +42,18 @@ for dir in "${path[@]}"; do
|
||||||
ls -1"
|
ls -1"
|
||||||
)"
|
)"
|
||||||
|
|
||||||
# Only try to create the subdir if does not already exist
|
# Loop over the dir content and check if this exact dir already exists
|
||||||
if [[ "${dir_content[*]}" =~ "${dir}" ]]; then
|
path_exists=0
|
||||||
echo "Dir: ${old_path}/${dir} already exists"
|
for content in "${dir_content[@]}"; do
|
||||||
else
|
if [[ "${content}" == "${dir}" ]]; then
|
||||||
echo "Creating dir: ${old_path}/${dir}"
|
echo "Dir: ${old_path}/${dir} already exists"
|
||||||
|
path_exists=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# If the dir does not exist, create it
|
||||||
|
if [[ "${path_exists}" -eq 0 ]]; then
|
||||||
|
echo "Dir: ${old_path}/${dir} does not exist. Creating it."
|
||||||
sftp -b - "${USER}"@"${HOST}" <<< "cd ${old_path}
|
sftp -b - "${USER}"@"${HOST}" <<< "cd ${old_path}
|
||||||
-mkdir ${dir}"
|
-mkdir ${dir}"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue