diff options
author | Jonas Smedegaard <dr@jones.dk> | 2010-11-23 16:37:06 +0100 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2010-11-23 16:37:06 +0100 |
commit | a0ecbc456fba229e9db50e8713fc96a9f9345ebc (patch) | |
tree | e36b950ad0e7f7c58645692cba469dbe6873df45 /sms.d/phone | |
parent | 6d8d31a3656a622ab82a3b26c8d45d5026313993 (diff) |
Add/update phone entry in tekstfile.
Diffstat (limited to 'sms.d/phone')
-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 ;; |