#!/bin/bash ####################################### # generate_text.sh - Create text files (German and Spanish) # # Author: Michael Haider # Created on: 26.01.2024 # Description: This script generates various text files with information such as date, time, news, and weather in German and Spanish. ####################################### text_dir="/root/iobroker_scripts/general/.text" html_file="$text_dir/handout.html" all=("date" "time" "weather") # Add more elements as needed # remove files in text_dir rm -rf $text_dir/* # Function to get the IP address of Lisa's iPhone check_ip() { mac_address="e4:cd:d1" # Replace this with the MAC address attempts=10 interval=5 for ((i = 1; i <= $attempts; i++)); do A72_ip=$(arp-scan -r 3 -v --localnet | grep "$mac_address" | awk '{print $1}') if [ -n "$A72_ip" ]; then echo "Found IP: $A72_ip" return 0 # Success: IP address found fi if [ $i -lt $attempts ]; then echo "Wait $interval seconds before the next attempt." sleep $interval fi done # All attempts unsuccessful echo "The target could not be reached after $attempts attempts." return 1 # Error: IP address not found } # Execute the check_ip function. check_ip # Function to generate the text files generate_text() { # German date_de=$(date '+Heute ist %A, der %d. %B %Y.') echo "$date_de" > "$text_dir/date_de.txt" time_de=$(date '+Es ist %H:%M Uhr.') echo "$time_de" > "$text_dir/time_de.txt" weather_de=$(trans -b :en :de "$(/root/iobroker_scripts/general/weather.sh)") echo "$weather_de" > "$text_dir/weather_de.txt" # Spanish date_es=$(trans -b :de :es "$date_de") echo "$date_es" > "$text_dir/date_es.txt" time_es=$(trans -b :de :es "$time_de") echo "$time_es" > "$text_dir/time_es.txt" weather_es=$(trans -b :en :es "$(/root/iobroker_scripts/general/weather.sh)") echo "$weather_es" > "$text_dir/weather_es.txt" } # Call the generate_text function generate_text # Create HTML file echo "" >> "$html_file" echo "" >> "$html_file" echo "
" >> "$html_file" echo "| Deutsch | EspaƱol |
|---|---|
| $german_output | $spanish_output |