aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Braendli <matthias.braendli@u-blox.com>2015-01-13 09:23:28 +0100
committerMatthias Braendli <matthias.braendli@u-blox.com>2015-01-13 09:23:28 +0100
commit3d3382cadcd032d1e58c95ee82262f91424ad98b (patch)
tree348dcca34791571a99fdf8a7984ed70e4a0a9871
parent3f2143ac7ad93e0d0283cd733af1f1061e2867aa (diff)
downloaddab-scripts-3d3382cadcd032d1e58c95ee82262f91424ad98b.tar.gz
dab-scripts-3d3382cadcd032d1e58c95ee82262f91424ad98b.tar.bz2
dab-scripts-3d3382cadcd032d1e58c95ee82262f91424ad98b.zip
Fix shell script bugs
-rwxr-xr-xencode-jack-dls.sh13
-rwxr-xr-xencode-jack.sh13
-rwxr-xr-xlaunch-all-encoders.sh2
-rwxr-xr-xradio.sh4
-rwxr-xr-xstart-mux-mod.sh4
5 files changed, 17 insertions, 19 deletions
diff --git a/encode-jack-dls.sh b/encode-jack-dls.sh
index 848f25a..7b8f8c9 100755
--- a/encode-jack-dls.sh
+++ b/encode-jack-dls.sh
@@ -22,13 +22,13 @@ printmsg() {
set -u
# check number of arguments
-if [[ "$#" < 3 ]] ; then
+if [[ "$#" -lt 3 ]] ; then
echo "Usage $0 url jack-id destination [volume] [encoder]"
echo "The volume setting is optional"
exit 1
fi
-if [[ "$#" > 2 ]] ; then
+if [[ "$#" -gt 2 ]] ; then
URL=$1
ID=$2
DST=$3
@@ -49,7 +49,7 @@ fi
BITRATE=80
RATE=32 #kHz
-if [[ "$ENC" == "toolame" && "RATE" == "32" ]] ; then
+if [[ "$ENC" == "toolame" && "$RATE" == "32" ]] ; then
echo "32kHz not supported for toolame"
exit 1
fi
@@ -57,7 +57,6 @@ fi
DLSDIR=site/dls
SLIDEDIR=site/slide
-encoderalive=0
mplayerpid=0
encoderpid=0
motencoderpid=0
@@ -100,11 +99,11 @@ while [[ "$running" == "1" ]]
do
if [[ "$mplayerpid" == "0" ]] ; then
if [[ "$VOL" == "0" ]] ; then
- mplayer -quiet -af resample=${RATE}000:0:2 -ao jack:name=$ID $URL | \
+ mplayer -quiet -af resample=${RATE}000:0:2 -ao jack:name=$ID "$URL" | \
./icy-info.py $DLSDIR/${ID}.dls $DLSDIR/${ID}-default.dls &
mplayerpid=$!
else
- mplayer -quiet -af resample=${RATE}000:0:2 -af volume=$VOL -ao jack:name=$ID $URL | \
+ mplayer -quiet -af resample=${RATE}000:0:2 -af volume=$VOL -ao jack:name=$ID "$URL" | \
./icy-info.py $DLSDIR/${ID}.dls $DLSDIR/${ID}-default.dls &
mplayerpid=$!
fi
@@ -276,7 +275,7 @@ do
if [[ "$MAILTO" != "" ]] ; then
NOW=$(date)
- mail -s "Encoder $ID restart $URL" $MAILTO << EOF
+ mail -s "Encoder $ID restart $URL" "$MAILTO" << EOF
The encoder id:$ID
encoding $URL -> $DST using encode-jack-dls was restarted at
$NOW
diff --git a/encode-jack.sh b/encode-jack.sh
index 3836a84..f6d822d 100755
--- a/encode-jack.sh
+++ b/encode-jack.sh
@@ -20,13 +20,13 @@ printmsg() {
set -u
# check number of arguments
-if [[ "$#" < 3 ]] ; then
+if [[ "$#" -lt 3 ]] ; then
echo "Usage $0 url jack-id destination [volume] [encoder]"
echo "The volume setting is optional"
exit 1
fi
-if [[ "$#" > 2 ]] ; then
+if [[ "$#" -gt 2 ]] ; then
URL=$1
ID=$2
DST=$3
@@ -47,12 +47,11 @@ fi
BITRATE=80
RATE=32 #kHz
-if [[ "$ENC" == "toolame" && "RATE" == "32" ]] ; then
+if [[ "$ENC" == "toolame" && "$RATE" == "32" ]] ; then
echo "32kHz not supported for toolame"
exit 1
fi
-encoderalive=0
mplayerpid=0
encoderpid=0
running=1
@@ -88,10 +87,10 @@ while [[ "$running" == "1" ]]
do
if [[ "$mplayerpid" == "0" ]] ; then
if [[ "$VOL" == "0" ]] ; then
- mplayer -quiet -af resample=${RATE}000:0:2 -ao jack:name=$ID $URL &
+ mplayer -quiet -af resample=${RATE}000:0:2 -ao jack:name=$ID "$URL" &
mplayerpid=$!
else
- mplayer -quiet -af resample=${RATE}000:0:2 -af volume=$VOL -ao jack:name=$ID $URL &
+ mplayer -quiet -af resample=${RATE}000:0:2 -af volume=$VOL -ao jack:name=$ID "$URL" &
mplayerpid=$!
fi
@@ -221,7 +220,7 @@ do
if [[ "$MAILTO" != "" ]] ; then
NOW=$(date)
- mail -s "Encoder $ID restart $URL" $MAILTO << EOF
+ mail -s "Encoder $ID restart $URL" "$MAILTO" << EOF
The encoder id:$ID
encoding $URL -> $DST using encode-jack was restarted at
$NOW
diff --git a/launch-all-encoders.sh b/launch-all-encoders.sh
index ec365cf..e4ca3db 100755
--- a/launch-all-encoders.sh
+++ b/launch-all-encoders.sh
@@ -11,7 +11,7 @@ then
for radio in ${all_radios[*]}
do
echo "Launching $radio encoder"
- screen -t $radio ./radio.sh $radio
+ screen -t "$radio" ./radio.sh "$radio"
sleep 0.4
done
diff --git a/radio.sh b/radio.sh
index b39eb39..b6eb305 100755
--- a/radio.sh
+++ b/radio.sh
@@ -27,7 +27,7 @@ sigint_trap() {
set -e
# check number of arguments
-if [[ "$#" < 1 ]] ; then
+if [[ "$#" -lt 1 ]] ; then
echo "Usage $0 radio-id"
echo "You must specify which radio to start"
exit 1
@@ -35,7 +35,7 @@ fi
RADIO=$1
-if [ ${radios[$RADIO]+_} ] ; then
+if [ "${radios[$RADIO]+_}" ] ; then
COMMAND=${radios[$RADIO]}
trap sigint_trap SIGINT
diff --git a/start-mux-mod.sh b/start-mux-mod.sh
index c7f2489..96e05c2 100755
--- a/start-mux-mod.sh
+++ b/start-mux-mod.sh
@@ -2,7 +2,7 @@
#
# Launch the multiplexer and the modulator
-if [[ -e site/multiplex.mux && -e site/mod.ini && site/mail-warning.txt ]]
+if [[ -e site/multiplex.mux && -e site/mod.ini && -e site/mail-warning.txt ]]
then
while true
@@ -14,7 +14,7 @@ then
if [[ "$MAILTO" != "" ]] ; then
NOW=$(date)
- mail -s "MUX and MOD restart" $MAILTO << EOF
+ mail -s "MUX and MOD restart" "$MAILTO" << EOF
The mux and mod were restarted at
$NOW