Update zip file/clean up skip with skip information

This commit is contained in:
Clemens Schwaighofer
2024-09-04 13:43:24 +09:00
parent 0bd40cdd73
commit 5659cc010f

View File

@@ -422,15 +422,22 @@ if [ ${INFO} -eq 1 ]; then
exit; exit;
fi; fi;
# check if there are any files in the SSH_KEYGEN_FOLDER, else skip zip file creation and file move # check if there are any files in the SSH_KEYGEN_FOLDER, else skip zip file creation and file move
has_pem_files=0;
if (shopt -s nullglob dotglob; f=("${SSH_KEYGEN_FOLDER}"*".pem"*); ((${#f[@]}))); then if (shopt -s nullglob dotglob; f=("${SSH_KEYGEN_FOLDER}"*".pem"*); ((${#f[@]}))); then
has_pem_files=1;
fi;
# zip everything and remove data in ssh key folder, delete output file with passwords # zip everything and remove data in ssh key folder, delete output file with passwords
if [ ${TEST} -eq 0 ]; then if [ ${TEST} -eq 0 ]; then
if [ "${has_pem_files}" -eq 1 ]; then
zip -r \ zip -r \
"${ROOT_FOLDER}${output_zip_folder}${output_zip}" \ "${ROOT_FOLDER}${output_zip_folder}${output_zip}" \
"${input_file}" \ "${input_file}" \
"${output_file}" \ "${output_file}" \
"${SSH_KEYGEN_FOLDER}" \ "${SSH_KEYGEN_FOLDER}" \
-x\*.gitignore; -x\*.gitignore;
else
echo "- Skip ZIP file creation, no pem files";
fi;
else else
echo "zip -r \\" echo "zip -r \\"
echo "${ROOT_FOLDER}${output_zip_folder}${output_zip} \\" echo "${ROOT_FOLDER}${output_zip_folder}${output_zip} \\"
@@ -442,16 +449,19 @@ if (shopt -s nullglob dotglob; f=("${SSH_KEYGEN_FOLDER}"*".pem"*); ((${#f[@]})))
echo "Download: ${ROOT_FOLDER}${output_zip_folder}${output_zip}"; echo "Download: ${ROOT_FOLDER}${output_zip_folder}${output_zip}";
# cleam up user log file and ssh keys # cleam up user log file and ssh keys
if [ ${TEST} -eq 0 ]; then if [ ${TEST} -eq 0 ]; then
if [ "${has_pem_files}" -eq 1 ]; then
# move pub to created folders # move pub to created folders
mv "${ROOT_FOLDER}${SSH_KEYGEN_FOLDER}"*.pub "${ROOT_FOLDER}${SSH_KEYGEN_FOLDER_CREATED_PUB}"; mv "${ROOT_FOLDER}${SSH_KEYGEN_FOLDER}"*.pub "${ROOT_FOLDER}${SSH_KEYGEN_FOLDER_CREATED_PUB}";
# delete the rest # delete the rest
rm "${ROOT_FOLDER}${output_file}"; rm "${ROOT_FOLDER}${output_file}";
rm "${ROOT_FOLDER}${SSH_KEYGEN_FOLDER}"*; rm "${ROOT_FOLDER}${SSH_KEYGEN_FOLDER}"*;
else
echo "- Skip pub file move and cleanup, no pem files";
fi;
else else
echo "$> mv ${ROOT_FOLDER}${SSH_KEYGEN_FOLDER}*.pub ${ROOT_FOLDER}${SSH_KEYGEN_FOLDER_CREATED_PUB};"; echo "$> mv ${ROOT_FOLDER}${SSH_KEYGEN_FOLDER}*.pub ${ROOT_FOLDER}${SSH_KEYGEN_FOLDER_CREATED_PUB};";
echo "$> rm ${ROOT_FOLDER}${output_file}"; echo "$> rm ${ROOT_FOLDER}${output_file}";
echo "$> rm ${ROOT_FOLDER}${SSH_KEYGEN_FOLDER}*"; echo "$> rm ${ROOT_FOLDER}${SSH_KEYGEN_FOLDER}*";
fi; fi;
fi;
# __END__ # __END__