Remove sudo from mmcli commands in modem scripts

master
Miles Alan 5 years ago
parent e5877059ff
commit 8b52988ad2
  1. 8
      scripts/modem/sxmo_modemcall.sh
  2. 7
      scripts/modem/sxmo_modemmonitor.sh
  3. 6
      scripts/modem/sxmo_modemtext.sh

@ -17,13 +17,13 @@ contacts() {
modem_cmd_errcheck() { modem_cmd_errcheck() {
ARGS="$@" ARGS="$@"
RES="$(sudo mmcli $ARGS 2>&1)" RES="$(mmcli $ARGS 2>&1)"
[[ $? -eq 0 ]] || err "Problem executing mmcli command!\n$RES" [[ $? -eq 0 ]] || err "Problem executing mmcli command!\n$RES"
echo $RES echo $RES
} }
vid_to_number() { 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() { log_event() {
@ -61,7 +61,7 @@ dialmenu() {
echo "Attempting to dial: $NUMBER" >&2 echo "Attempting to dial: $NUMBER" >&2
VID="$( 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 echo "Starting call with VID: $VID" >&2
startcall $VID >&@ startcall $VID >&@
@ -78,7 +78,7 @@ startcall() {
acceptcall() { acceptcall() {
VID="$1" VID="$1"
echo "Attempting to pickup VID $VID" 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 modem_cmd_errcheck -m $(modem_n) -o $VID --accept
log_event "call_pickup" $VID log_event "call_pickup" $VID
} }

@ -12,8 +12,9 @@ newcall() {
sxmo_vibratepine 2000 & sxmo_vibratepine 2000 &
sxmo_setpineled green 1 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 # Delete all terminated calls
sudo mmcli -m $(modem_n) --voice-delete-call $i 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 done
echo "Incoming Call:" echo "Incoming Call:"
@ -45,7 +46,7 @@ newtexts() {
mkdir -p "$LOGDIR/$NUM" mkdir -p "$LOGDIR/$NUM"
echo -ne "Received from $NUM at $TIME:\n$TEXT\n\n" >> $LOGDIR/$NUM/sms.txt 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 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
sxmo_vibratepine 300 && sleep 0.1 sxmo_vibratepine 300 && sleep 0.1

@ -29,12 +29,12 @@ sendmsg() {
TEXTSIZE="$(echo "$TEXT" | wc -c)" TEXTSIZE="$(echo "$TEXT" | wc -c)"
SMSNO=$( 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]*$ 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 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 done
TIME="$(date --iso-8601=seconds)" TIME="$(date --iso-8601=seconds)"

Loading…
Cancel
Save