#!/bin/bash SITES=("https://www.fondsprofessionell.at/fonds/details/fondsName/Amundi-Komfort-Invest-traditionell-T/ISIN/AT0000801071/fondsID/FU_80107/" "https://www.fondsprofessionell.at/fonds/details/ISIN/AT0000A2L443/fondsID/FU_100076607/" "https://www.fondsprofessionell.at/fonds/details/fondsName/Amundi-CPR-Climate-Action-T/ISIN/AT0000A28YU4/fondsID/FU_100070247/" "https://www.finanzen.net/index/dow_jones" "https://www.finanzen.net/index/dax" "https://www.finanzen.net/index/atx") if [ -f /home/lucas/Documents/Dokumente/Projekte/Server/www/BA_Data.html ]; then BA_JS="/home/lucas/Documents/Dokumente/Projekte/Server/www/data.js" BA_DATA="/home/lucas/Documents/Dokumente/Projekte/Server/www/BA_Data.html" else exit fi DEBUG=false if [ "$1" == "-d" ];then DEBUG=true fi DATE="$(date +"%d.%m.%Y")" if [ $# -eq 3 ]; then KURS_INET1="$1" KURS_INET2="$2" KURS_INET3="$3" else KURS_INET1="" KURS_INET2="" KURS_INET3="" DOWJ="" DAX="" GET=true if ${GET}; then KURS_INET1=$(wget -qO- ${SITES[0]} | sed 's/<\//\n<\//g' | grep -A2 "NAV am" | grep -o -P '(?<= ).*(?=EUR)' | sed 's/ //g' | sed 's/,/./g') KURS_INET2=$(wget -qO- ${SITES[1]} | sed 's/<\//\n<\//g' | grep -A2 "NAV am" | grep -o -P '(?<= ).*(?=EUR)' | sed 's/ //g' | sed 's/,/./g') #KURS_INET2=$(wget -qO- ${SITES[1]} | grep "Rücknahmepreis" | grep -o -P '(?<=right">).*(?=)' | sed 's/,/./g') KURS_INET3=$(wget -qO- ${SITES[2]} | sed 's/<\//\n<\//g' | grep -A2 "NAV am" | grep -o -P '(?<= ).*(?=EUR)' | sed 's/ //g' | sed 's/,/./g') DOWJ=$(wget -qO- ${SITES[3]} | sed 's//\n/g' | grep -A3 'Kurs' | grep -o -E "[0-9]+\.[0-9]+,[0-9]{2}" | tr -d '.' | tr ',' '.' | tail -1) DAX=$(wget -qO- ${SITES[4]} | sed 's//\n/g' | grep -A3 'Kurs' | grep -o -E "[0-9]+\.[0-9]+,[0-9]{2}" | tr -d '.' | tr ',' '.' | tail -1) ATX=$(wget -qO- ${SITES[5]} | sed 's//\n/g' | grep -A3 'Kurs' | grep -o -E "[0-9]+\.[0-9]+,[0-9]{2}" | tr -d '.' | tr ',' '.' | tail -1) fi fi #if [ "$(cat ${BA_DATA} | grep -F "${DATE}")" == "" ]; then # if [[ "${KURS_INET1}" != "" ]] && [[ "${KURS_INET2}" != "" ]] && [[ "${KURS_INET3}" != "" ]] && [[ "${DATE}" != "" ]]; then # sed -i 's/<\/table>/'"${KURS_INET1}"'<\/td>'"${KURS_INET2}"'<\/td>'"${KURS_INET3}"'<\/td>'"${DATE}"'<\/td><\/tr><\/table>/g' ${BA_DATA} # fi IFS=$'\n'; set -f KURSE_INET=("${KURS_INET1}" "${KURS_INET2}" "${KURS_INET3}" "${DOWJ}" "${DAX}" "${ATX}") KURSE_LOCAL=($(cat ${BA_JS} | grep '.data' | rev | cut -d',' -f 1 | rev | sed 's/\];//g')) DATE_LOCAL="$(cat ${BA_JS} | grep 'date' | rev | cut -d',' -f 1 | rev | sed 's/\];//g' | tr -d "\'")" if ${DEBUG}; then echo "${#KURSE_INET[@]} -eq ${#KURSE_LOCAL[@]}" fi ALL_THERE=true for ((i=0;i<${#KURSE_INET[@]};i++)); do if [[ "${KURSE_INET[$i]}" == "" ]]; then ALL_THERE=false if ${DEBUG}; then echo "$i: ${KURSE_INET[$i]}" fi fi done if [[ "${ALL_THERE}" == "true" ]]; then CHANGE=false unset IFS; set +f if ${DEBUG}; then printf "Inet\t\tLocal\n" fi for ((i=0;i<${#KURSE_INET[@]};i++)); do if ${DEBUG}; then printf "%s\t\t%s\n" "${KURSE_INET[$i]}" "${KURSE_LOCAL[$i]}" fi if [ "${KURSE_INET[$i]}" != "${KURSE_LOCAL[$i]}" ]; then CHANGE=true printf "Diff: %s\t\t%s\n" "${KURSE_INET[$i]}" "${KURSE_LOCAL[$i]}" fi done if [[ "${CHANGE}" == "true" ]]; then if [[ "${DATE}" == "${DATE_LOCAL}" ]]; then if ${DEBUG}; then echo "Change on same Date"; fi sed -i 's/'"${KURS_LOCAL[0]}"'<\/td>'"${KURS_LOCAL[1]}"'<\/td>'"${KURS_LOCAL[2]}"'<\/td>'"${DATE}"'<\/td><\/tr>/'"${KURSE_INET[0]}"'<\/td>'"${KURSE_INET[1]}"'<\/td>'"${KURSE_INET[2]}"'<\/td>'"${DATE}"'<\/td><\/tr>/g' ${BA_DATA} sed -i 's/\(fond_trad\.data.*\),[0-9]\+\.[0-9]\{2\}\];/\1,'"${KURSE_INET[0]}"'];/g' ${BA_JS} sed -i 's/\(fond_dyn\.data.*\),[0-9]\+\.[0-9]\{2\}\];/\1,'"${KURSE_INET[1]}"'];/g' ${BA_JS} sed -i 's/\(fond_climate\.data.*\),[0-9]\+\.[0-9]\{2\}\];/\1,'"${KURSE_INET[2]}"'];/g' ${BA_JS} sed -i 's/\(fond_doj\.data.*\),[0-9]\+\.[0-9]\{2\}\];/\1,'"${KURSE_INET[3]}"'];/g' ${BA_JS} sed -i 's/\(fond_dax\.data.*\),[0-9]\+\.[0-9]\{2\}\];/\1,'"${KURSE_INET[4]}"'];/g' ${BA_JS} sed -i 's/\(fond_atx\.data.*\),[0-9]\+\.[0-9]\{2\}\];/\1,'"${KURSE_INET[5]}"'];/g' ${BA_JS} touch ${BA_DATA} touch ${BA_JS} else if ${DEBUG}; then echo "Change on New Date"; fi sed -i 's/<\/table>/'"${KURSE_INET[0]}"'<\/td>'"${KURSE_INET[1]}"'<\/td>'"${KURSE_INET[2]}"'<\/td>'"${DATE}"'<\/td><\/tr><\/table>/g' ${BA_DATA} ## data.js ## sed -i 's/\(fond_trad\.data.*\)\];/\1,'"${KURSE_INET[0]}"'];/g' ${BA_JS} echo $? sed -i 's/\(fond_dyn\.data.*\)\];/\1,'"${KURSE_INET[1]}"'];/g' ${BA_JS} echo $? sed -i 's/\(fond_climate\.data.*\)\];/\1,'"${KURSE_INET[2]}"'];/g' ${BA_JS} echo $? sed -i 's/\(date.*\)\];/\1,'"'${DATE}'"'];/g' ${BA_JS} echo $? sed -i 's/\(fond_doj\.data.*\)\];/\1,'"${KURSE_INET[3]}"'];/g' ${BA_JS} echo $? sed -i 's/\(fond_dax\.data.*\)\];/\1,'"${KURSE_INET[4]}"'];/g' ${BA_JS} echo $? sed -i 's/\(fond_atx\.data.*\)\];/\1,'"${KURSE_INET[5]}"'];/g' ${BA_JS} echo $? touch ${BA_DATA} touch ${BA_JS} fi else if ${DEBUG}; then echo No Change; fi fi fi if [ "$(which syncNC)" != "" ]; then syncNC > /dev/null 2>&1 fi