wrs_auxclk.sh 1.47 KB
Newer Older
1 2 3 4
#!/bin/sh

# Script read wrs_auxclk parameters from dot-config, then start wrs_auxclk.

5 6 7
tmpdir=/tmp
wrs_auxclk_set_status_file="$tmpdir"/wrs_auxclk_set_status

8 9
# First, read dot-config to get wrs_auxclk parameters
dotconfig=/wr/etc/dot-config
10
set -o pipefail
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

if [ -f $dotconfig ]; then
    . $dotconfig
else
    # exit
    echo "dot-config not found! Don't setup wrs_auxclk"
    exit 1
fi

if [ ! -z "$CONFIG_WRSAUXCLK_FREQ" ]; then
	p_freq="--freq "$CONFIG_WRSAUXCLK_FREQ;
fi

if [ ! -z "$CONFIG_WRSAUXCLK_DUTY" ]; then
	p_duty="--duty "$CONFIG_WRSAUXCLK_DUTY;
fi

if [ ! -z "$CONFIG_WRSAUXCLK_CSHIFT" ]; then
	p_cshift="--cshift "$CONFIG_WRSAUXCLK_CSHIFT;
fi

if [ ! -z "$CONFIG_WRSAUXCLK_SIGDEL" ]; then
	p_sigdel="--sigdel "$CONFIG_WRSAUXCLK_SIGDEL;
fi

if [ ! -z "$CONFIG_WRSAUXCLK_PPSHIFT" ]; then
	p_ppshift="--ppshift "$CONFIG_WRSAUXCLK_PPSHIFT;
fi

40 41 42 43 44 45 46 47 48 49 50 51
WRS_LOG=$CONFIG_WRS_LOG_OTHER

# if empty turn it to /dev/null
if [ -z $WRS_LOG ]; then
    WRS_LOG="/dev/null";
fi

# if a pathname, use it
if echo "$WRS_LOG" | grep / > /dev/null; then
    eval LOGPIPE=\" \> $WRS_LOG 2\>\&1 \";
else
    # not a pathname: use verbatim
52
    eval LOGPIPE=\" 2\>\&1 \| logger -t auxclk -p $WRS_LOG\"
53 54
fi

55
# execute wrs_auxclk
56
echo -n "Configuring external clock clk2: "
57 58 59 60
eval /wr/bin/wrs_auxclk $p_freq $p_duty $p_cshift $p_sigdel $p_ppshift $LOGPIPE
ret=$?
if [ $ret -eq 0 ]; then
    echo "OK"
61
    echo "ok" > $wrs_auxclk_set_status_file
62
else
63
    echo "Failed"
64
    echo "failed" > $wrs_auxclk_set_status_file
65
fi