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 Mon 18 Jun 2018, 00:34
All times are UTC - 4
 Forum index » House Training » Bugs ( Submit bugs )
Puppy 528 time sync bugs and fix
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [1 Post]  
Author Message
Moose On The Loose

Joined: 24 Feb 2011
Posts: 778

PostPosted: Fri 14 Jun 2013, 10:39    Post subject:  Puppy 528 time sync bugs and fix
Subject description: The script that did the time sync on boot had several problems

I tried to do it as an attachment but I got "extension not allowed" error messages when I tried.

I commented what the script does and added some GUI to tell the user about the issues.

In the older version, if the network was not working at the time of boot, the sync function would silently fail.

In this version, a simple GUIis forced on if there is an error so the user knows what to do rather than scratching their head about why the time is wrong any time they re-boot.

If the "localtime" "utc" thing had a commented line in it, the script would silently fail.

****** Cut here ************
#Clock Set Gui
# /usr/local/psync/psyncfunc
# This used the:
#Robert Lane 2009 2010 2011(tasmod)
# version as a starting point
# Many edits by moose-on-the-loose, to the point of a near complete
# rewrite but with care to keep compatible with the existing
# timesync.sh script

# List the servers that will be used
# If you are adding one remember
# 1-The variable name must be the same as what comes in on $1
# 2-If it is not ntp.org an edit is needed later in this script
NORTHAMERICA="north-america.pool.ntp.org "
SOUTHAMERICA="south-america.pool.ntp.org "

# Turn the $1 into the DOGUI switch and server name
DOGUI=$(echo "$WHERE" | cut -d "," -f 2 )
WHERE=$(echo "$WHERE" | cut -d "," -f 1 )
eval "SERVER=\${${WHERE}}"

# if something weird happened stuff in a default value for now
if ! ( echo "$SERVER" | grep -q "ntp.org" ) ; then
Xdialog -infobox "Trouble in /usr/local/psync/psyncfunc the server name
looks incorrect setting it to a default of $SERVER" 0 0

# Read the /etc/clock file to look at what sort of time we are doing
# it is "localtime" or "utc"
# This doesn't work if there are comments in the file
#HTIME=`cat /etc/clock | grep 'HWCLOCKTIME' | cut -d "=" -f 2 `
# This fixes that
HTIME=$( cat /etc/clock | cut -d "#" -f 1 | grep "HWCLOCKTIME" | cut -d "=" -f 2 )

# If I don't find the file etc, I force it to UTC.
if [[ "$HTIME" == "localtime" ]] ; then
HWCLOCKCMD="hwclock -w"
# all else taken as UTC
HWCLOCKCMD="hwclock --systohc --utc"
if [[ "$HTIME" != "utc" ]] ; then
Xdialog -infobox "Trouble in /usr/local/psync/psyncfunc the read of
/etc/clock gave something other than 'localtime' or 'utc'" 0 0

# A loop so we can check again after we think it is fixed
while (true) ; do
# Any network "link" that is "BROADCAST" and "UP" is assumed to be a
# working network
if ! ( ip link | grep "<BROADCAST" | grep -q ",UP," ) ; then
TEXT="<text xalign=\"0\" wrap=\"true\" width-request=\"500\"><label>"
MSG="$TEXT We are attempting to sychronize the clock to an external"
MSG="$MSG server but there is no network working yet."
MSG="$MSG You have a few options for trying to fix this. $TEND"
TEXT="<text xalign=\"0\" wrap=\"true\" width-request=\"400\"><label>"
OP1="$TEXT It may be that the network connection took time to start working"
OP1="$OP1 and by time you have read this is now running. $TEND"
OP2="$TEXT The network may not be configured. Click here to run the"
OP2="$OP2 network wizard. $TEND"
OP3="$TEXT If you want to deal with the problem manually, click here."
OP3="$OP3 The clock synchroization will not be done at this time $TEND"
BUTTON="<button width-request=\"100\"><label>"
export P="
<window title=\"Synchronised Time problem\"><vbox><frame>$MSG</frame>
<frame><hbox>$OP1 $BUTTON Retry $BEND
<frame><hbox>$OP2 $BUTTON Connect $BEND
<frame><hbox>$OP3 $BUTTON Quit $BEND
RESULT=$(gtkdialog3 -c -p P)
case $RESULT in
* )

if $DOGUI ; then
Xdialog --infobox "Setting Time ........Please wait" 12 40 &

OFFSET=$(ntpdate $SERVER | grep "offset")

BLURB="# Psync autorun server location - Rob Lane (tasmod) 2011 (mod KS)"

echo -e $BLURB > /usr/local/psync/setcountry
echo -e "${WHERE}REP" >> /usr/local/psync/setcountry

if ! $DOGUI ; then

cd $HOME
export timeis="
<window title=\"Synchronised System Time\">
<frame Updated Time>
<text use-markup=\"true\"><label>\"<b>$NEWCURRENT_TIME</b>\"</label></text>
<text><label>\" \"</label></text>
<text use-markup=\"true\"><label>\" <b> Offset was $OFFSET </b>\"</label></text>
<text><label> To synchronise your clock at each startup. </label></text>
<text><label>Press the button for auto run at each startup.</label></text>
<text><label>\" \"</label></text>
<input file icon=\"gtk-execute\"></input>
<action>cp /usr/local/psync/timesync.sh /root/Startup/timesync.sh</action>
<action> exit: gtkdialogue </action>
<input file icon=\"gtk-execute\"></input>
<label>Remove Autostart</label>
<action>rm /root/Startup/timesync.sh</action>
<action> exit: gtkdialogue </action>
<input file icon=\"gtk-close\"></input>

#execute gtkdialog
gtkdialog3 -c -p timeis
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [1 Post]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Bugs ( Submit bugs )
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.0360s ][ Queries: 11 (0.0083s) ][ GZIP on ]