Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 19 Nov 2017, 18:00
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Network
ntpdate gets the time and date right on your Puppy
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [7 Posts]  
Author Message
musher0


Joined: 04 Jan 2009
Posts: 11158
Location: Gatineau (Qc), Canada

PostPosted: Mon 07 Aug 2017, 17:26    Post subject:  ntpdate gets the time and date right on your Puppy
Subject description: Puppy had always given me a hell of a time with this...
 

Hello all.

I've always had a problem with Puppy setting the date and time correctly
for my session. I was setting my time zone correctly, but no luck.

Except with psync, but some Puppies don't have it. And more often than
not, psync is a slowpoke, IMO.

I started searching for an alternative.

At ntp.org, you'll find material to set up your own ntp server if you like,
but there you'll also find a small utility called ntpdate which does exactly
this: set the time on your computer against the data provided by an ntp
server in your country.

~~~~~~~~~

Note --
ntpdate needs the libssl.so.1.1 and libcrypto.so.1.1 to work. Some Pups,
like petihar's Tahr derivative, Triton, do not have it. The following
pinstall.sh script will correct that situation.

Please read the comments in the code below so you won't fall
off your chair
if the libs start downloading.

It will also set the country properly in the /etc/ntp.conf file.
Code:
#!/bin/sh
# pinastall.sh # for ntpdate pet
# What this script does:
# 1) It checks if you have the proper ssl and crypto libraries for ntpdate;
# 2) It sets the ntp server configuration file for your country.
# (c) musher0, Aug. 7 2017. GPL3. Please read:
# https://opensource.org/licenses/GPL-3.0
####
A=/usr/lib/libssl.so.1.1;B=/usr/lib/libcrypto.so.1.1
if [ "`ls $A`" != "$A" -o "`ls $B`" != "$B" ];then
# This part gets and installs the libs if not installed in your Puppy.
   cd ~/my-applications
   wget http://dl.fedoraproject.org/pub/fedora-secondary/releases/26/Everything/i386/os/Packages/o/openssl-libs-1.1.0f-4.fc26.i686.rpm
# This takes a few seconds.
   petget openssl-libs-1.1.0f-4.fc26.i686.rpm
# You may wish to delete this rpm archive when done.
# (This openssl archive also contains the libcrypto library.)
fi
##
CountrY="${LANG:3:2}";CountrY="${CountrY,,}"
if [ "`grep -v $CountrY /etc/ntp.conf`" ];then
# If you are in Canada, you don't need this part, because the default
configuration file already points to Canadian servers.
   echo "server 0.$CountrY.pool.ntp.org
server 1.$CountrY.pool.ntp.org
server 2.$CountrY.pool.ntp.org
server 3.$CountrY.pool.ntp.org" > /etc/ntp.conf
fi
## Fin | End ##

This script fetches the dependencies if you don't have them on your Puppy,
and sets the country code for ntpdate according to the second part of your
LANG variable.

The LANG variable syntax is always the pair "language-country" (plus the
utf8 at the end). For ex.: en_US, en_AU, fr_CA, pt_BR. It was easy enough
to extract it for re-use in the ntp.conf file.

I haven't thoroughly checked, but I believe only the smallest countries do
not have their own time server(s). If you live in a country which does not
have a time server, please let me know your country code and I'll try to
incorporate it in the pinstall script. TIA.

At the opposite end, if you live in a large country such as the US, Australia
or Canada, it is not necessary to specify the state or province nearest you:
the ntpdate utility will figure it out through its other configuration file,
ntp.drift, located at /var/lib/ntp. With this, ntpdate can use the ntp server
nearest you, and set your computer date and time faster.

Ntpdate works this way:
based on the country information provided in /etc/ntp.conf, it connects to
the nearest server available in the ntp pool of servers for your country.
(Some countries have dozens, even hundreds, of ntp servers.)

~~~~~~~~~

An advantage of ntpdate is that it will correctly set the date and time on
your computer even if your computer battery is dead! There you go:
musher0 just saved you five bucks! Smile

~~~~~~~~~

Once this pet is installed, please have a look at ~/Startup. You'll see the
ntpdate launcher there is named "zz-ntp-sync.sh". That's on purpose.

This script needs to be the last one called in the Startup chain. I found that
out through experience, I'm not an ntp specialist. Please do not rename
this Startup script.

My tentative explanation is that an ntp connection needs a bit of time to
establish itself properly, and launchers running afterwards would disturb it.

If someone could fill us in with some science on that, it would be great.

~~~~~~~~~

I've been using ntpdate on various recent Puppies (Tahr, Puduan, Slim6,
DPupStretch) for about six months now, and I never had a problem with it.

Your constructive and improvement-oriented feedback is always welcome.

BFN.
ntp-4.2.8p10_simple.pet
Description 
pet

 Download 
Filename  ntp-4.2.8p10_simple.pet 
Filesize  65.14 KB 
Downloaded  32 Time(s) 

_________________
musher0
~~~~~~~~~~
"Logical entities must not be multiplied beyond necessity." | |
« Il ne faut pas multiplier les entités logiques sans nécessité. » (Ockham)

Last edited by musher0 on Sun 20 Aug 2017, 17:04; edited 1 time in total
Back to top
View user's profile Send private message 
Moose On The Loose


Joined: 24 Feb 2011
Posts: 773

PostPosted: Tue 08 Aug 2017, 10:24    Post subject: Re: ntpdate gets the time and date right on your Puppy
Subject description: Puppy had always given me a hell of a time with this...
 

musher0 wrote:
Hello all.

I've always had a problem with Puppy setting the date and time correctly
for my session. I was setting my time zone correctly, but no luck.

Except with psync, but some Puppies don't have it. And more often than
not, psync is a slowpoke, IMO.


Attached is my variation on psync for 528.
The intended changes were:
--The dialog box fits onto the screen on a 640x400
--When it has troubles it trys to explain what went wrong.

I have been using it for a long time now and it has never seemed slow to me. Some of what it does maybe could be combined with your ntpdate.
psync-2.0.pet
Description 
pet

 Download 
Filename  psync-2.0.pet 
Filesize  5.65 KB 
Downloaded  32 Time(s) 
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 11158
Location: Gatineau (Qc), Canada

PostPosted: Tue 08 Aug 2017, 17:03    Post subject:  

I'll have a look at it. Thanks, Moose.
_________________
musher0
~~~~~~~~~~
"Logical entities must not be multiplied beyond necessity." | |
« Il ne faut pas multiplier les entités logiques sans nécessité. » (Ockham)
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 11158
Location: Gatineau (Qc), Canada

PostPosted: Tue 05 Sep 2017, 14:24    Post subject:  

Hello all.

After a few tests, this is the wrapper that I now use in /root/Startup:
Code:
#!/bin/sh
# ~/Startup/zz-ntp-sync.sh
#
# So named because this script should be the last to be launched in the ~/Startup directory.
#
# Goal: Adjust the time on your computer clock by synchronizing it with an ntp server.
#
# Requires the ntp suite. (De : / From: http://www.ntp.org/downloads.html)
# Also the configuration files: /etc/ntp.conf, /var/lib/ntp/ntp.drift.
#
# Source : http://www.pool.ntp.org/fr/use.html
#
# (c) Christian L'Écuyer, Gatineau (Qc), Canada, 3 avril 2017. GPL3
# (Alias musher0 [forum Puppy].) # https://opensource.org/licenses/GPL-3.0
# Rév. : 16 juin, 3 juillet et 13 août 2017.
#
####
[ "`lsof -i | grep -o dhcpcd`" ] || sleep 15s
# Wait until frisbee has established a connection.
# The real lsof is needed here, not the busybox contraption of lsof.

ntpdate pool.ntp.org

YMMV. BFN.

_________________
musher0
~~~~~~~~~~
"Logical entities must not be multiplied beyond necessity." | |
« Il ne faut pas multiplier les entités logiques sans nécessité. » (Ockham)
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 11158
Location: Gatineau (Qc), Canada

PostPosted: Wed 06 Sep 2017, 03:43    Post subject:  

Hello all.

I've been reading a bit on dhcpcd. I found that the lsof line above can be
successfully replaced by
Code:
[ "`ps | awk '$4 ~ /dhcpcd/'`" ] || sleep 15s
This entirely removes the need to call any type of lsof to check.

We query with < ps > if dhcpcd is running in memory. If it is, we proceed
without pause to retrieving or validating our computer's time data. This is
useful when recycling our sessions during the day.

On the other hand, the 15 seconds wait is useful on the 1st boot of the
day. On 1st boot, we indeed have to wait until freesbee or another "Puppy
connector" establishes the connection.

After some tests, I discovered that 15 seconds is the best delay on this
machine, but don't hesitate to increase this number if your connection
needs more time to get established.

~~~~~~~~~~~~~~~~

Finally, please note that I cannot test a wi-fi connection, since AFAIK, we
only have ethernet connection in this neighborhood. It would be great if
one of you could complement this little script with a check for a wi-fi
connection, for those who do not have cable Internet.

I understand that freesbee is supposed to take care of wi-fi as well as
ethernet connections, so if the script doesn't need a complement for wi-fi,
I'd appreciate your letting me know as well.

TIA.


~~~~~~~~~~~~~~~~

IHTH. BFN.

_________________
musher0
~~~~~~~~~~
"Logical entities must not be multiplied beyond necessity." | |
« Il ne faut pas multiplier les entités logiques sans nécessité. » (Ockham)
Back to top
View user's profile Send private message 
Moose On The Loose


Joined: 24 Feb 2011
Posts: 773

PostPosted: Wed 06 Sep 2017, 10:35    Post subject:  

musher0 wrote:
Hello all.


And a gracious good morning to you.

It seems to me that checking that the internet is functioning is complicated unless you consider the ability to reach a specific site as the indication.

[code]

if ping -c 1 www.bogus.com ; then echo "Internet connected"; fi
ping: bad address 'www.bogus.com'

if ping -c 1 www.duckduckgo.com ; then echo "Internet connected"; fi
PING www.duckduckgo.com (50.18.192.250): 56 data bytes
64 bytes from 50.18.192.250: seq=0 ttl=51 time=12.831 ms

--- www.duckduckgo.com ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 12.831/12.831/12.831 ms
Internet connected

[/quote]
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 11158
Location: Gatineau (Qc), Canada

PostPosted: Wed 06 Sep 2017, 16:29    Post subject:
Subject description: If it works, don't fix it! (Proverb)
 

HI Moose.

Thanks for the reminder.
But the script above is working, so I'm not fixing it! Wink

BFN.

_________________
musher0
~~~~~~~~~~
"Logical entities must not be multiplied beyond necessity." | |
« Il ne faut pas multiplier les entités logiques sans nécessité. » (Ockham)
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [7 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Network
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0669s ][ Queries: 12 (0.0078s) ][ GZIP on ]