mirror of
https://github.com/PR0M3TH3AN/VoxVera.git
synced 2025-09-08 15:08:42 +00:00
Merge pull request #73 from PR0M3TH3AN/codex/add-trap-commands-to-remove-temp-files
Add cleanup traps to shell scripts
This commit is contained in:
@@ -18,12 +18,16 @@ tear=$(jq -r '.tear_off_link' "$CONFIG")
|
|||||||
tmp_content=$(mktemp)
|
tmp_content=$(mktemp)
|
||||||
tmp_tear=$(mktemp)
|
tmp_tear=$(mktemp)
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
rm -f "$tmp_content" "$tmp_tear"
|
||||||
|
}
|
||||||
|
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
qrencode -o "$tmp_content" -s 10 -m 0 "$url"
|
qrencode -o "$tmp_content" -s 10 -m 0 "$url"
|
||||||
qrencode -o "$tmp_tear" -s 10 -m 0 "$tear"
|
qrencode -o "$tmp_tear" -s 10 -m 0 "$tear"
|
||||||
|
|
||||||
convert "$tmp_content" -resize 128x128 "qrcode-content.png"
|
convert "$tmp_content" -resize 128x128 "qrcode-content.png"
|
||||||
convert "$tmp_tear" -resize 128x128 "qrcode-tear-offs.png"
|
convert "$tmp_tear" -resize 128x128 "qrcode-tear-offs.png"
|
||||||
|
|
||||||
rm -f "$tmp_content" "$tmp_tear"
|
|
||||||
|
|
||||||
echo "QR codes generated"
|
echo "QR codes generated"
|
||||||
|
@@ -31,6 +31,12 @@ temp_js_file=$(mktemp_with_suffix .js) # Temporary .js file for extracting Java
|
|||||||
temp_js_obfuscated_file=$(mktemp_with_suffix .js) # Temporary file for obfuscated JavaScript
|
temp_js_obfuscated_file=$(mktemp_with_suffix .js) # Temporary file for obfuscated JavaScript
|
||||||
temp_html_file=$(mktemp) # Temporary file for processing HTML without JS
|
temp_html_file=$(mktemp) # Temporary file for processing HTML without JS
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
rm -f "$temp_js_file" "$temp_js_obfuscated_file" "$temp_html_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
# Check if the input file exists
|
# Check if the input file exists
|
||||||
if [ ! -f "$input_file" ]; then
|
if [ ! -f "$input_file" ]; then
|
||||||
echo "Input file $input_file does not exist."
|
echo "Input file $input_file does not exist."
|
||||||
@@ -61,7 +67,6 @@ html-minifier-terser \
|
|||||||
--output "$output_file" \
|
--output "$output_file" \
|
||||||
"$temp_html_file"
|
"$temp_html_file"
|
||||||
|
|
||||||
# Clean up temporary files
|
# Clean up temporary files handled by trap
|
||||||
rm "$temp_js_file" "$temp_js_obfuscated_file" "$temp_html_file"
|
|
||||||
|
|
||||||
echo "Obfuscation and minification complete. Output saved as $output_file."
|
echo "Obfuscation and minification complete. Output saved as $output_file."
|
||||||
|
@@ -31,6 +31,12 @@ temp_js_file=$(mktemp_with_suffix .js) # Temporary .js file for extracting Java
|
|||||||
temp_js_obfuscated_file=$(mktemp_with_suffix .js) # Temporary file for obfuscated JavaScript
|
temp_js_obfuscated_file=$(mktemp_with_suffix .js) # Temporary file for obfuscated JavaScript
|
||||||
temp_html_file=$(mktemp) # Temporary file for processing HTML without JS
|
temp_html_file=$(mktemp) # Temporary file for processing HTML without JS
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
rm -f "$temp_js_file" "$temp_js_obfuscated_file" "$temp_html_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
# Check if the input file exists
|
# Check if the input file exists
|
||||||
if [ ! -f "$input_file" ]; then
|
if [ ! -f "$input_file" ]; then
|
||||||
echo "Input file $input_file does not exist."
|
echo "Input file $input_file does not exist."
|
||||||
@@ -61,7 +67,6 @@ html-minifier-terser \
|
|||||||
--output "$output_file" \
|
--output "$output_file" \
|
||||||
"$temp_html_file"
|
"$temp_html_file"
|
||||||
|
|
||||||
# Clean up temporary files
|
# Clean up temporary files handled by trap
|
||||||
rm "$temp_js_file" "$temp_js_obfuscated_file" "$temp_html_file"
|
|
||||||
|
|
||||||
echo "Obfuscation and minification complete. Output saved as $output_file."
|
echo "Obfuscation and minification complete. Output saved as $output_file."
|
||||||
|
Reference in New Issue
Block a user