1

(26 odpowiedzi, napisanych Oprogramowanie / Software)

Działa jak trzeba. Super robotę robisz, pięknie dziękuję.

2

(26 odpowiedzi, napisanych Oprogramowanie / Software)

Widziałem, że w /openwrt-25.12/ już jest, a czy dla 24.10/aarch64_cortex-a53 też będzie? Wiem, że czeka mnie upgrade, ale trochę się jeszcze cykam smile

3

(26 odpowiedzi, napisanych Oprogramowanie / Software)

A wiadomo może kiedy najnowsza poprawka (https://github.com/obsy/sms_tool/pull/20) trafi do repo opkg? Czy nie nastawiać się za bardzo na to?

IceG napisał/a:

Na ten moment tak to dokladnie dziala

Dzięki za odpowiedź. Coś takiego sobie wydłubałem, zostawiam pro publico bono

#!/bin/bash

# sms2email.sh
#
# Requirements:
# installed bash
# installed jq-full
# installed sms_tool
# installed end configured mutt

#Config:
MODEM_DEV='/dev/ttyUSB1'
FILE_PROCESSED='/root/scripts/sms2email.processed'
EMAIL_RECIPIENT='my-email@gmail.com'
SMS_LIMIT=20

LOCK_FILE='/var/lock/sms2email.lock'

log(){
  msg="$1"
  echo "${msg}"
  logger -p "info" -t "sms2email.sh" "${msg}"
}

# DISABLE CONCURRENT
exec 200>"${LOCK_FILE}"
flock -n 200 || { log "Already running" >&2; exit 1; }
# shellcheck disable=SC2064
trap "flock -u 200; rm -f '${LOCK_FILE}'" EXIT

log "Script started"
sms_oldest_first="$(sms_tool -d "${MODEM_DEV}" -j -f '%Y-%m-%d %H:%M' recv | jq '.msg|sort_by(.timestamp)')"
readarray -t sms_array_oldest_first < <(echo "${sms_oldest_first}" | jq --compact-output '.[]')
for item in "${sms_array_oldest_first[@]}"; do
  index=$(jq --raw-output '.index' <<< "$item")
  sender=$(jq --raw-output '.sender' <<< "$item")
  timestamp=$(jq --raw-output '.timestamp' <<< "$item")
  content=$(jq --raw-output '.content' <<< "$item")

  if grep -q "^${index}\$" "${FILE_PROCESSED}"; then
    log "sms ${index} already processed"
  else
    body="${content}

[${sender} ${timestamp} ${index}]"
    echo "${body}" | mutt -s "SMS od: ${sender}" -- "${EMAIL_RECIPIENT}"
    echo "${index}" >> "${FILE_PROCESSED}"
    log "sms ${index} sent to email"
  fi
done

sms_newest_first="$(echo "${sms_oldest_first}" | jq 'reverse')"
readarray -t sms_array_newest_first < <(echo "${sms_newest_first}" | jq --compact-output '.[]')
counter=0
for item in "${sms_array_newest_first[@]}"; do
  counter=$((counter+1))
  index=$(jq --raw-output '.index' <<< "$item")
  sender=$(jq --raw-output '.sender' <<< "$item")
  timestamp=$(jq --raw-output '.timestamp' <<< "$item")
  content=$(jq --raw-output '.content' <<< "$item")

  if [[ "${counter}" -gt "${SMS_LIMIT}" ]]; then
    log "deleting sms ${index}"
    sms_tool -d "${MODEM_DEV}" delete "${index}"
    sed -i "/^${index}\$/d" "${FILE_PROCESSED}"
  fi
done

log "sms2email finished"

Jak działa opcja "Forward to E-mail"? Skonfigurowałem parametry, zaznaczyłem "Enable message forwarding". Pojawił się przycisk "Forward SMS", ale działa tyko na żądanie. Spodziewałem się, że będzie pracował w tle i forwardował SMSy po otrzymaniu. Coś źle skonfigurowałem, czy to tak nie działa? Jeżeli bibliotek nie przewiduje tego to może da się podpiąć jakoś pod EventHandler jak w smstools3?