-
Notifications
You must be signed in to change notification settings - Fork 0
/
timeUpdate.sh
50 lines (36 loc) · 1.54 KB
/
timeUpdate.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
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
applicationPath=$(dirname $0)
timeZonePath=/usr/share/zoneinfo
RsyncServer=rsync://rsync.iana.org/tz/
timeZone=America/Santiago
tzTemp=${applicationPath}/tzTemp
tzBackup=${applicationPath}/tzBackup
hash make 2>/dev/null || { echo >&2 "'make' command required but not installed. Aborting."; exit 1; }
hash rsync 2>/dev/null || { echo >&2 "'rsync' command required but not installed. Aborting."; exit 1; }
tzDataCurrentPath=$(rsync -l ${RsyncServer}tzdata-latest.tar.gz | awk '{print $7}')
tzDataCurrentFile=$(echo $tzDataCurrentPath | awk -F"/" '{print $NF}')
tzCodeCurrentPath=$(rsync -l ${RsyncServer}tzcode-latest.tar.gz | awk '{print $7}')
tzCodeCurrentFile=$(echo $tzCodeCurrentPath | awk -F"/" '{print $NF}')
if [ ! -d "$tzBackup" ]; then
mkdir "$tzBackup"
fi
if [ ! -f "$tzBackup/$tzDataCurrentFile" ] || [ ! -f "$tzBackup/$tzCodeCurrentFile" ] ; then
if [ ! -d "$tzTemp" ]; then
mkdir "$tzTemp"
fi
cd "$tzTemp"
rsync ${RsyncServer}${tzCodeCurrentPath} .
rsync ${RsyncServer}${tzDataCurrentPath} .
cp "$tzDataCurrentFile" "../$tzBackup/$tzDataCurrentFile"
cp "$tzCodeCurrentFile" "../$tzBackup/$tzCodeCurrentFile"
gzip -dc ${tzDataCurrentFile} | tar -xf -
gzip -dc ${tzCodeCurrentFile} | tar -xf -
make "TOPDIR=`pwd`/tz_dir" install > /dev/null 2>&1
cp -fr ./bin-timezone/etc/zoneinfo/* ${timeZonePath}
echo $timeZone > /etc/timezone
cp -f "$timeZonePath/$timeZone" /etc/localtime
cd ..
rm -fr "$tzTemp"
echo "Hora corriente : `date`"
fi