summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xjabberwall.pl15
-rwxr-xr-xnotify-reboot23
-rwxr-xr-xnotify-users38
3 files changed, 67 insertions, 9 deletions
diff --git a/jabberwall.pl b/jabberwall.pl
index c8c4897..e590d6d 100755
--- a/jabberwall.pl
+++ b/jabberwall.pl
@@ -10,8 +10,8 @@ use Data::Dumper;
# options are: server, port, username, password, ressource
# location: ~/.jabberwallrc
-if(@ARGV != 1) {
- print "usage: ", basename($0), " <userlist>\n";
+if(@ARGV != 3) {
+ print "usage: ", basename($0), " <userlist> <subject> <body>\n";
exit 1;
}
@@ -38,20 +38,17 @@ if ($result[0] ne "ok") {
die "Jabber auth error: @result\n";
}
-my $body = '';
-while (<STDIN>) {
- $body .= $_;
-}
-chomp($body);
+chomp(my $subject = $ARGV[1]);
+my $body = $ARGV[2];
for my $to (@recipients) {
chomp $to;
next if ($to eq "");
$clnt->MessageSend(to=>$to,
- subject=>"",
+ subject=>$subject,
body=>$body,
- type=>"chat",
+ type=>"message",
priority=>0);
}
diff --git a/notify-reboot b/notify-reboot
new file mode 100755
index 0000000..6429115
--- /dev/null
+++ b/notify-reboot
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+if [[ $# < 2 ]]; then
+ echo "usage: $(basename "$0") <server> <relativ time>"
+ exit
+fi
+
+server="$1"
+orig_date="$2"
+
+date="$(date -d "$orig_date" +%s)"
+if [[ "$date" == "" ]]; then
+ echo "\$date is empty"
+ exit 1
+fi
+
+servername=$(cat ~/"docs/$server/servername")
+if [[ "$servername" == "" ]]; then
+ echo "\"~/docs/$server/servername\" is empty or doesn't exist"
+ exit 1
+fi
+
+notify-users "$server" "Notice: $servername will reboot in $orig_date ($(date -d @$date))"
diff --git a/notify-users b/notify-users
new file mode 100755
index 0000000..1b63037
--- /dev/null
+++ b/notify-users
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+if [[ $# < 2 ]]; then
+ echo "usage: $(basename "$0") <server> <subject>"
+ exit
+fi
+
+server=$1
+subject=$2
+
+send_mails() {
+ addr_file=$1
+ subject=$2
+ body=$3
+ from="Florian Pritz <flo@xinu.at>"
+
+ for addr in $(cat "$addr_file"); do
+ msmtp -t <<EOF
+Subject: $subject
+From: $from
+To: $addr
+Date: $(date -R)
+
+$body
+
+EOF
+ done
+}
+
+echo "Mail body: ^D to send"
+body=$(cat)
+
+if [[ "$body" == "" ]]; then
+ body="No more information available."
+fi
+
+jabberwall.pl ~/"docs/$server/users/jabber" "$subject" "$body"
+send_mails ~/"docs/$server/users/email" "$subject" "$body"