forked from jasonacox/Powerwall-Dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtz.sh
executable file
·40 lines (36 loc) · 968 Bytes
/
tz.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# Shell script to replace timezone values in powerwall.yml, telegraf.conf, influxdb.sql and dashboard.json
if [ $# -eq 0 ]
then
echo "ERROR: No timezone supplied"
echo
echo "USAGE: ${0} {timezone}"
exit
fi
# Current and New TZ values
DEFAULT="America/Los_Angeles"
CURRENT=`cat tz`
NEW=$1
# Replace TZ Function
updatetz() {
local from=${1}
local to=${2}
sed -i.bak "s@${from}@${to}@g" powerwall.yml
sed -i.bak "s@${from}@${to}@g" telegraf.conf
sed -i.bak "s@${from}@${to}@g" influxdb/influxdb.sql
for i in dashboards/dashboard*.json; do
sed -i.bak "s@${from}@${to}@g" $i
done
sed -i.bak "s@${from}@${to}@g" pypowerwall.env
if [ -d "dashboards" ]
then
for i in dashboards/*.json; do
sed -i.bak "s@${from}@${to}@g" $i
done
fi
}
# Replace TZ values
updatetz "${CURRENT}" "${NEW}"
updatetz "${DEFAULT}" "${NEW}"
# Record new TZ value
echo "${NEW}" > tz