From 41f3b3a4d2f983f6d1128bafcce2aa54825c6ca8 Mon Sep 17 00:00:00 2001 From: Ratatoskr Date: Tue, 6 Feb 2024 17:39:37 +0100 Subject: [PATCH] Refactor HTML generation, improve Markdown content creation, and update notification mechanism in generate_text.sh: - Refactored HTML file creation with Markdown content construction for clarity and conciseness. - Removed the HTML file generation block and replaced it with a Markdown content string. - Updated the notification mechanism using the constructed Markdown content and a curl command. - Display the constructed Markdown content instead of the HTML file. - Updated the file transfer destination to the A72 device's /sdcard/ directory for generate_text.sh. --- generate_text.sh | 52 +++++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 34 deletions(-) diff --git a/generate_text.sh b/generate_text.sh index 3e95149..f02f564 100755 --- a/generate_text.sh +++ b/generate_text.sh @@ -62,49 +62,33 @@ generate_text() { # Call the generate_text function generate_text -# Create HTML file -echo "" > "$html_file" -echo "" >> "$html_file" -echo "" >> "$html_file" -echo "Handout" >> "$html_file" -echo "" >> "$html_file" -echo "" >> "$html_file" -echo "" >> "$html_file" -echo "

Handout:

" >> "$html_file" -echo "" >> "$html_file" -echo "" >> "$html_file" +# Create Markdown content +markdown_content="**Handout:** +\n +| Deutsch | Español | +| ------- | -------- |" for component in "${all[@]}"; do - echo "processing: $component" german_output=$(cat "$text_dir/${component}_de.txt") spanish_output=$(cat "$text_dir/${component}_es.txt") - echo "" >> "$html_file" + markdown_content+="\n| $german_output | $spanish_output |" done -echo "
DeutschEspañol
$german_output$spanish_output
" >> "$html_file" -echo "" >> "$html_file" -echo "" >> "$html_file" +# Send Notification to A72 with Markdown content +curl_command="curl -u 'Michaelis:u5ptufUFuDL6q4yEcSN3iqas5gtXNkN77Lx3cy3oX8UoSgFWdifYy9FVopv2Zwtu' \ + -H 'Priority:High' \ + -d \"$markdown_content\" \ + -H 'Markdown: yes' \ + https://ntfy.michaelis.digital/ioBroker" + +echo "curl_command: $curl_command" +eval "$curl_command" # Execute the constructed curl command # Transfer files to A72 -scp -r -i /root/.ssh/A72 "$text_dir" root@$A72_ip:/data/scripts/ +scp -r -i /root/.ssh/A72 "$text_dir" root@$A72_ip:/sdcard/ -# Display Markdown file content -cat $markdown_file +# Display Markdown content +echo -e "$markdown_content" # Start generate_mp3.sh on A72 nohup ssh -i /root/.ssh/A72 -f root@$A72_ip '/data/scripts/generate_mp3.sh' > /root/generate_mp3.log & -