#!/bin/bash ######################################################################## # filename: setrlcclock # description: Reads the Linux system clock (localtime) then generates # the DTMF sequences to set the RLC-3 repeater controller # clock's Date and Time. # notes: Uses the fastdtmfdial script if available; otherwise, # the dtmfdial script is used. fastdtmfdial has settable # speed parameters and can send the DTMF tone very quickly. # See the node owner's list for messages on how to create # the fastdtmfdial script on your system. # ${SCRIPT}/dtmfdial # history: # 20020628 kc6hur Original release # 20020903 kc6hur Modified to automatically use fastdtmfdial if # available. ######################################################################## # # check user # if [ `/usr/bin/whoami` != "repeater" ] ; then echo $0: must be run as user 'repeater'! exit 1 fi # # check environment # if [ "$RUN_ENV" != "TRUE" ] ; then echo -n "loading IRLP environment..." . /home/irlp/custom/environment echo "DONE" fi # # Constants # CMDPREFIX=0 # RLC-3 Command Prefix Code (default is 0) SETTIME=025 # RLC-3 Set Time Command SETDATE=028 # RLC-3 Set Date Command FORCEEX=D # RLC-S Forced Execute Command (default is D) AM=0 PM=1 # # Subroutines # function procdate () { # Determine the dialer to use if [ -f ${CUSTOM}/fastdtmfdial ] ; then DIALER="${CUSTOM}/fastdtmfdial" else DIALER="${SCRIPT}/dtmfdial" fi # Convert the AM/PM if [ "$7" = "AM" ] ; then AMPM=${AM} else AMPM=${PM} fi echo -n "Setting RLC-3 clock time..." ${DIALER} ${CMDPREFIX}${SETTIME}$5$6${AMPM}${FORCEEX} echo "DONE" sleep 2 echo -n "Setting RLC-3 clock date..." ${DIALER} ${CMDPREFIX}${SETDATE}$1$2$3$[$4+1]${FORCEEX} echo "DONE" } # # Main # procdate `date +"%m %d %y %w %I %M %p"`