From 8b52988ad2bc210ec2027b2075b72d280345e0b7 Mon Sep 17 00:00:00 2001 From: Miles Alan Date: Mon, 11 May 2020 22:13:15 -0500 Subject: [PATCH] Remove sudo from mmcli commands in modem scripts --- scripts/modem/sxmo_modemcall.sh | 8 ++++---- scripts/modem/sxmo_modemmonitor.sh | 7 ++++--- scripts/modem/sxmo_modemtext.sh | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/scripts/modem/sxmo_modemcall.sh b/scripts/modem/sxmo_modemcall.sh index 87d7161..115609e 100755 --- a/scripts/modem/sxmo_modemcall.sh +++ b/scripts/modem/sxmo_modemcall.sh @@ -17,13 +17,13 @@ contacts() { modem_cmd_errcheck() { ARGS="$@" - RES="$(sudo mmcli $ARGS 2>&1)" + RES="$(mmcli $ARGS 2>&1)" [[ $? -eq 0 ]] || err "Problem executing mmcli command!\n$RES" echo $RES } vid_to_number() { - sudo mmcli -m $(modem_n) -o $1 -K | grep call.properties.number | cut -d ':' -f2 | tr -d ' ' + mmcli -m $(modem_n) -o $1 -K | grep call.properties.number | cut -d ':' -f2 | tr -d ' ' } log_event() { @@ -61,7 +61,7 @@ dialmenu() { echo "Attempting to dial: $NUMBER" >&2 VID="$( - sudo mmcli -m $(modem_n) --voice-create-call "number=$NUMBER" | grep -Eo Call/[0-9]+ | grep -oE [0-9]+ + mmcli -m $(modem_n) --voice-create-call "number=$NUMBER" | grep -Eo Call/[0-9]+ | grep -oE [0-9]+ )" echo "Starting call with VID: $VID" >&2 startcall $VID >&@ @@ -78,7 +78,7 @@ startcall() { acceptcall() { VID="$1" echo "Attempting to pickup VID $VID" - #sudo mmcli --voice-status -o $VID + #mmcli --voice-status -o $VID modem_cmd_errcheck -m $(modem_n) -o $VID --accept log_event "call_pickup" $VID } diff --git a/scripts/modem/sxmo_modemmonitor.sh b/scripts/modem/sxmo_modemmonitor.sh index e7f04f5..832243d 100755 --- a/scripts/modem/sxmo_modemmonitor.sh +++ b/scripts/modem/sxmo_modemmonitor.sh @@ -12,8 +12,9 @@ newcall() { sxmo_vibratepine 2000 & sxmo_setpineled green 1 - for i in $(sudo mmcli -m $(modem_n) --voice-list-calls | grep terminated | grep -oE Call\/[0-9]+ | cut -d'/' -f2); do - sudo mmcli -m $(modem_n) --voice-delete-call $i + # Delete all terminated calls + for i in $(mmcli -m $(modem_n) --voice-list-calls | grep terminated | grep -oE Call\/[0-9]+ | cut -d'/' -f2); do + mmcli -m $(modem_n) --voice-delete-call $i done echo "Incoming Call:" @@ -45,7 +46,7 @@ newtexts() { mkdir -p "$LOGDIR/$NUM" echo -ne "Received from $NUM at $TIME:\n$TEXT\n\n" >> $LOGDIR/$NUM/sms.txt echo -ne "$TIME\trecv_txt\t$NUM\t$TEXTSIZE chars\n" >> $LOGDIR/modemlog.tsv - sudo mmcli -m $(modem_n) --messaging-delete-sms=$i + mmcli -m $(modem_n) --messaging-delete-sms=$i sxmo_vibratepine 300 && sleep 0.1 sxmo_vibratepine 300 && sleep 0.1 diff --git a/scripts/modem/sxmo_modemtext.sh b/scripts/modem/sxmo_modemtext.sh index f276fda..1e1385e 100755 --- a/scripts/modem/sxmo_modemtext.sh +++ b/scripts/modem/sxmo_modemtext.sh @@ -29,12 +29,12 @@ sendmsg() { TEXTSIZE="$(echo "$TEXT" | wc -c)" SMSNO=$( - sudo mmcli -m $MODEM --messaging-create-sms="text='$TEXT',number=$NUMBER" | + mmcli -m $MODEM --messaging-create-sms="text='$TEXT',number=$NUMBER" | grep -o [0-9]*$ ) - sudo mmcli -s ${SMSNO} --send || err "Couldn't send text message" + mmcli -s ${SMSNO} --send || err "Couldn't send text message" for i in $(mmcli -m $MODEM --messaging-list-sms | grep " (sent)" | cut -f5 -d' ') ; do - sudo mmcli -m $MODEM --messaging-delete-sms=$i + mmcli -m $MODEM --messaging-delete-sms=$i done TIME="$(date --iso-8601=seconds)"