description "This starts up the TIL"

start on stopped modempower ok

script

# For Type A

# RdoT is the radio token file that specifies
# whether this is a GSM device or a CDMA device.
# RdoT is created by running PmModemInfo. Once
# RdoT is created on the device, we don't have
# to run PmModemInfo again.

# First check if RdoT exists. If it does, we
# already have the radio type and we don't
# need to run PmModemInfo. If it doesn't exist,
# we run PmModemInfo which creates RdoT. 

if  [ -f /var/lib/til/RdoT ]; then
    logger -p info "Read From Existing Token file"
    export radioType=`cat /var/lib/til/RdoT`
else
    logger -p info "Executing ModemInfo"
    modeminfo=`/usr/bin/PmModemInfo || true`
    logger -p info "Reading Token After ModemInfo"
    export radioType=`cat /var/lib/til/RdoT`
fi

# In case RdoT contains an invalid value or 
# PmModemInfo failed to create RdoT, we try
# running PmModemInfo again.

if [ "$radioType" != "UMTS" -a "$radioType" != "CDMA" ]; then
    logger -p info "Executing ModemInfo AGAIN"
    modeminfo=`/usr/bin/PmModemInfo || true`
    logger -p info "Reading Token"
    export radioType=`cat /var/lib/til/RdoT`
fi

# Now we start the TIL appropriate for the radio type
# specified in RdoT. If RdoT doesn't contain a valid 
# radio type, we'll assume default radio type.

if  [ -f /etc/virtura ]; then
    logger -p info "Launch Virtual TIL"
    
    # on newer architectures, we ask the radio
    # what type it is (cdma, gsm..)
    radioType=""
    exec /usr/bin/PmWsfDaemon -c /etc/til.d/tilwsfvirtual.conf
    
elif [ "$radioType" = "UMTS" ];then
    logger -p info "Launch UMTS TIL"
    exec /usr/bin/PmWsfDaemon -c /etc/til.d/tilwsfgsm.conf
elif [ "$radioType" = "CDMA" ];then
    logger -p info "Launch CDMA TIL"
    exec /usr/bin/PmWsfDaemon -c /etc/til.d/tilwsfcdma.conf
else
    logger -p emerg "********** Unknown Radio Launching Default TIL (CDMA) ************"
    exec /usr/bin/PmWsfDaemon -c /etc/til.d/tilwsfcdma.conf
fi

end script

respawn

