home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
-
- # A small script used to set the time under Linux with hwclock...
- # MU: updated for puppy 1.0.7.
-
- # Title to be used for all Xdialog boxes.
- TITLE="Set time tool"
-
- # Now check for hwclock existence...
- if ! [ -f /usr/sbin/hwclock ] ; then
- Xdialog --title "$TITLE" --msgbox "/usr/sbin/hwclock not found..." 0 0
- exit 0
- fi
-
- # Get the date (returned in DD/MM/YYYY format by Xdialog.
- ENTEREDDATE=`Xdialog --stdout --title "$TITLE" --calendar "Please set the date..." 0 0 0 0 0`
- if [ ! $? -eq 0 ]; then
- exit
- fi
-
- # Convert the date to the MM/DD/YYYY format needed by hwclock.
- NEWDATE=`echo "$ENTEREDDATE" | awk --source 'BEGIN { FS="/" }' --source '{ print $2 "/" $1 "/" $3 }'`
-
- # Get the time in HH:MM:SS format.
- NEWTIME=`Xdialog --stdout --title "$TITLE" --timebox "Please set the time..." 0 0`
- if [ ! $? -eq 0 ]; then
- Xdialog --title "$TITLE" --msgbox "Aborted." 0 0
- exit
- fi
-
-
- # Set the hardware clock (RTC) and then the system clock
-
- D=`echo $NEWDATE|sed "s/^...//" | sed "s/\/.*$//"`
-
- M=`echo $NEWDATE|sed "s/\/.*$//"`
- Y=`echo $NEWDATE|sed "s/^........//" | sed "s/ .*$//"`
-
- H=`echo $NEWTIME|sed "s/^.* //" | sed "s/://g" | sed "s/..$//"`
-
- DT=`echo $M$D$H$Y`
-
- date $DT
-
-
- Xdialog --title "info" --msgbox "Your screen might turn black now for some seconds, just wait..." 0 0
-
- /usr/sbin/hwclock --systohc --localtime
-
- THEDATE=`date`
- Xdialog --title "info" --msgbox "Finished. Time was set to $THEDATE" 0 0
-