Commit | Line | Data |
---|---|---|
4af9eedb SK |
1 | #! /bin/sh |
2 | ||
3 | set -e | |
4 | ||
5 | repeat() { | |
6 | x="$1" | |
7 | n="$2" | |
8 | awk -v x="$x" -v n="$n" 'BEGIN {for (i=1; i<=n; i++) {printf x}}' | |
9 | } | |
10 | ||
11 | bar=$(repeat '-' '80') | |
12 | ts_fmt='+%A, %Y %B %d, %H:%M:%S' | |
13 | ts_lang='el_GR.UTF-8' | |
14 | timestamp_local=$(LANG="$ts_lang" date "$ts_fmt") | |
15 | timestamp_west=$( LANG="$ts_lang" TZ='US/Pacific' date "$ts_fmt") | |
16 | timestamp_pl=$( LANG="$ts_lang" TZ='Poland' date "$ts_fmt") | |
17 | timestamp_nz=$( LANG="$ts_lang" TZ='NZ' date "$ts_fmt") | |
18 | ||
19 | ip_addresses=$( | |
20 | ip addr \ | |
21 | | awk ' | |
22 | /^[0-9]+:/ { | |
23 | interface = $2 | |
24 | sub(":$", "", interface) | |
25 | interfaces[++interface_count] = interface | |
26 | } | |
27 | ||
28 | /^ +inet +/ { | |
29 | addr = $2 | |
30 | sub("/[0-9]+$", "", addr) | |
31 | addrs[interface] = addr | |
32 | } | |
33 | ||
34 | END { | |
35 | for (i=1; i<=interface_count; i++) { | |
36 | interface = interfaces[i] | |
37 | print interface, addrs[interface] | |
38 | } | |
39 | }' \ | |
40 | | column -t | |
41 | ) | |
42 | ||
43 | weather=$( | |
44 | curl "http://wttr.in/${ZIP_CODE}?1" 2> /dev/null \ | |
45 | || \ | |
46 | echo "Weather update failed" \ | |
47 | ) | |
48 | ||
49 | clear | |
50 | #LANG="$ts_lang" ncal -M $(date +%Y) | |
51 | LANG="$ts_lang" ncal -M | |
52 | echo "$bar" | |
53 | ( | |
54 | echo 'LOCAL' ',' "$timestamp_local" | |
55 | echo 'Pacific' ',' "$timestamp_west" | |
56 | echo 'Poland' ',' "$timestamp_pl" | |
57 | echo 'New Zealand' ',' "$timestamp_nz" | |
58 | ) \ | |
59 | | column -ts, | |
60 | echo "$bar" | |
61 | echo "$ip_addresses" | |
62 | echo "$bar" | |
63 | echo '' | |
64 | echo "$weather" | |
65 | echo '' |