#!/bin/bash tab() { if [ $# -lt 2 ]; then printf "\t"; fi for ((i_tab=${#2};i_tab<$1;i_tab++)); do printf " "; done } if [ "$1" != "-o" ]; then exec 1>/home/lucas/.bash_motd_buff fi if [ "$(/sbin/ip -br link | grep bond0)" != "" ];then if1="bond0" ip1="$(/sbin/ip -br link bond0 | grep -o "10\.0\.0\.103")" if2="$(cat /proc/net/bonding/bond0 | grep 'Currently Active Slave:' | grep -o 'wlan0\|eth0')" if [ "if2" == "" ]; then printf "*******************************WTF? No bond IF2?*******************************\n" fi ip2="$(ip addr show $if2 | grep -o '10\.0\.0\.27\|10\.0\.0\.103')" printf "%s:\t%s\t" "$if1" "$ip1" else ifx=( $(ip -br link | cut -f1 -d' ' | grep -v lo) ) for i in ${!ifx[@]}; do ipx[$i]="$(ip addr show ${ifx[$i]} | grep -m1 -o -P '(?<=inet ).*(?=/24 brd)')" if [ "${ipx[$i]}" == "" ]; then ipx[$i]="----------" fi done printf "%s:\t%s\t" "${ifx[0]}" "${ipx[0]}" fi ip="$(wget -T 5 -qO- ifconfig.co)" location="$(wget -T 5 -qO- ifconfig.co/country)" city=$(wget -T 5 -qO- ifconfig.co/city) if [ "${ip}" == "" ]; then ip="IP empty" elif [ "${location}" == "" ]; then location="No LOC" elif [ "${city}" == "" ]; then city="No City" fi printf "\tUser: $(whoami)"; tab 14 "$(whoami)"; printf "$ip"; tab 17 "$ip"; printf "$location\n" if [ "$HOSTNAME" == "quiethost" ]; then for ((i=1; i<${#ifx[@]}; i++)); do printf "%s:\t%s" "${ifx[$i]}" "${ipx[$i]}" if [ $i -eq 1 ]; then printf "\t\t\t\t\t\t${city}\n"; else printf "\n"; fi done fi if [ "$HOSTNAME" == "raspberry" ]; then printf "%s:\t%s\t\t" "${ifx[1]}" "${ipx[1]}" fi if [ "$HOSTNAME" == "quiethost_dep" ]; then printf "WallpaperChanger: " if [ "$(ps -elf | grep -v grep | grep wallpaperChanger.sh)" = "" ]; then printf "[ OFF ]\t\t" else time="$(ps -elf | grep -v grep | grep wallpaperChanger.sh | sed 's/ \+/ /g' | cut -f18 -d' ')" printf "[ ON ]\t%s min\t" "$time" fi printf "\n" KURS1="$(wget -qO- https://www.fondsprofessionell.at/fonds/details/fondsName/Amundi-Komfort-Invest-traditionell-T/ISIN/AT0000801071/fondsID/FU_80107/)" KURS2="$(wget -qO- https://www.fondsprofessionell.at/fonds/details/ISIN/AT0000A2L443/fondsID/FU_100076607/)" KURS3="$(wget -qO- https://www.fondsprofessionell.at/fonds/details/fondsName/Amundi-CPR-Climate-Action-T/ISIN/AT0000A28YU4/fondsID/FU_100070247/)" DATE1="$(printf "%s\n" "${KURS1}" | sed 's/<\/b>/<\/b>\n/g' | grep -o -P '(?<=NAV am ).*(?= )')" DATE2="$(printf "%s\n" "${KURS2}" | sed 's/<\/b>/<\/b>\n/g' | grep -o -P '(?<=NAV am ).*(?= )')" DATE3="$(printf "%s\n" "${KURS3}" | sed 's/<\/b>/<\/b>\n/g' | grep -o -P '(?<=NAV am ).*(?= )')" KURS_EUR1=$(printf "%s\n" "${KURS1}" | sed 's/<\//\n<\//g' | grep -A2 "NAV am" | grep -o -P '(?<= ).*(?=EUR)' | sed 's/ //g' | sed 's/,/./g') KURS_PER1=$(printf "%s\n" "${KURS1}" | sed 's/<\//\n<\//g' | grep -A3 "Änderung (%)" | grep -o -P '(?<= ).*(?=%\))') printf "Traditionell:\t%s EUR" "${KURS_EUR1}"; tab 8 "${KURS_EUR1}"; printf "%s%%)\t${DATE1}\n" "${KURS_PER1}" KURS_EUR2=$(printf "%s\n" "${KURS2}" | sed 's/<\//\n<\//g' | grep -A2 "NAV am" | grep -o -P '(?<= ).*(?=EUR)' | sed 's/ //g' | sed 's/,/./g') KURS_PER2=$(printf "%s\n" "${KURS2}" | sed 's/<\//\n<\//g' | grep -A3 "Änderung (%)" | grep -o -P '(?<= ).*(?=%\))') printf "Dynamisch:\t%s EUR" "${KURS_EUR2}"; tab 8 "${KURS_EUR2}"; printf "%s%%)\t${DATE2}\n" "${KURS_PER2}" KURS_EUR3=$(printf "%s\n" "${KURS3}" | sed 's/<\//\n<\//g' | grep -A2 "NAV am" | grep -o -P '(?<= ).*(?=EUR)' | sed 's/ //g' | sed 's/,/./g') KURS_PER3=$(printf "%s\n" "${KURS3}" | sed 's/<\//\n<\//g' | grep -A3 "Änderung (%)" | grep -o -P '(?<= ).*(?=%\))') printf "Climate:\t%s EUR" "${KURS_EUR3}"; tab 8 "${KURS_EUR3}"; printf "%s%%)\t${DATE3}\n" "${KURS_PER3}" #bash "/home/lucas/Documents/Dokumente/Projekte/Server/scripts/serverhost/update_BA_Data.sh" "${KURS_EUR1}" "${KURS_EUR2}" "${KURS_EUR3}" fi if [ "$HOSTNAME" == "raspberry_dep" ]; then printf "MoistSens: " if [ "$(pgrep recieveMS)" = "" ]; then printf "[ OFF ]\t" else printf "[ ON ]\t" fi printf "BTServer: " if [ "$(pgrep BTserver)" = "" ]; then printf "[ OFF ]\n" else printf "[ ON ]\n" fi fi if [[ "$HOSTNAME" = "serverhost" ]] || [[ "$HOSTNAME" = "workhost" ]]; then printf "OpenVPN: " if [ "$(pgrep openvpn)" = "" ]; then printf "[ OFF ]\t" else printf "[ ON ] PID: %s" "$(pgrep openvpn | tr '\n' ' ')" fi if [[ "$HOSTNAME" = "serverhost" ]]; then printf "\tUser: deluge-user"; tab 14 "deluge-user"; ip=$(sudo /home/lucas/scripts/serverhost/deluge_user_cmd.sh wget -T 2 -qO- ifconfig.co) if [ "$ip" != "" ]; then location=$(sudo /home/lucas/scripts/serverhost/deluge_user_cmd.sh wget -T 2 -qO- ifconfig.co/country) # city=$(sudo /home/lucas/scripts/serverhost/deluge_user_cmd.sh wget -T 2 -qO- ifconfig.co/city) printf "$ip"; tab 17 "$ip"; printf "$location\n" else printf "No Connection\n" fi else printf "\n" fi fi printf "\n" SPACE_TAB=18 mem="$(free -h | awk 'NR==2 { printf "Total: %sB,\tUsed: %sB,\tFree: %sB",$2,$3,$7; }')" printf "Memory:"; tab ${SPACE_TAB} "Memory:"; printf "$mem\n"; IFS=$'\n'; set -f data_dev=($(df -h | grep "/dev/sd[a-f]" | sed 's/ \+/ /g' | cut -f1 -d' ')) unset IFS; set +f osspace="" for ((i=0;i<${#data_dev[@]};i++)); do device="$(df -h "${data_dev[$i]}" | sed 's/ \+/ /g' | tail -1 | cut -f6 -d' ')" if [ "$device" != "/" ]; then device="/$(echo $device | rev | cut -f1 -d'/' |rev):" else device="/root:" fi if [[ "$(echo $device | grep "efi")" != "" ]] || [[ "$(echo $device | grep "win10")" != "" ]]; then continue; fi osspace="$(df -h "${data_dev[$i]}" | awk 'NR==2 { printf "Total: %sB,\tUsed: %sB,\tFree: %sB\t%s used\n",$2,$3,$4,$5; }')" printf "%s" "${device}" tab ${SPACE_TAB} "${device}"; printf "%s\n" "$osspace" done tabs -8 if [[ "$HOSTNAME" = "raspberry" ]]; then temp="$(/opt/vc/bin/vcgencmd measure_temp | cut -c "6-9") ºC" temp="Temperature...: $temp" echo $temp fi if [[ "$HOSTNAME" = "workhost" ]] || [[ "$HOSTNAME" = "raspberry" ]] && [[ -f /etc/motd ]]; then cat /etc/motd fi if [[ "$HOSTNAME" = "serverhost" ]] || [[ "$HOSTNAME" = "quiethost" ]]; then sudo /etc/update-motd.d/90-updates-available if [ -f /etc/motd ]; then cat /etc/motd; fi sudo /etc/update-motd.d/91-release-upgrade sudo /etc/update-motd.d/98-fsck-at-reboot sudo /etc/update-motd.d/98-reboot-required fi if [[ "$1" != "-o" ]] && [[ -f /home/lucas/.bash_motd_buff ]]; then mv /home/lucas/.bash_motd_buff /home/lucas/.bash_motd fi