diff options
-rwxr-xr-x | sms.d/phone | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sms.d/phone b/sms.d/phone index 4e08104..d63f632 100755 --- a/sms.d/phone +++ b/sms.d/phone @@ -15,10 +15,16 @@ export smtp=mail.bitbase.dk export from=hp@fossasia.org export sender="$from" +file=/var/www/vhosts/www-sms/sms.localnet/index.txt mail_subject="[sms] phone $sms_fromphone" mail_recipients="hp@fossasia.org mb@fossasia.org" doit() { + # Replace or append to phone list + perl -i -s -p \ + -e 's/^(\Q$number\E) .*/$1 $name/ and $seen++;' \ + -e '$_ .= "$number $name\n" if (eof and !$seen);' \ + -- -number="$sms_fromphone" -name="$msg" "$file" # Send message (...to stdout if invoked from cmdline) if [ -n "$sms_phone" ]; then mail -s "$mail_subject" $mail_recipients @@ -31,9 +37,11 @@ doit() { case "$app" in phone) cat <<EOF | doit -Someone at $sms_fromphone sent an sms to $sms_phone with keyword phone -and this message (supposedly his/her name): -$msg +Phone list auto-updated with this entry: + + $sms_fromphone $msg + +See the complete up-to-date phone list at http://sms.localhost/ EOF exit 1 ;; |