diff options
| author | Marc Vertes <mvertes@free.fr> | 2025-01-21 15:42:22 +0100 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2025-01-21 15:42:22 +0100 |
| commit | e5f5c9b635dca0c59808c2c2aeb5b5e4d569989e (patch) | |
| tree | 4e5e34d7a44c30dd3d6bb798f17b285eb3d2d1de /bin/update_hosts | |
| parent | 7e5c61de7d243038d058973d191e729e52c4cbd2 (diff) | |
fix bin/update_hosts
Diffstat (limited to 'bin/update_hosts')
| -rwxr-xr-x | bin/update_hosts | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/bin/update_hosts b/bin/update_hosts index 74bf25b..54aa528 100755 --- a/bin/update_hosts +++ b/bin/update_hosts @@ -5,13 +5,18 @@ [ "$USER" = root ] || exec sudo "$0" "$@" +cdate=date +case $(uname -s) in +(Darwin) cdate=gdate ;; # install gdate with 'brew install coreutils' +esac + echo 'Checking from https://github.com/StevenBlack/hosts:' lsd=$(curl -s 'https://api.github.com/repos/StevenBlack/hosts/commits?path=hosts&page=1&per_page=1' | jq -r '.[0].commit.committer.date') -#echo "last source update: $(date -j -f "%FT%TZ" "$lsd")" -echo "last source update: $(date --date="$lsd")" +echo "last source update: $(date -j -f "%FT%TZ" "$lsd")" +#echo "last source update: $(date --date="$lsd")" # with BSD date echo "last local update: $(date -r /etc/hosts)" -# [ $(date -j -f "%FT%TZ" "$lsd" +%s) -lt $(date -r /etc/hosts +%s) ] && echo 'Nothing to do' && exit -[ $(date --date="$lsd" +%s) -lt $(date -r /etc/hosts +%s) ] && echo 'Nothing to do' && exit +[ $(date -j -f "%FT%TZ" "$lsd" +%s) -lt $(date -r /etc/hosts +%s) ] && echo 'Nothing to do' && exit +# [ $(date --date="$lsd" +%s) -lt $(date -r /etc/hosts +%s) ] && echo 'Nothing to do' && exit # with BSD date # with BSD date cd /etc cp -p hosts hosts.old |
