set Time init script (network share depending)

Support for C series TVs that all user could ask. Please do not ask a questions at other forums.
Post Reply

User avatar
beatfreak
SamyGO Project Donor
Posts: 591
Joined: Tue Aug 23, 2011 9:03 am
Location: Hamburg
Contact:

set Time init script (network share depending)

Post by beatfreak »

I noticed the section

Code: Select all

         # set time, required for ssl communication but tv 'll show strange values
        #../../bin/busybox date -s "2011-06-23 13:45:00"
in

Code: Select all

SamyGO/etc/init.d/01_01_catch_crap.init
sure, as it has been commented out its not really necessary to set system time on boot.
and for some obscure reason the samsung-software-frontend knows the current time from dvb tuner but its not forwarded to system time...

maybe its a bit neurotic but this is how i do it...

on my NFS-Server (Win7) i run this script:

Code: Select all

@ECHO OFF
e:
cd E:\samygo
:start
set ctm=%time%
set chr=%ctm:~0,2%
set cmn=%ctm:~3,2%
if "%chr:~0,1%"==" " set chr=0%chr:~1,1%
echo %chr%%cmn%>timefile
ping 123.234.123.234 -n 1 -w 60000 > NUL
goto start
and on TV side:

Code: Select all

# cat SamyGO/etc/init.d/02_09_set_time.init
#!/bin/sh
#
#
. /dtv/SGO.env


FILTERI='-e s/Jan/01/;s/Feb/02/;s/Mar/03/;s/Apr/04/;s/May/05/;s/Jun/06/;s/Jul/07/;s/Aug/08/;s/Sep/09/;s/Oct/10/;s/Nov/11/;s/Dec/12/'
TIMEFILE=$SYSROOT/img/timefile
FILTERII="s/ 1/ 01/g;s/ 2/ 02/g;s/ 3/ 03/g;s/ 4/ 04/g;s/ 5/ 05/g;s/ 6/ 06/g;s/ 7/ 07/g;s/ 8/ 08/g;s/ 9/ 09/g"
case $1 in
    start)
        CURMONTH=`ls -l $TIMEFILE | sed $FILTERI -e "s/ \+ / /g" | cut -d' ' -f6`
        CURDAY=`ls -l $TIMEFILE | sed -e "s/ \+ / /g" -e "$FILTERII" | cut -d' ' -f7`
        CURYEAR=`ls -l $TIMEFILE | sed -e "s/ \+ / /g" | cut -d' ' -f8`
        CURTIME=`cat $TIMEFILE | cut -c1-4`
        date -s$CURMONTH$CURDAY$CURTIME$CURYEAR >/dev/null
        ;;
    stop)
        #rmmod fuse
        ;;
    status)
        ;;
    *)
    echo "Usage: $0 {start|stop}" 1>&2
    exit 0
    ;;
esac
#
this script gets called after nfs-share for pvrimage is available, timefile is in the same folder as pvrimage
Last edited by beatfreak on Sat Jan 25, 2014 5:08 pm, edited 1 time in total.
//UE40C6500 @ T-VALDEUC 3011 // rooted manual HotelMode style // PVR to NFS via 18MB on-the-fly sparse XFS //
FYI: you can close your ssh session with SamyGO with

Code: Select all

~.
If you can't fix it using dvct tape, you are not using enough dvct tape.
User avatar
beatfreak
SamyGO Project Donor
Posts: 591
Joined: Tue Aug 23, 2011 9:03 am
Location: Hamburg
Contact:

Re: set Time init script

Post by beatfreak »

Update:

Code: Select all

#!/bin/sh
#
#
. /dtv/SGO.env


FILTERCMD='-e s/Jan/01/;s/Feb/02/;s/Mar/03/;s/Apr/04/;s/May/05/;s/Jun/06/;s/Jul/07/;s/Aug/08/;s/Sep/09/;s/Oct/10/;s/Nov/11/;s/Dec/12/'
TIMEFILE=$SYSROOT/img/timefile
#FILTERII="s/ 1/ 01/g;s/ 2/ 02/g;s/ 3/ 03/g;s/ 4/ 04/g;s/ 5/ 05/g;s/ 6/ 06/g;s/ 7/ 07/g;s/ 8/ 08/g;s/ 9/ 09/g"
FILTERII="s/\<[0-9]\>/0&/"
case $1 in 
    start)
        CURMONTH=`ls -l $TIMEFILE | sed $FILTERCMD -e "s/ \+ / /g" | cut -d' ' -f6`
        CURDAY=`ls -l $TIMEFILE | sed -e "s/ \+ / /g" | cut -d' ' -f7`
        CURYEAR=`ls -l $TIMEFILE | sed -e "s/ \+ / /g" | cut -d' ' -f8`
        if [ ${#CURDAY} == 1 ]; then
                CURDAY=`echo $CURDAY | sed -e $FILTERII`
        fi
        #CURTIME=`date | sed -e "s/ \+ / /g" | cut -d' ' -f4`
        CURTIME=`cat $TIMEFILE | cut -c1-4`
        date -s$CURMONTH$CURDAY$CURTIME$CURYEAR >/dev/null 
        #date -s "$CURTIME" >/dev/null
        ;;
    stop)
        #rmmod fuse
        ;;
    status)
        ;;
    *)
    echo "Usage: $0 {start|stop}" 1>&2
    exit 0
    ;;
esac
//UE40C6500 @ T-VALDEUC 3011 // rooted manual HotelMode style // PVR to NFS via 18MB on-the-fly sparse XFS //
FYI: you can close your ssh session with SamyGO with

Code: Select all

~.
If you can't fix it using dvct tape, you are not using enough dvct tape.
User avatar
beatfreak
SamyGO Project Donor
Posts: 591
Joined: Tue Aug 23, 2011 9:03 am
Location: Hamburg
Contact:

Re: set Time init script

Post by beatfreak »

Update:

Code: Select all

# cat SamyGO/etc/init.d/03_04_set_time.init 
#!/bin/sh
#
#
. /dtv/SGO.env


FILTERCMD='-e s/Jan/01/;s/Feb/02/;s/Mar/03/;s/Apr/04/;s/May/05/;s/Jun/06/;s/Jul/07/;s/Aug/08/;s/Sep/09/;s/Oct/10/;s/Nov/11/;s/Dec/12/'
TIMEFILE=$TF_MOUNT/ramdrive/timefile
#FILTERII="s/ 1/ 01/g;s/ 2/ 02/g;s/ 3/ 03/g;s/ 4/ 04/g;s/ 5/ 05/g;s/ 6/ 06/g;s/ 7/ 07/g;s/ 8/ 08/g;s/ 9/ 09/g"
FILTERII="s/\<[0-9]\>/0&/"
case $1 in 
    start)
        echo `date`
        CURMONTH=`date -r $TIMEFILE | sed $FILTERCMD -e "s/ \+ / /g" | cut -d' ' -f2`
        CURDAY=`date -r $TIMEFILE | sed -e "s/ \+ / /g" | cut -d' ' -f3`
        CURYEAR=`date -r $TIMEFILE | sed -e "s/ \+ / /g" | cut -d' ' -f6`
        if [ ${#CURDAY} == 1 ]; then
                CURDAY=`echo $CURDAY | sed -e $FILTERII`
        fi
        CURTIME=`cat $TIMEFILE | cut -c1-4`
        CURSEC=`cat $TIMEFILE | cut -c5-6`
        CURDATE="$CURMONTH$CURDAY$CURTIME$CURYEAR.$CURSEC"
        date -s$CURDATE >/dev/null 
        echo `date`
        ;;
    stop)
        ;;
    status)
        ;;
    *)
    echo "Usage: $0 {start|stop}" 1>&2
    exit 0
    ;;
esac
# 
and (Win7)Server script:

Code: Select all

@ECHO OFF
e:
cd E:\nfsshare\ramdrive
:start
set ctm=%time%
set chr=%ctm:~0,2%
set cmn=%ctm:~3,2%
set csk=%ctm:~6,2%
if "%chr:~0,1%"==" " set chr=0%chr:~1,1%
echo %chr%%cmn%%csk%>timefile
timeout 1 > NUL
goto start
#
changes:
using date -r instead of ls -l as it always prints the same fields (if year is already == current year ls -l prints time instead of year)
using timeout instead of ping (less resource intensive)
having timefile placed on a ramdrive mounted in e:\nfsshare\ramdrive
location of timefile is detected during nfsshare init script:
(only changes in function do_mount)

Code: Select all

do_mount()
{
        #               $(echo -e "[sdg]\nVendor : NfsMount\nProduct : $FR_NAME\n\
        #Serial : Q80VQLFG\nDevpath : 7\nLun : 0\nMountDir : $DEST_DIR\nFileSystem : vfat\n" >> /dtv/usb/log)

        M_POINT="$DEST_DIR/$1/$(echo -n "$2" | sed -e "s/\//_/g")"
        mkdir -p "$M_POINT" 
        if [ `cat /proc/mounts | grep -c "$M_POINT"` -lt "1" ] ; then
                /bin/busybox mount -o "$M_OPTS" "$1:$2" "$M_POINT"
                if [ $? = 0 ]; then
                        echo "Share $1:$2 successfully mounted on $M_POINT" 
                        if [ -e "$M_POINT/ramdrive/timefile" ]; then
                                echo "TF_MOUNT=\"$M_POINT\"" >> /dtv/SGO.env 
                        else
                                echo "timefile not found on $M_POINT"
                        fi
                else
                        echo "Error during mount of $1:$2 on $M_POINT"
                fi
        else
                echo "Share $1:$2 is already mounted!"
        fi
}
//UE40C6500 @ T-VALDEUC 3011 // rooted manual HotelMode style // PVR to NFS via 18MB on-the-fly sparse XFS //
FYI: you can close your ssh session with SamyGO with

Code: Select all

~.
If you can't fix it using dvct tape, you are not using enough dvct tape.

Post Reply

Return to “[C] Support”