summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2012-07-03 23:51:58 +0200
committerFlorian Bruhin <me@the-compiler.org>2012-07-03 23:51:58 +0200
commit482ee9a01cfd790b21e1035a1a2a73aed0cb665c (patch)
tree757e34bc132b3127514e99d37fc20c27454328fa
downloadawaysms-482ee9a01cfd790b21e1035a1a2a73aed0cb665c.tar.gz
awaysms-482ee9a01cfd790b21e1035a1a2a73aed0cb665c.zip
Initial commit
-rwxr-xr-x_.awaysms78
-rwxr-xr-xlang/de.lang31
-rwxr-xr-xlang/en.lang31
-rwxr-xr-xpid1
-rw-r--r--procmailrc12
-rwxr-xr-xsetlang.sh78
-rwxr-xr-xsrc/addban.sh83
-rwxr-xr-xsrc/admin.sh142
-rwxr-xr-xsrc/getlang.sh57
-rwxr-xr-xsrc/limits.sh78
-rwxr-xr-xsrc/mail.sh124
-rwxr-xr-xsrc/query.sh191
-rwxr-xr-xsrc/readoptions.sh62
-rwxr-xr-xsrc/replies.sh67
-rwxr-xr-xsrc/send.sh129
-rwxr-xr-xsrc/setlang.sh77
-rwxr-xr-xsrc/sleep.sh37
-rwxr-xr-xsrc/smssend.pl123
-rwxr-xr-xsrc/todo1
19 files changed, 1402 insertions, 0 deletions
diff --git a/_.awaysms b/_.awaysms
new file mode 100755
index 0000000..cb40f2d
--- /dev/null
+++ b/_.awaysms
@@ -0,0 +1,78 @@
+#!/bin/bash
+
+###########################################################################
+# awaysms - .awaysms - awaysms configuration file #
+# Copyright (C) 2009 Florian Bruhin / The Compiler <me@the-compiler.org> #
+# #
+# .awaysms is a part of awaysms. #
+# awaysms is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+###########################################################################
+
+# SETTINGS
+limits="100 10 5 1" # Maximal amount of messages (month day hour minute)
+userlimits="30 10 5 1" # Maximal amount of messages per user (month day hour minute)
+notifydelay="300" # Delay between "I'm not here"-messages, seconds, 15 minutes here (FIXME maybe add a possibility for m/h suffixes)
+mailwait="30m" # The time awaysms waits for an answer
+
+# CLICKATELL
+clickatell_username="" # The username for clickatell
+clickatell_password="" # The password for clickatell
+clickatell_apikey="" # The html-api-key for clickatell
+clickatell_number="" # The number to send the messages to.
+
+# BASEDIR
+dir="$HOME/awaysms" # The awaysms basedir.
+
+mask="*!%IDENT%@%HOST%"
+#
+# Mess starts here, watch your step!
+#
+
+srcdir="$dir/src" # Where all our sources are.
+langdir="$dir/lang" # Where the languages are
+
+# LOGS
+logs="$dir/logs" # Where the logs are
+debug="$logs/debug" # the debuglog (verbose output)
+error="$logs/error" # the errorlog (mostly stderr of all scripts)
+messages="$logs/messages" # the messagelog (all the messages sent by the users)
+automessages="$logs/automessages" # the automessagelog (the automatically sent messages)
+
+# TEMPFILES
+lastmsg="$logs/lastmgs" # the last messages for each user (to use them with !sendlast)
+toolong="$logs/toolong" # the too long messages (to use them with !!send)
+replies="$dir/replies" # the reply-files
+pidfile="$dir/pid" # where the pid of sleep.sh should be stored
+mail="$dir/mail" # temporary location for the mail
+smssend="$logs/smssend" # the smssend log
+
+# RESSOURCES
+awayfile="$HOME/.irssi/away2web-status" # where the awayfile from irssi's away2web.pl is
+mailfile="/var/mail/florian" # where our mails are
+up="$dir/up" # the upfile, to decide if we're up and running or not
+lastnotify="$dir/lastnotify" # which users we notified at which time
+users="$dir/users" # the userfile
+
+
+# Create files and dirs which doesn't exist yet
+for i in "$dir" "$logs" "$replies"; do
+ [ ! -d "$i" ] && mkdir "$i"
+done
+
+for i in "$users" "$debug" "$error" "$mail" "$messages" "$automessages" "$up" "$lastnotify" "$smssend" "$lastmsg" "$toolong"; do
+ [ ! -f "$i" ] && touch "$i"
+done
+
+# DO NOT ADD AN EXIT HERE
+
diff --git a/lang/de.lang b/lang/de.lang
new file mode 100755
index 0000000..de4b75a
--- /dev/null
+++ b/lang/de.lang
@@ -0,0 +1,31 @@
+#!/bin/bash
+t_limits="Sorry, aber leider wurden einige Limiten überschritten, es kann keine SMS gesendet werden. Folgende Limiten wurden überschritten: %FAILLIMITS%"
+
+t_didntsendanytext="Du hast bisher noch keinen Text gesendet."
+
+t_lastsenttext="Der Text, den du zuletzt gesendet hast, war: %LASTTEXT%"
+
+t_help="Befehle:
+!send <Nachricht> - sende eine Nachricht zu mir (ohne < und >)
+!!send - Sende die Nachricht auch wenn sie zu lang war, und beschneide sie falls nötig.
+!sendlast - Sende den Text, den du mir zuletzt gesendet hattest.
+!viewlast - Zeige den Text, den du mir zuletzt gesendet hattest.
+!rules - Zeige die Regeln"
+
+t_rules="Fühle dich frei mir eine Nachricht über dieses System zu senden, wenn du irgendeine Frage an mich hast. Bitte nutze es aber nicht, um zu spammen, oder ich werde dich sperren. Ausserdem fasse bitte was du willst in einer Zeile kurz zusammen, ein 'ich brauche Hilfe' nützt mir nicht viel. Danke fürs Lesen."
+
+t_unknown_cmd="Unbekannter Befehl. Versuche !help"
+
+#t_away="Sorry, aber ich bin im Moment nicht da (%AWAYREASON%) - benutze !send <Nachricht> um mir eine Nachricht via SMS zu senden, oder !sendlast um mir die Nachricht zu senden, die du soeben gesendet hast. Vor dem Senden lese bitte mittels !rules die Regeln. Für weitere Hilfe nutze !help"
+
+t_away="Sorry, aber ich bin im Moment nicht da (%AWAYREASON%) - Falls du eine wichtige Nachricht an mich hast, schicke mir eine Mail an me@the-compiler.org"
+
+t_reply="[SMS-Antwort] %LINE%"
+
+t_toolong="Dein Text ist zu lang (%MSGLENGTH% Zeichen, aber es sind nur %MAXMSGLENGTH% erlaubt), bitte kürze ihn oder nutze !!send um ihn zu beschneiden und trotzdem zu senden."
+
+t_senderror="Leider ist während dem Senden ein interner Fehler aufgetreten, die Fehlernachricht ist: %ERROR%. Ich wurde automatisch über dieses Problem informiert."
+
+t_sent="Nachricht erfolgreich verschickt. Falls ich Zeit habe werde ich dir antworten."
+
+t_banned="Sorry, aber du wurdest vom System gesperrt. Spreche mich an, wenn ich online bin, falls du denkst dass du nicht gesperrt sein solltest."
diff --git a/lang/en.lang b/lang/en.lang
new file mode 100755
index 0000000..40a9985
--- /dev/null
+++ b/lang/en.lang
@@ -0,0 +1,31 @@
+#!/bin/bash
+t_limits="I'm sorry, but some limits are exceeded, no more sms can be sent. These limits were exceeded: %FAILLIMITS%"
+
+t_didntsendanytext="You didn't send any text yet."
+
+t_lastsenttext="Your last sent text was: %LASTTEXT%"
+
+t_help="Possible commands:
+!send <message> - send a message to me
+!!send - send the message even if too long, and if needed, truncate it.
+!sendlast - send the message you last sent, truncate it if needed
+!viewlast - view the last message you sent
+!rules - Show the rules"
+
+t_rules="Feel free to send me a message through this system if you have any question to me, e.g. about using my server, adding foobar to your chan, etc. Please don't use it to spam or flood me, or you will get banned. And please not notify me if foobar lags or quits, I'll get notified about that automatically. Also, please quickly describe what you want in one line/message, a 'please help me' doesn't really show what you want. Thanks for reading."
+
+t_unknown_cmd="Unknown command. Try !help"
+
+#t_away="Sorry, but I'm not here at the moment (%AWAYREASON%) - use !send <message> to send me a message via SMS or !sendlast to send me the message you just sent (please view the rules first using !rules). For further help use !help"
+
+t_away="Sorry, but I'm not here at the moment (%AWAYREASON%) - if you have something important to tell me, send me a mail to me@the-compiler.org"
+
+t_reply="[sms-reply] %LINE%"
+
+t_toolong="The text is too long (%MSGLENGTH% characters, but maximally %MAXMSGLENGTH% are allowed), please shorten it or use !!send to send it anyways and truncate it."
+
+t_sent="Message sucessfully sent. If I have time I'll respond via SMS."
+
+t_senderror="There was an internal error while sending the message, the errormessage was: %ERROR%. I'll automatically get notified about that."
+
+t_banned="I'm sorry, but you are banned. Ask me when I'm online if you believe you shouldn't be."
diff --git a/pid b/pid
new file mode 100755
index 0000000..8b13789
--- /dev/null
+++ b/pid
@@ -0,0 +1 @@
+
diff --git a/procmailrc b/procmailrc
new file mode 100644
index 0000000..1b0c62d
--- /dev/null
+++ b/procmailrc
@@ -0,0 +1,12 @@
+SHELL="/bin/sh"
+PMDIR="$HOME/.procmail"
+LOGFILE="$PMDIR/pmlog"
+LOG="
+"
+
+
+# * ^To:.*asms@gmx.ch
+
+:0
+*
+| ~/awaysms/src/mail.sh
diff --git a/setlang.sh b/setlang.sh
new file mode 100755
index 0000000..ecffad8
--- /dev/null
+++ b/setlang.sh
@@ -0,0 +1,78 @@
+#!/bin/bash
+
+###########################################################################
+# awaysms - setlang.sh - set the language for an user. #
+# Copyright (C) 2009 Florian Bruhin / The Compiler <me@the-compiler.org> #
+# #
+# setlang.sh is a part of awaysms. #
+# awaysms is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+###########################################################################
+
+# If avialable source the settings file, if not quit
+if [[ -f ~/.awaysms ]]; then
+ . ~/.awaysms
+else
+ exit 255
+fi
+
+echo "$(date +%H:%M:%S) [setlang.sh] We got launched." >> "$debug"
+
+# Storing the hostmask in $hostmask and cutting the host out of it
+hostmask="$1"
+setlang="$2"
+
+echo "$(date +%H:%M:%S) [setlang.sh] Our hostmask is $hostmask" >> "$debug"
+
+case "$hostmask" in
+ *\**|*\?*) # the host which should get banned already contains wildcards
+ mask="$hostmask"
+ echo "$(date +%H:%M:%S) [setlang.sh] The hostmask already contains wildcards, our mask is $mask" >> "$debug"
+ ;;
+ *)
+ nick=$(cut -d '!' -f 1 <<< "$hostmask")
+ ident=$(cut -d '!' -f 2 <<< "$hostmask" | cut -d '@' -f 1)
+ host=$(cut -d '@' -f 2 <<< "$hostmask")
+ echo "$(date +%H:%M:%S) [setlang.sh] Nick: $nick || Ident: $ident || Host: $host" >> "$debug"
+ mask=$(sed "s/%NICK%/$nick/g ; s/%IDENT%/$ident/g ; s/%USER%/$ident/g ; s/%HOST%/$host/g" <<< "$hostmask")
+ echo "$(date +%H:%M:%S) [setlang.sh] The hostmask doesn't contain wildcards, our mask is $mask" >> "$debug"
+ ;;
+esac
+
+# See if that user has already an entry or is even already banned
+echo "$(date +%H:%M:%S) [setlang.sh] Giving control to readoptions.sh" >> "$debug"
+opts=$("$srcdir/readoptions.sh" "$hostmask" "getlang")
+status="$?"
+echo "$(date +%H:%M:%S) [setlang.sh] Getting control by readoptions.sh with the options $opts and the status $status" >> "$debug"
+read line lang <<< "$opts"
+
+case "$status" in
+ 1) # no entry in the userfile yet
+ echo "$(date +%H:%M:%S) [setlang.sh] No entry in the userfile yet, adding a new one" >> "$debug"
+ echo "$mask - $setlang" >> "$users"
+ echo "$(date +%H:%M:%S) [setlang.sh] Exiting..." >> "$debug"
+ exit 0
+ ;;
+ 0) # already an entry for that user
+ echo "$(date +%H:%M:%S) [setlang.sh] already an entry in the file" >> "$debug"
+ # host options lang vvvvvv lang may or may not be there
+ sed -i "${line}s/\([^ ]* [^ ]*\)\( [^ ]*\)\{0,1\}/\1 $setlang/" "$users"
+ echo "$(date +%H:%M:%S) [setlang.sh] Exiting..." >> "$debug"
+ exit 0
+ ;;
+ *) # aka "WTF?"
+ echo "$(date +%H:%M:%S) [setlang.sh] Some weird exitstatus: $status..." >> "$debug"
+ echo "$(date +%H:%M:%S) [setlang.sh] Exiting..." >> "$debug"
+ exit 2
+ ;;
+esac
diff --git a/src/addban.sh b/src/addban.sh
new file mode 100755
index 0000000..ebd40fc
--- /dev/null
+++ b/src/addban.sh
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+###########################################################################
+# awaysms - addban.sh - add a ban for an user. #
+# Copyright (C) 2009 Florian Bruhin / The Compiler <me@the-compiler.org> #
+# #
+# addban.sh is a part of awaysms. #
+# awaysms is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+###########################################################################
+
+# If avialable source the settings file, if not quit
+if [[ -f ~/.awaysms ]]; then
+ . ~/.awaysms
+else
+ exit 255
+fi
+
+echo "$(date +%H:%M:%S) [addban.sh] We got launched." >> "$debug"
+
+# Storing the hostmask in $hostmask and cutting the host out of it
+hostmask="$1"
+
+echo "$(date +%H:%M:%S) [addban.sh] Our hostmask is $hostmask" >> "$debug"
+
+case "$hostmask" in
+ *\**|*\?*) # the host which should get banned already contains wildcards
+ mask="$hostmask"
+ echo "$(date +%H:%M:%S) [addban.sh] The hostmask already contains wildcards, our mask is $mask" >> "$debug"
+ ;;
+ *)
+ nick=$(cut -d '!' -f 1 <<< "$hostmask")
+ ident=$(cut -d '!' -f 2 <<< "$hostmask" | cut -d '@' -f 1)
+ host=$(cut -d '@' -f 2 <<< "$hostmask")
+ echo "$(date +%H:%M:%S) [addban.sh] Nick: $nick || Ident: $ident || Host: $host" >> "$debug"
+ mask=$(sed "s/%NICK%/$nick/g ; s/%IDENT%/$ident/g ; s/%USER%/$ident/g ; s/%HOST%/$host/g" <<< "$mask")
+ echo "$(date +%H:%M:%S) [addban.sh] The hostmask doesn't contain wildcards, our mask is $mask" >> "$debug"
+ ;;
+esac
+
+# See if that user has already an entry or is even already banned
+echo "$(date +%H:%M:%S) [addban.sh] Giving control to readoptions.sh" >> "$debug"
+opts=$("$srcdir/readoptions.sh" "$hostmask" "getban")
+status="$?"
+echo "$(date +%H:%M:%S) [addban.sh] Getting control by readoptions.sh with the options $opts and the status $status" >> "$debug"
+read line options <<< "$opts"
+
+case "$status" in
+ 1) # no entry in the userfile yet
+ echo "$(date +%H:%M:%S) [addban.sh] No entry in the userfile yet, adding a new one" >> "$debug"
+
+ echo "$mask ban" >> "$users"
+ echo "$(date +%H:%M:%S) [addban.sh] Exiting..." >> "$debug"
+ exit 0
+ ;;
+ 0) # already an entry for that user
+ echo "$(date +%H:%M:%S) [addban.sh] already an entry in the file" >> "$debug"
+ if [[ "$options" == *ban* ]]; then # already banned
+ echo "$(date +%H:%M:%S) [addban.sh] $hostmask already banned by: $(sed -n "${line}p" "$users")" >> "$debug"
+ echo "$(date +%H:%M:%S) [addban.sh] Exiting..." >> "$debug"
+ exit 1
+ else
+ echo "$(date +%H:%M:%S) [addban.sh] $hostmask not banned by: $(sed -n "${line}p" "$users") - adding ban to that line" >> "$debug"
+ sed -i "${line}s/\([^ ]* [^ ]*\)\(.*\)/\1,ban\2/" "$users"
+ echo "$(date +%H:%M:%S) [addban.sh] Exiting..." >> "$debug"
+ exit 0
+ fi
+ ;;
+ *) # aka "WTF?"
+ echo "$(date +%H:%M:%S) [addban.sh] ERROR: Some weird exitstatus: $status - exiting" | tee -a "$debug" >> "$error"
+ exit 2
+ ;;
+esac
diff --git a/src/admin.sh b/src/admin.sh
new file mode 100755
index 0000000..beb2ab2
--- /dev/null
+++ b/src/admin.sh
@@ -0,0 +1,142 @@
+#!/bin/bash
+
+###########################################################################
+# awaysms - admin.sh - admin interface for awaysms #
+# Copyright (C) 2009 Florian Bruhin / The Compiler <me@the-compiler.org> #
+# #
+# admin.sh is a part of awaysms. #
+# awaysms is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+###########################################################################
+
+# If available source the settings file, if not quit.
+if [[ -f ~/.awaysms ]]; then
+ . ~/.awaysms
+ echo "$(date +%H:%M:%S) [admin.sh]: settings loaded" >> "$debug"
+else
+ dialog --stdout --no-lines --backtitle "awaysms" --title "Fatal error" --msgbox "Fatal error: settings not found!" 0 0
+ exit 255
+fi
+
+
+# Endless loop as we want to show the dialog over and over again, and we'll just exit 0 if the user chooses exit
+while :; do
+ if [[ -z "$out" ]]; then # if we come back from the modes, we'll set out to the submenu so it doesn't show the main menu. So do that only if out is empty.
+ # Isn't the dialog syntax a bitch? ....
+ out=$(dialog --stdout --no-lines --cancel-label "Exit" --backtitle "awaysms" --title "Admin interface" --menu "" 0 0 0 "Users" "" "Logs" "" "Statistics" "" "Status" "")
+ status="$?" # do that just for the case we decide to do some debug output on some point.
+ case "$status" in
+ 1|255) exit 1 ;; # esc pressed or cancel choosen
+ esac
+ fi
+
+ case "$out" in
+ Users)
+ sed '/^\#.*/d;/^$/d' "$users" | while read line; do # the sed line deletes all comments (lines starting with #) and empty lines
+ read host other <<< "$line"
+ args="$args \"$host\" \"$other\""
+ echo "$args"
+ dialog --no-lines --msgbox "host: $host || other: $other || args: $args" 0 0
+ done
+
+ if [[ -z $(sed 's/ //g;s/"//g' <<< "$args") ]]; then # if args only has " and spaces in it (no users)
+ args="\"\" \"No users\""
+ fi
+
+ eval out2=\$\(dialog --stdout --no-lines --help-button --help-label "\"Add new user\"" --cancel-label "\"Back\"" --ok-label "\"Edit/Delete\"" --backtitle "\"awaysms\"" --title "\"Users\"" --menu "\"\"" 0 60 0 $args\)
+ status="$?" # do that just for the case we decide to do some debug output on some point.
+ args=
+
+ case "$status" in
+ 0) # Edit/Delete
+ dialog --stdout --no-lines --backtitle "awaysms" --title "Edit/Delete" --yes-button "Edit" --no-button "Delete" --yesno "$out2" 0 0
+ status="$?" # do that just for the case we decide to do some debug output on some point.
+ case "$status" in
+ 0) # Edit
+ # FIXME that part is a bitch.
+ ;;
+ 1) # Delete
+ dialog --stdout --no-lines --backtitle "awaysms" --title "Really delete?" --yesno "Are you sure you want to delete ${out2}?" 0 0 && sed -i "/$out2 .*/d" "$users" # the sed-line searches for the host-line in the userfile, then deletes it.
+ ;;
+ esac
+ ;;
+ 1|255) # Back / Escape
+ out=
+ ;;
+ 2) # Add new user
+ # FIXME that part is a bitch.
+ ;;
+ esac
+ ;;
+ Logs)
+ out2=$(dialog --stdout --no-lines --ok-label "View" --cancel-label "Back" --extra-button --extra-label "Delete" --backtitle "awaysms" --title "Logs" --menu "Please select a log" 0 0 0 "debug" "" "error" "" "messages" "" "automessages" "" "toolong" "" "lastmsg" "" "lastnotify" "" "replies" "")
+ # Exit status: 0 view, 3 delete, 1 back
+ status="$?"
+ eval file="\$$out2"
+
+ case $status in
+ 0) # view
+ dialog --stdout --no-lines --exit-label "back" --backtitle "awaysms" --title "$file" --textbox "$file" 0 0
+ ;;
+ 3) # delete
+ dialog --stdout --no-lines --backtitle "awaysms" --title "Really delete?" --yesno "Are you sure you want to delete ${file}?" 0 0
+ status="$?" # do that just for the case we decide to do some debug output on some point.
+ case "$status" in
+ 0) # Yes
+ [[ "$mode" = dir ]] && rm -r "$file" && mkdir "$file"
+ [[ "$mode" = file ]] && rm "$file" && touch "$file"
+ ;;
+ esac
+ ;;
+ 1|255) # back
+ out=
+ ;;
+ esac
+ case "$status" in 1|255) ;; *) out=Logs ;; esac
+ ;;
+ Statistics)
+ firstmessage=$(head -n 1 "$messages" | cut -d " " -f 2,3)
+ lastmessage=$(tail -n 1 "$messages" | cut -d " " -f 2,3)
+ messagecount=$(wc -l < "$messages")
+ firstautomessage=$(head -n 1 "$automessages" | cut -d " " -f 2,3)
+ lastautomessage=$(tail -n 1 "$automessages" | cut -d " " -f 2,3)
+ automessagecount=$(wc -l < "$automessages")
+ [[ "$messagecount" -ne 0 && "$firstmessage" != "$lastmessage" ]] && messagetext=", the first on $firstmessage and the last on $lastmessage." || messagetext="."
+ [[ "$messagecount" -ne 0 && "$firstmessage" = "$lastmessage" ]] && messagetext=", on $firstmessage." || messagetext="."
+ [[ "$automessagecount" -ne 0 ]] && automessagetext=", the first on $firstautomessage and the last on $lastautomessage." || automessagetext="."
+ [[ "$automessagecount" -ne 0 && "$firstautomessage" = "$lastautomessage" ]] && automessagetext=", on $firstautomessage." || automessagetext="."
+ dialog --stdout --no-lines --backtitle "awaysms" --title "$file" --msgbox "Totally $messagecount messages written$messagetext\n\nAditionally, totally $automessagecount automessages written$automessagetext" 0 0
+ out=
+ ;;
+ Status)
+ case $(<$up) in
+ 0)
+ dialog --stdout --no-lines --backtitle "awaysms" --title "$file" --yes-label "Ok" --no-label "Start it" --msgbox "asms is shut down." 0 0
+ status="$?"
+ case "$status" in 1) echo "1" > "$up" ;; esac
+ ;;
+ 1)
+ dialog --stdout --no-lines --backtitle "awaysms" --title "$file" --yes-label "Ok" --no-label "Stop it" --msgbox "asms is up and running" 0 0
+ status="$?"
+ case "$status" in 1) echo "0" > "$up" ;; esac
+ ;;
+ *)
+ dialog --stdout --no-lines --backtitle "awaysms" --title "$file" --yes-label "Ok" --no-label "Start it" --msgbox "undefined status in $up" 0 0
+ status="$?"
+ case "$status" in 1) echo "1" > "$up" ;; esac
+ ;;
+ esac
+ out=
+ ;;
+ esac
+done
diff --git a/src/getlang.sh b/src/getlang.sh
new file mode 100755
index 0000000..1992617
--- /dev/null
+++ b/src/getlang.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+###########################################################################
+# awaysms - getlang.sh - get the language of an user #
+# Copyright (C) 2009 Florian Bruhin / The Compiler <me@the-compiler.org> #
+# #
+# getlang.sh is a part of awaysms. #
+# awaysms is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+###########################################################################
+
+. ~/.awaysms
+host="$1"
+echo "$(date +%H:%M:%S) [getlang.sh]: Got loaded with the host $host." >> "$debug"
+
+# First attempt to get the language out of the userfile
+# get the options for the user
+echo "$(date +%H:%M:%S) [getlang.sh]: first trying to get the language out of the userfile, giving control to readoptions.sh now" >> "$debug"
+readoptions=$("$srcdir/readoptions.sh" "$host" 2>> "$error")
+echo "$(date +%H:%M:%S) [getlang.sh]: gained control back, exit status $? || readoptions: $readoptions" >> "$debug"
+
+# split options up
+echo "$(date +%H:%M:%S) [getlang.sh]: splitting options up" >> "$debug"
+read options lang <<< "$readoptions"
+echo "$(date +%H:%M:%S) [getlang.sh]: options: $options || lang: $lang" >> "$debug"
+
+if [[ -z "$lang" ]]; then # if the language wasn't set in the userfile
+ echo "$(date +%H:%M:%S) [getlang.sh]: The language wasn't set in the userfile, checking the host $host now." >> "$debug"
+ case "$host" in
+ *.init7.net|*.surfino.com|*.li-life.net|*.ch|*.li|*.at|*.de) lang="de" ;;
+ *) lang="en" ;;
+ esac
+else # we got the language out of the userfile
+ echo "$(date +%H:%M:%S) [getlang.sh]: Got the language out of the userfile w00t!" >> "$debug"
+fi
+
+echo "$(date +%H:%M:%S) [getlang.sh]: The host $host has hopefully the language $lang. Checking if it's existent!" >> "$debug"
+
+if [[ -f "$langdir/$lang.lang" ]]; then
+ echo "$(date +%H:%M:%S) [getlang.sh]: Alright, echoing the language $lang" >> "$debug"
+ echo "$lang"
+ exit 0
+else
+ echo "$(date +%H:%M:%S) [getlang.sh]: ERROR The language $lang doesn't exist, falling back to English!" | tee -a "$error" >> "$debug"
+ echo "en"
+ exit 1
+fi
diff --git a/src/limits.sh b/src/limits.sh
new file mode 100755
index 0000000..4a73462
--- /dev/null
+++ b/src/limits.sh
@@ -0,0 +1,78 @@
+#!/bin/bash
+
+###########################################################################
+# awaysms - limits.sh - get the limits for an user #
+# Copyright (C) 2009 Florian Bruhin / The Compiler <me@the-compiler.org> #
+# #
+# limits.sh is a part of awaysms. #
+# awaysms is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+###########################################################################
+
+# source the settings file.
+. ~/.awaysms
+
+# Storing $1 in $host as it's a bitch to use $1 all the time
+host="$1"
+
+echo "$(date +%H:%M:%S) [limits.sh]: loading and splitting limits" >> $debug
+
+# Do the following for "month, day, hour, minute", and use the counter to cut out the right part
+count=1
+for i in month day hour minute; do
+ limit[$i]=$(cut -d " " -f $count <<< "$limits")
+ userlimit[$i]=$(cut -d " " -f $count <<< "$userlimits")
+ count=$(( $count + 1 ))
+
+ # convert 1 month/day/hour/minute to seconds
+ case $i in
+ month) secs=2952000 ;; # 60 * 60 * 24 * 30 = 2'952'000
+ day) secs=86400 ;; # 60 * 60 * 24 = 84'000
+ hour) secs=3600 ;; # 60 * 60 = 3'600
+ minute) secs=60 ;; # 60 = 60
+ esac
+
+ # Count the usermessages
+ period=$(( $(date +%s) - $secs))
+ msgs=$(awk "\$1 > $period" "$messages")
+ usermsgs=$(awk "\$6 == \"$host\"" <<< "$msgs" | sed '/^$/d' | wc -l)
+ msgs=$(sed '/^$/d' <<< "$msgs" | wc -l)
+
+ # If we exceeded the limits, add it to the "faillimits" list and echo some debug output
+ if [[ "$usermsgs" -ge "${userlimit[$i]}" ]]; then
+ echo "$(date +%H:%M:%S) [limits.sh] ${i}userlimit NOT OK, [$usermsgs/${userlimit[$i]}] in ${secs}s." >> $debug
+ faillimits="$faillimits $i-userlimit"
+ else
+ echo "$(date +%H:%M:%S) [limits.sh] ${i}userlimit OK [$usermsgs/${userlimit[$i]}] in ${secs}s." >> $debug
+ fi
+
+ if [[ $msgs -ge ${limit[$i]} ]]; then
+ echo "$(date +%H:%M:%S) [limits.sh] ${i}limit NOT OK, [$msgs/${limit[$i]}] in ${secs}s." >> $debug
+ faillimits="$faillimits $i-globallimit"
+ else
+ echo "$(date +%H:%M:%S) [limits.sh] ${i}limit OK [$msgs/${limit[$i]}] in ${secs}s." >> $debug
+ fi
+done
+
+if [[ "$faillimits" ]]; then
+ echo "$(date +%H:%M:%S) [limits.sh] faillimits: $faillimits, thus reading the language from getlang." >> $debug
+ lang=$("$srcdir/getlang.sh" "$host")
+ echo "$(date +%H:%M:%S) [limits.sh] Got the control back by getlang." >> $debug
+ echo "$(date +%H:%M:%S) [limits.sh] language: $lang" >> $debug
+ . "$langdir/$lang.lang"
+ t_limits=$(sed "s/%FAILLIMITS%/$faillimits/g" <<< "$t_limits")
+ echo "$t_limits"
+ exit 1
+else
+ exit 0
+fi
diff --git a/src/mail.sh b/src/mail.sh
new file mode 100755
index 0000000..0314a9e
--- /dev/null
+++ b/src/mail.sh
@@ -0,0 +1,124 @@
+#!/bin/bash
+
+###########################################################################
+# awaysms - mail.sh - process incoming mails #
+# Copyright (C) 2009 Florian Bruhin / The Compiler <me@the-compiler.org> #
+# #
+# mail.sh is a part of awaysms. #
+# awaysms is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+###########################################################################
+
+# Source the settings
+. ~/.awaysms
+
+# Open the logfile
+echo "" >> "$debug"
+echo "===== LOG OPENED at $(date -R) by mail.sh ====" >> "$debug"
+echo "$(date +%H:%M:%S) [mail.sh]: We got launched." >> "$debug"
+
+# Save the mail into a file
+
+echo "$(date +%H:%M:%S) [mail.sh]: Saving the mail in $mail." >> "$debug"
+cat > "$mail"
+
+# We don't want to get nasty SMS' for spam, do we?
+# This is only for Sunrise of course, you might want to change it a bit for your hoster.
+# FIXME make this a setting?
+echo "$(date +%H:%M:%S) [mail.sh]: Checking if the mail was sent from the mobile phone (number: $clickatell_number)" >> "$debug"
+if grep -q "From: ${clickatell_number}@gsm.sunrise.ch" "$mail" && grep -q 'Subject: Mail from a mobile phone' "$mail"; then
+ echo "$(date +%H:%M:%S) [mail.sh]: Test passed." >> "$debug"
+else
+ echo "$(date +%H:%M:%S) [mail.sh]: Test failed." >> "$debug"
+ exit 1
+fi
+
+
+# the text should be everything between "--- Start message ---" and "--- End message ---", then remove the first two and the last two lines
+# We could use sed '1,/^$/d' but as sunrise adds some crap to the mails anyway it's easier like this.
+text=$(sed -n '/--- Start message ---/,/--- End message ---/p' "$mail" | sed '1,2d;N;$!P;$!D;$d')
+
+echo "$(date +%H:%M:%S) [mail.sh]: modified mail: $text" >> "$debug"
+
+# First word in the sms is the command
+cmd=$(cut -d " " -f 1 <<< "$text")
+echo "$(date +%H:%M:%S) [mail.sh]: Command: $cmd" >> "$debug"
+
+case "$cmd" in
+ r|re|reply) # reply to a message just sent
+ echo "$(date +%H:%M:%S) [mail.sh]: The user wants to reply to a message" >> "$debug"
+
+ # If we use an id, the second argument should be it.
+ id=$(cut -d " " -f 2 <<< "$text") # hopefully that's the id
+ echo "$(date +%H:%M:%S) [mail.sh]: PROBABLY our id is $id" >> "$debug"
+
+ if [ -z "$id" ]; then # no text at all
+ echo "$(date +%H:%M:%S) [mail.sh]: Ouch, our id is empty... Sending an error back." >> "$debug"
+ echo "$(date +%H:%M:%S) [mail.sh]: Giving the control to send.sh" >> "$debug"
+ "$srcdir/send.sh" "auto" "" "mail.sh!mail.sh@mail.sh" "Error: no id specified." 2>> "$error"
+ echo "$(date +%H:%M:%S) [mail.sh]: Got the control back by send.sh" >> "$debug"
+ echo "$(date +%H:%M:%S) [mail.sh]: Exiting with the exitstatus 1.." >> "$debug"
+ exit 1
+ fi
+
+ # FIXME maybe use [[ ]] here instead? Ask wouter for more maybe.
+ if grep -q '[0-9]\+' <<< "$id"; then # if it's another amount of digits make three out of it.
+ text=$(cut -d " " -f 3- <<< "$text")
+ echo "$(date +%H:%M:%S) [mail.sh]: Our id is another number, so we're making $id out of it, our text is: $text" >> "$debug"
+ else # if there's another thing (not an id) then reply to the last message
+ text=$(cut -d " " -f 2- <<< "$text")
+
+ # forth field of she last line in the msglog
+ id=$(tail -n 1 "$messages" | cut -d " " -f 4)
+ echo "$(date +%H:%M:%S) [mail.sh]: Our id isn't a number at all, so we got $id out of the msglog, our text is: $text" >> "$debug"
+ fi
+
+ if [ -z "$text" ]; then # we got an id, but no text. ARGH!
+ echo "$(date +%H:%M:%S) [mail.sh]: Ouch, no text... Sending an error back." >> "$debug"
+ echo "$(date +%H:%M:%S) [mail.sh]: Giving the control to send.sh" >> "$debug"
+ "$srcdir/send.sh" "auto" "" "mail.sh!mail.sh@mail.sh" "Error: no text specified." 2>> "$error"
+ echo "$(date +%H:%M:%S) [mail.sh]: Got the control back by send.sh" >> "$debug"
+ echo "$(date +%H:%M:%S) [mail.sh]: Exiting with the exitstatus 1.." >> "$debug"
+ exit 1
+ fi
+
+ # adding the text to the replyfile
+ echo "$(date +%H:%M:%S) [mail.sh]: replies is >$replies< and id is >$id<" >> "$debug"
+ echo "$text" >> "$replies/$id"
+ ;;
+ h|help) # Help-Test
+ echo "$(date +%H:%M:%S) [mail.sh]: The user wants some help" >> "$debug"
+ echo "$(date +%H:%M:%S) [mail.sh]: Giving the control to send.sh" >> "$debug"
+ "$srcdir/send.sh" "auto" "" "mail.sh!mail.sh@mail.sh" "r <id> - reply / h - help" 2>> "$error"
+ echo "$(date +%H:%M:%S) [mail.sh]: Got the control back by send.sh" >> "$debug"
+ ;;
+ ping) # small silly ping test
+ echo "$(date +%H:%M:%S) [mail.sh]: Let's play some pingpong" >> "$debug"
+ echo "$(date +%H:%M:%S) [mail.sh]: Giving the control to send.sh" >> "$debug"
+ "$srcdir/send.sh" "auto" "" "mail.sh!mail.sh@mail.sh" "pong" 2>> "$error"
+ echo "$(date +%H:%M:%S) [mail.sh]: Got the control back by send.sh" >> "$debug"
+ ;;
+ *) # Unknown command
+ echo "$(date +%H:%M:%S) [mail.sh]: The command $cmd seems to be unknown. Notifying the user about it." >> "$debug"
+ echo "$(date +%H:%M:%S) [mail.sh]: Giving the control to send.sh" >> "$debug"
+ "$srcdir/send.sh" "auto" "" "mail.sh!mail.sh@mail.sh" "Error: unknown command: $cmd" 2>> "$error"
+ echo "$(date +%H:%M:%S) [mail.sh]: Got the control back by send.sh" >> "$debug"
+ ;;
+esac
+
+# Now we can remove the mail
+echo "$(date +%H:%M:%S) [mail.sh]: Removing the mail $mail." >> "$debug"
+rm "$mail"
+
+echo "$(date +%H:%M:%S) [mail.sh]: Exiting.." >> "$debug"
+exit 0
diff --git a/src/query.sh b/src/query.sh
new file mode 100755
index 0000000..093d9fc
--- /dev/null
+++ b/src/query.sh
@@ -0,0 +1,191 @@
+#!/bin/bash
+
+###########################################################################
+# awaysms - query.sh - process queries #
+# Copyright (C) 2009 Florian Bruhin / The Compiler <me@the-compiler.org> #
+# #
+# query.sh is a part of awaysms. #
+# awaysms is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+###########################################################################
+
+# If available source the settings file, if not quit.
+if [[ -f ~/.awaysms ]]; then
+ . ~/.awaysms
+ echo "$(date +%H:%M:%S) [query.sh]: settings loaded" >> "$debug"
+else
+ exit 255
+fi
+
+echo "" >> "$debug"
+echo "===== LOG OPENED at $(date -R) by query.sh ====" >> "$debug"
+
+
+echo "$(date +%H:%M:%S) [query.sh]: Checking the upfile $up" >> "$debug"
+case $(<"$up") in
+ 0)
+ echo "$(date +%H:%M:%S) [query.sh]: The upstatus is 0, exiting." >> "$debug"
+ exit 3
+ ;;
+ 1)
+ echo "$(date +%H:%M:%S) [query.sh]: We're up and running" >> "$debug"
+ ;;
+ *)
+ echo "$(date +%H:%M:%S) [query.sh]: Warning: undefinied upstatus" >> "$debug"
+ ;;
+esac
+
+server="$1"
+host="$2"
+text="$3"
+
+# Escape the host so sed and grep don't choke on it
+# \ \\ ; \; / \/ * \* . \. ^ \^ [ \[ ] \]
+eschost=$(sed -e 's/\\/\\\\/g ; s/\;/\\;/g ; s|/|\\/|g ; s/\*/\\*/g ; s/\./\\./g ; s/\^/\\^/g ; s/\[/\\[/g ; s/\]/\\]/g' <<< "$host")
+
+# Some debug output...
+echo "$(date +%H:%M:%S) [query.sh]: server: $server || host: $host || text: $text || eschost: $eschost" >> "$debug"
+
+# Exit if the away2web file doesn't exist
+if [[ ! -e "$awayfile" ]]; then
+ echo "$(date +%H:%M:%S) [query.sh]: awayfile $awayfile doesn't exist. Aborting." >> "$debug"
+ exit 2
+else
+ echo "$(date +%H:%M:%S) [query.sh]: awayfile $awayfile exists." >> "$debug"
+fi
+
+# If we aren't away exit
+echo "$(date +%H:%M:%S) [query.sh]: checking away status" >> "$debug"
+awaystatus=$(head -n 1 "$awayfile")
+if [[ "$awaystatus" -eq 1 ]]; then
+ echo "$(date +%H:%M:%S) [query.sh]: awaystatus is $awaystatus - not away. Aborting." >> "$debug"
+ exit 1
+else
+ echo "$(date +%H:%M:%S) [query.sh]: awaystatus is $awaystatus - away." >> "$debug"
+fi
+
+# Get the awayreason
+echo "$(date +%H:%M:%S) [query.sh]: reading away-reason" >> "$debug"
+awayreason=$(tail -n 1 "$awayfile")
+echo "$(date +%H:%M:%S) [query.sh]: away-reason is: $awayreason" >> "$debug"
+
+# get the options for the user
+echo "$(date +%H:%M:%S) [query.sh]: giving control to readoptions.sh now" >> "$debug"
+readoptions=$("$srcdir/readoptions.sh" "$host" 2>> "$error")
+echo "$(date +%H:%M:%S) [query.sh]: gained control back, exit status $? || readoptions: $readoptions" >> "$debug"
+
+# split options up
+echo "$(date +%H:%M:%S) [query.sh]: splitting options up now" >> "$debug"
+read options number <<< "$readoptions"
+echo "$(date +%H:%M:%S) [query.sh]: options: $options || lang: $lang" >> "$debug"
+
+case "$options" in
+ *ignore*)
+ echo "$(date +%H:%M:%S) [query.sh]: Bleh, we got the user on ignore, let's get outta here!" >> "$debug"
+ exit 4
+ ;;
+esac
+
+# Source the langfile
+echo "$(date +%H:%M:%S) [query.sh] Giving the control to getlang" >> $debug
+lang=$("$srcdir/getlang.sh" "$host")
+echo "$(date +%H:%M:%S) [query.sh] Got the control back by getlang." >> $debug
+echo "$(date +%H:%M:%S) [query.sh] language: $lang" >> $debug
+. "$langdir/$lang.lang"
+
+# check what the user wants to do
+echo "$(date +%H:%M:%S) [query.sh]: now checking the text: >$text<" >> "$debug"
+case "$text" in
+ \!send\ *) # send something
+ echo "$(date +%H:%M:%S) [query.sh]: The user wants to send something. Giving control to send.sh now." >> "$debug"
+ case "$text" in \!\!send\ *) options="$options,truncate" ;; esac
+ text=$(sed 's/^!*send //' <<< "$text")
+ "$srcdir/send.sh" "$options" "$server" "$host" "$text" 2>> "$error"
+ echo "$(date +%H:%M:%S) [query.sh]: Got control back from send.sh." >> "$debug"
+ ;;
+ \!\!send)
+ echo "$(date +%H:%M:%S) [query.sh]: The user wants to send anyways." >> "$debug"
+ lasttext=$(grep "$host .*" "$toolong" | cut -d " " -f 2)
+
+ if [[ "$lasttext" ]]; then
+ "$srcdir/send.sh" "$options,truncate" "$server" "$host" "$lasttext" 2>> "$error"
+ elif [[ -z "$lasttext" ]]; then
+ echo "$t_didntsendanytext"
+ fi
+ ;;
+ \!sendlast|\!viewlast) # send/view last text
+ echo "$(date +%H:%M:%S) [query.sh]: The user wants to send his last text." >> "$debug"
+ lasttext=$(grep "$host .*" "$lastmsg" | cut -d " " -f 2)
+
+ if [[ "$lasttext" && "$text" = \!viewlast ]]; then
+ t_lastsenttext=$(sed "s/%LASTTEXT%/$lasttext/g" <<< "$t_lastsenttext")
+ echo "$t_lastsenttext"
+ elif [[ "$lasttext" && "$text" = \!sendlast ]]; then
+ "$srcdir/send.sh" "$options,truncate" "$server" "$host" "$lasttext" 2>> "$error"
+ elif [[ -z "$lasttext" ]]; then
+ echo "$t_didntsendanytext"
+ fi
+ ;;
+ \!help) # help
+ echo "$(date +%H:%M:%S) [query.sh]: The user wanted some help, aye." >> "$debug"
+ echo "$t_help"
+ ;;
+ \!rules) # rules
+ echo "$(date +%H:%M:%S) [query.sh]: Wow, someone is actually reading the rules :O" >> "$debug"
+ echo "$t_rules"
+ ;;
+ \!lang*) # set the language
+ echo "$(date +%H:%M:%S) [query.sh]: Someone wants to set their language" >> "$debug"
+ echo "$(date +%H:%M:%S) [query.sh]: Giving control to setlang.sh now." >> "$debug"
+ text=$(sed 's/^!lang //' <<< "$text")
+ "$srcdir/setlang.sh" "$host" "$text" 2>> "$error"
+ echo "$(date +%H:%M:%S) [query.sh]: Got control back from setlang.sh, exit status $?" >> "$debug"
+ ;;
+ \!gofuckyourself*)
+ echo "In your face."
+ ;;
+ \!*) # unknown command
+ echo "$(date +%H:%M:%S) [query.sh]: The command $text was unknown or wrong used." >> "$debug"
+ echo "$t_unknown_cmd"
+ ;;
+ *) # normal text
+ echo "$(date +%H:%M:%S) [query.sh]: $text seems to be a normal text, giving the user my awaymessage." >> "$debug"
+
+ echo "$(date +%H:%M:%S) [query.sh]: Adding the line '$host $text' to the file $lastmsg" >> "$debug"
+ sed -i "/$eschost .*/d" "$lastmsg" # Delete old lines by this user
+ echo "$host $text" >> "$lastmsg"
+
+ # Only give the awaymessage if the user wasn't notified in the last $notifydelay seconds
+ echo "$(date +%H:%M:%S) [query.sh]: Check if the user was already notified." >> "$debug"
+
+ # The epoche now
+ time=$(date +%s)
+ # The timespan where notifies were
+ timespan=$(($time - $notifydelay))
+ # The count of messages in that period
+ msgcount=$(awk "\$2 == \"$host\" && \$1 > $timespan" "$lastnotify")
+ echo "$(date +%H:%M:%S) [query.sh]: time: $time || notifydelay: $notifydelay || timespan: $timespan || msgcount: $msgcount" >> "$debug"
+
+ if [[ -z "$msgcount" ]]; then
+ echo "$(date +%H:%M:%S) [query.sh]: Allright, no notify yet, notifying and changing adding the line $(date +%s) $host to the file $lastnotify." >> "$debug"
+ t_away=$(sed "s/%AWAYREASON%/$awayreason/g" <<< "$t_away")
+ echo "$t_away"
+ sed -i "/.* $eschost/d" "$lastnotify" # Delete old lines by this user
+ echo "$(date +%s) $host" >> "$lastnotify"
+ fi
+ ;;
+esac
+
+
+echo "$(date +%H:%M:%S) [query.sh]: We did what we had to do, exiting." >> "$debug"
+exit 0
diff --git a/src/readoptions.sh b/src/readoptions.sh
new file mode 100755
index 0000000..2302a00
--- /dev/null
+++ b/src/readoptions.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+###########################################################################
+# awaysms - readoptions.sh - read the options for an user #
+# Copyright (C) 2009 Florian Bruhin / The Compiler <me@the-compiler.org> #
+# #
+# readoptions.sh is a part of awaysms. #
+# awaysms is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+###########################################################################
+
+# source the settings file
+. ~/.awaysms
+echo "$(date +%H:%M:%S) [readoptions.sh]: settings loaded" >> "$debug"
+
+# storing host in $host
+host="$1"
+args="$2"
+
+# Escape the host so the pathname expansion doesn't choke on it
+# [ \[ ] \]
+eschost=$(sed 's/\[/\\[/g ; s/\]/\\]/g' <<< "$host")
+
+echo "$(date +%H:%M:%S) [readoptions.sh]: reading userfile: $users" >> "$debug"
+
+# The first sed deletes all lines which begin with an # (comments), and all empty lines.
+# The second sed numbers the lines
+# The third line puts the numbers left of the lines
+# The read -r splits the line up in number, pattern, options and language.
+sed '/^\#.*/d;/^$/d' "$users" | sed '=' | sed 'N;s/\n/ /' | while read -r number pattern options lang; do
+ # we don't care about [ and ] in the pattern, so lets escape 'em.
+ # [ \[ ] \]
+ escpattern=$(sed 's/\[/\\[/g ; s/\]/\\]/g' <<< "$pattern")
+
+ # if the pattern matches...
+ if [[ "$host" = $escpattern ]]; then
+ case "$args" in
+ getban) echo "$number" "$options" ;;
+ getlang) echo "$number" "$lang" ;;
+ *) mode=normal; echo "$options" "$lang" ;;
+ esac
+ match=yes
+ else
+ match=no
+ fi
+ echo "$(date +%H:%M:%S) [readoptions.sh]: number: $number || pattern: $pattern || options: $options || lang: $lang || host: $host || args: $args || match: $match" >> "$debug"
+ # This only exits the while-subshell
+ [[ "$match" = yes ]] && exit 0
+done
+status="$?"
+[[ "$status" = 1 ]] && echo "$(date +%H:%M:%S) [readoptions.sh]: no pattern matched to host $host - exiting" >> "$debug"
+exit "$status"
diff --git a/src/replies.sh b/src/replies.sh
new file mode 100755
index 0000000..58be8ce
--- /dev/null
+++ b/src/replies.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+###########################################################################
+# awaysms - replies.sh - process replies to an user #
+# Copyright (C) 2009 Florian Bruhin / The Compiler <me@the-compiler.org> #
+# #
+# replies.sh is a part of awaysms. #
+# awaysms is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+###########################################################################
+
+# If available source the settings file, if not quit
+. ~/.awaysms
+
+# Store the id in $1 as it's a bitch to use $1 all the time
+id="$1"
+host="$2"
+
+echo "$(date +%H:%M:%S) [replies.sh]: We got launched with the id $id." >> "$debug"
+
+# Source the langfile
+# FIXME we don't even got the host here :O
+echo "$(date +%H:%M:%S) [replies.sh] Giving the control to getlang" >> $debug
+lang=$("$srcdir/getlang.sh" "$host")
+echo "$(date +%H:%M:%S) [replies.sh] Got the control back by getlang." >> $debug
+echo "$(date +%H:%M:%S) [replies.sh] language: $lang" >> $debug
+. "$langdir/$lang.lang"
+
+echo "$(date +%H:%M:%S) [replies.sh]: Starting sleep.sh." >> "$debug"
+
+# Sleep.sh will die after some seconds, then tail -f will die too as we gave it the pid of sleep.sh# Sleep.sh will die after some seconds, then tail -f will die too as we gave it the pid of sleep.sh# Sleep.sh will die after some seconds, then tail -f will die too as we gave it the pid of sleep.sh
+"$srcdir/sleep.sh" 2>> "$error" &
+
+# Create the reply file (which shouldn't exist yet anyways!)
+[ ! -e "$replies/$id" ] && touch "$replies/$id" && echo "$(date +%H:%M:%S) [replies.sh]: $replies/$id didn't exist yet, created." >> "$debug"
+
+sleep 1 # to make sure the pidfile is created
+
+pid=$(<"$pidfile")
+echo "$(date +%H:%M:%S) [replies.sh]: Reading replies, id $id, pid $pid" >> "$debug"
+
+# The tail will die as soon as sleep.sh dies.
+tail -f --pid="$pid" "$replies/$id" | while read line; do
+ # If we read an answer, echo it to the log, and to the shell.
+ echo "$(date +%H:%M:%S) [replies.sh]: replyline: $line." >> "$debug"
+ t_reply=$(echo "$t_reply" | sed "s/%LINE%/$line/g")
+ echo "$t_reply"
+done
+
+echo "$(date +%H:%M:%S) [replies.sh]: The pid $pid got killed, deleting replies for $id and commiting suicide!" >> "$debug"
+
+# Remove the pidfile
+echo "$(date +%H:%M:%S) [replies.sh]: Removing $replies/$id" >> "$debug"
+rm "$replies/$id"
+
+echo "$(date +%H:%M:%S) [replies.sh]: Exiting." >> "$debug"
+exit 0
diff --git a/src/send.sh b/src/send.sh
new file mode 100755
index 0000000..e60ba88
--- /dev/null
+++ b/src/send.sh
@@ -0,0 +1,129 @@
+#!/bin/bash
+
+###########################################################################
+# awaysms - send.sh - actually send the message #
+# Copyright (C) 2009 Florian Bruhin / The Compiler <me@the-compiler.org> #
+# #
+# send.sh is a part of awaysms. #
+# awaysms is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+###########################################################################
+
+. ~/.awaysms
+echo "$(date +%H:%M:%S) [send.sh]: settings loaded" >> "$debug"
+
+# Use some nicer variables as it's a bitch to use $1, $2, etc.
+options="$1"
+server="$2"
+host="$3"
+text="$4"
+
+echo "$(date +%H:%M:%S) [send.sh]: options: $options || server: $server || host: $host || text: $text" >> "$debug"
+
+# Source the langfile
+echo "$(date +%H:%M:%S) [send.sh] Giving the control to getlang" >> $debug
+lang=$("$srcdir/getlang.sh" "$host")
+echo "$(date +%H:%M:%S) [send.sh] Got the control back by getlang." >> $debug
+echo "$(date +%H:%M:%S) [send.sh] language: $lang" >> $debug
+. "$langdir/$lang.lang"
+
+
+nicklength=$(cut -d '!' -f 1 <<< "$host" | wc -m)
+maxmsglength=$((155-$nicklength)) # Format: <nnn> <nick> <message>, 160 chars available per SMS, minus 5 for the number and spaces, minus nicklength
+msglength=$(wc -m <<< "$text")
+
+if [[ "$msglength" -gt "$maxmsglength" ]]; then
+ case "$options" in
+ *truncate*|*auto*)
+ echo "$(date +%H:%M:%S) [send.sh]: Truncating the message to $maxmsglength chars." >> "$debug"
+ text=$(cut -c -"$maxmsglength" <<< "$text")
+ ;;
+ *)
+ t_toolong=$(sed "s/%MSGLENGTH%/$msglength/g;s/%MAXMSGLENGTH%/$maxmsglength/g" <<< "$t_toolong")
+ echo "$t_toolong"
+
+ echo "$(date +%H:%M:%S) [send.sh]: Adding the line '$host $text' to the file $toolong" >> "$debug"
+ sed -i "/$host .*/d" "$toolong" # Delete old lines by this user
+ echo "$host $text" >> "$toolong"
+ exit 3
+ ;;
+ esac
+fi
+
+case "$options" in
+ *nolimit*|*auto*)
+ echo "$(date +%H:%M:%S) [send.sh]: The user has nolimits on." >> "$debug"
+ ;;
+ *ban*) # exit if we're banned
+ echo "$(date +%H:%M:%S) [send.sh]: The user is banned, exiting." >> "$debug"
+ echo "$t_banned"
+ exit 2
+ ;;
+ *)
+ echo "$(date +%H:%M:%S) [send.sh]: Giving control to limits.sh." >> "$debug"
+ "$srcdir/limits.sh" "$host" 2>> "$error"
+ limitstatus="$?"
+ echo "$(date +%H:%M:%S) [send.sh]: got control back from limits.sh - limitstatus: $limitstatus." >> "$debug"
+ ;;
+esac
+
+case "$limitstatus" in
+ 1)
+ echo "$(date +%H:%M:%S) [send.sh]: As we exceeded some limits, exiting." >> "$debug"
+ exit 1
+ ;;
+esac
+
+nick=$(cut -d '!' -f 1 <<< "$host")
+# Check the last number
+case "$options" in
+ *auto*)
+ id="---"; auto=1
+ echo "$(date "+%s %d.%m.%y %H:%M:%S") $text" >> "$automessages" # <epoche> <dd.mm.yy> <hh:mm:ss> <message>
+ ;;
+ *)
+ number=$(tail -n 1 "$messages" | cut -d " " -f 4) # id of the last line in the msglog
+ case "$number" in
+ "") # the msglog is empty
+ id="0"
+ ;;
+ *)
+ id=$(( $number + 1 ))
+ ;;
+ esac
+ echo "$(date +%H:%M:%S) [send.sh]: The last id was $number so the new one is $id." >> "$debug"
+ echo "$(date "+%s %d.%m.%y %H:%M:%S") $id $server $host $text" >> "$messages" # <epoche> <dd.mm.yy> <hh:mm:ss> <id> <server> <host> <message>
+ ;;
+esac
+
+# Send the message
+# out=$("$srcdir/smssend.pl" -u "$clickatell_username" -p "$clickatell_password" -a "$clickatell_apikey" -m "$id <$nick> $text" -t "$clickatell_number" | tee -a "$smssend" 2>&1)
+out="Sorry, but the message wasn't sent as I got a new cellphone and gotta change some things in awaysms. Until I did that simply send a mail to me@the-compiler.org and I'll get your message to my phone || Sorry, deine Nachricht wurde nicht gesendet, da ich ein neues Handy habe und deshalb einige Dinge an awaysms erst ändern muss. Bis ich das getan habe, schreibe einfach ein Mail an me@the-compiler.org und ich werde deine Nachricht aufs Handy bekommen."
+# Check the output
+case "$out" in
+ "Message sent")
+ echo "$(date +%H:%M:%S) [send.sh]: Message sucessfully sent." >> "$debug"
+ # Let the user know the message was sent if "auto" isn't set.
+ [[ "$auto" != 1 ]] && echo "$t_sent"
+ ;;
+ *)
+ t_senderror=$(sed "s/%ERROR%/$out/g" <<< "$t_senderror")
+ # Gonna spam the logs WOHOO.
+ echo "$(date +%H:%M:%S) [send.sh]: ERROR There was an error while sending the message: $out" | tee -a "$debug" >> "$error"
+ # Let the user know about the error if "auto" isn't set.
+ [[ "$auto" != 1 ]] && echo "$t_senderror"
+ ;;
+esac
+
+# Wait for replies if "auto" isn't set.
+[ "$auto" != 1 ] && "$srcdir/replies.sh" "$id" "$host" 2>> "$error"
diff --git a/src/setlang.sh b/src/setlang.sh
new file mode 100755
index 0000000..ef2f875
--- /dev/null
+++ b/src/setlang.sh
@@ -0,0 +1,77 @@
+#!/bin/bash
+
+###########################################################################
+# awaysms - setlang.sh - set the language for an user. #
+# Copyright (C) 2009 Florian Bruhin / The Compiler <me@the-compiler.org> #
+# #
+# setlang.sh is a part of awaysms. #
+# awaysms is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+###########################################################################
+
+# If avialable source the settings file, if not quit
+if [[ -f ~/.awaysms ]]; then
+ . ~/.awaysms
+else
+ exit 255
+fi
+
+echo "$(date +%H:%M:%S) [setlang.sh] We got launched." >> "$debug"
+
+# Storing the hostmask in $hostmask and cutting the host out of it
+hostmask="$1"
+setlang="$2"
+
+echo "$(date +%H:%M:%S) [setlang.sh] Our hostmask is $hostmask" >> "$debug"
+
+case "$hostmask" in
+ *\**|*\?*) # the host which should get banned already contains wildcards
+ mask="$hostmask"
+ echo "$(date +%H:%M:%S) [setlang.sh] The hostmask already contains wildcards, our mask is $mask" >> "$debug"
+ ;;
+ *)
+ nick=$(cut -d '!' -f 1 <<< "$hostmask")
+ ident=$(cut -d '!' -f 2 <<< "$hostmask" | cut -d '@' -f 1)
+ host=$(cut -d '@' -f 2 <<< "$hostmask")
+ echo "$(date +%H:%M:%S) [setlang.sh] Nick: $nick || Ident: $ident || Host: $host" >> "$debug"
+ mask=$(sed "s/%NICK%/$nick/g ; s/%IDENT%/$ident/g ; s/%USER%/$ident/g ; s/%HOST%/$host/g" <<< "$mask")
+ echo "$(date +%H:%M:%S) [setlang.sh] The hostmask doesn't contain wildcards, our mask is $mask" >> "$debug"
+ ;;
+esac
+
+# See if that user has already an entry or is even already banned
+echo "$(date +%H:%M:%S) [setlang.sh] Giving control to readoptions.sh" >> "$debug"
+opts=$("$srcdir/readoptions.sh" "$hostmask" "getlang")
+status="$?"
+echo "$(date +%H:%M:%S) [setlang.sh] Getting control by readoptions.sh with the options $opts and the status $status" >> "$debug"
+read line lang <<< "$opts"
+
+case "$status" in
+ 1) # no entry in the userfile yet
+ echo "$(date +%H:%M:%S) [setlang.sh] No entry in the userfile yet, adding a new one" >> "$debug"
+
+ echo "$mask - $setlang" >> "$users"
+ echo "$(date +%H:%M:%S) [setlang.sh] Exiting..." >> "$debug"
+ ;;
+ 0) # already an entry for that user
+ echo "$(date +%H:%M:%S) [setlang.sh] already an entry in the file" >> "$debug"
+ # host options lang vvvvvv lang may or may not be there
+ sed -i "${line}s/\([^ ]* [^ ]*\)\( [^ ]*\)\{0,1\}/\1 $setlang/" "$users"
+ echo "$(date +%H:%M:%S) [setlang.sh] Exiting..." >> "$debug"
+ ;;
+ *) # aka "WTF?"
+ echo "$(date +%H:%M:%S) [setlang.sh] Some weird exitstatus: $status..." >> "$debug"
+ echo "$(date +%H:%M:%S) [setlang.sh] Exiting..." >> "$debug"
+ ;;
+esac
+echo "Language sucessfully set."; exit 0 # FIXME do that in other languages, and also check if the language even exists.....
diff --git a/src/sleep.sh b/src/sleep.sh
new file mode 100755
index 0000000..6acfd3c
--- /dev/null
+++ b/src/sleep.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+###########################################################################
+# awaysms - sleep.sh - sleep for a specific period and wait for replies #
+# Copyright (C) 2009 Florian Bruhin / The Compiler <me@the-compiler.org> #
+# #
+# sleep.sh is a part of awaysms. #
+# awaysms is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+###########################################################################
+
+# Source the settingfile
+. ~/.awaysms
+
+echo "$(date +%H:%M:%S) [sleep.sh]: We got launched." >> "$debug"
+
+# Echo the current pid to the pidfile
+echo "$(date +%H:%M:%S) [sleep.sh]: echoing the pid $$ into the pidfile $pidfile" >> "$debug"
+echo "$$" > "$pidfile"
+
+# Sleep for the sleepperiod
+echo "$(date +%H:%M:%S) [sleep.sh]: Now sleeping for $mailwait." >> "$debug"
+sleep "$mailwait"
+echo "$(date +%H:%M:%S) [sleep.sh]: Sleeping for pid $$ over, slept for $mailwait." >> "$debug"
+
+echo "$(date +%H:%M:%S) [sleep.sh]: Exiting." >> "$debug"
+exit 0
diff --git a/src/smssend.pl b/src/smssend.pl
new file mode 100755
index 0000000..4af7f08
--- /dev/null
+++ b/src/smssend.pl
@@ -0,0 +1,123 @@
+#!/usr/bin/perl -wT
+
+# Original file: http://www.nagiosexchange.org/cgi-bin/page.cgi?g=Detailed%2F1855.html;d=1
+# Created by serotizm I thinkg.
+# Modfications by Cristian Livadaru - office@lcx.at
+# http://cristian.livadaru.net/2006/04/27/nagios-with-sms-notification/
+# modified by pcdog pcdog@pcdog.ch
+
+use strict;
+use HTTP::Lite;
+use Getopt::Long;
+use URI::Escape;
+use vars qw($opt_version $opt_help $opt_username $opt_password $opt_api_id $opt_baseurl $opt_text $opt_to $PROGNAME);
+use lib "/opt/local/libexec/nagios/" ;
+use lib "/usr/lib/nagios/plugins/" ;
+use utils qw(%ERRORS &print_revision &support &usage);
+
+$PROGNAME = "notify_sms";
+
+sub print_help ();
+sub print_usage ();
+
+Getopt::Long::Configure('bundling');
+
+GetOptions
+ ("v" => \$opt_version, "version" => \$opt_version,
+ "h" => \$opt_help, "help" => \$opt_help,
+ "a=s" => \$opt_api_id, "apiid=s" => \$opt_api_id,
+ "b=s" => \$opt_baseurl, "baseurl=s" => \$opt_baseurl,
+ "m=s" => \$opt_text, "message=s" => \$opt_text,
+ "p=s" => \$opt_password, "password=s" => \$opt_password,
+ "t=s" => \$opt_to, "to=s" => \$opt_to,
+ "u=s" => \$opt_username, "username=s" => \$opt_username);
+
+if ($opt_version) {
+ print_revision($PROGNAME,'$Revision: 1.1 $');
+ exit $ERRORS{'OK'};
+}
+if ($opt_help) {print_help(); exit $ERRORS{'OK'};}
+
+($opt_api_id) || usage("Gateway api ID must be specified\n");
+($opt_text) || usage("Message body must be specified\n");
+($opt_password) || usage("Gateway login password must be specified\n");
+($opt_to) || usage("Phone to number must be specified\n");
+($opt_username) || usage("Gateway login username must be specified\n");
+
+if (!$opt_baseurl) {
+ $opt_baseurl = "http://api.clickatell.com";
+}
+
+my $login_url = $opt_baseurl."/http/auth?user=".$opt_username."&password=".$opt_password."&api_id=".$opt_api_id;
+my $http = new HTTP::Lite;
+my $req = $http->request($login_url);
+my $res = $http->body();
+my @sres = split(":", $res);
+
+
+if ($sres[0] eq "OK") {
+ my $sess = $sres[1];
+ chomp($sess);
+ $sess = substr($sess,1);
+ my $msg=uri_escape($opt_text);
+ my $send_url = $opt_baseurl."/http/sendmsg?session_id=".$sess."&to=".$opt_to."&text=".$msg;
+ my $rhttp = new HTTP::Lite;
+ my $ret = $rhttp->request($send_url);
+ my $nres = $rhttp->body();
+ my @sent = split(":", $nres);
+ if ($sent[0] eq "ID") {
+ print "Message sent\n";
+ exit $ERRORS{'OK'};
+ } else {
+ print "Gateway authentication failed\n";
+ exit $ERRORS{'CRITICAL'};
+ }
+} else {
+ print "Authentication failed\n";
+}
+
+sub urlencode {
+ my $ask = shift @_;
+ my @a2 = unpack "C*", $ask;
+ my $s2 = "";
+ while (@a2) {
+ $s2 .= sprintf "%%%X", shift @a2;
+ }
+ return $s2;
+}
+
+sub print_usage () {
+ print "Usage: $PROGNAME -u <gw_username> -p <gw_password> -a <gw_api_id> -b <gw_baseurl> -m <message_text> -t
+<to_msisdn>\n";
+}
+
+sub print_help () {
+ print_revision($PROGNAME,'$Revision: 1.1 $');
+ print "
+Copyright (c) 2005 Serhan D. KIYMAZ <skiymaz\@netpia.com>
+Netpia Internet Hizmetleri Pazarlama A.S. - TURKEY
+
+This plugin sends SMS notification messages to contacts from a SMS Gateway.
+It has been tested with Clickatell <www.clickatell.com>
+
+"; }
+
+ print_usage();
+ print "
+-a, --apiid=API_ID
+ Api ID for gateway login. It is specified by gateway company.
+-b, --baseurl=BASE_URL
+ Base URL for login and send SMS actions of gateway. Default: http://api.clickatell.com.
+-m, --message=MESSAGE_TEXT
+ Message text that will be sent to TO number. Max: 160 chars.
+-p, --password=PASSWORD
+ Login password for gateway login.
+-t, --to=TO_NUMBER
+ GSM phone number that the message will be delivered to.
+-u, --username=USERNAME
+ Login username for gateway login.
+
+";
+ support();
+
+
diff --git a/src/todo b/src/todo
new file mode 100755
index 0000000..eaabdb2
--- /dev/null
+++ b/src/todo
@@ -0,0 +1 @@
+do a read/setoption.sh which handles '-' and ',' correctly, etc.