X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sshsendmail;h=866847024fd2bff170f589033e241ce189cfd0bc;hb=82befb00f4d6101fc6dd266166805ee34be2e35d;hp=815130294a656d32b82e34c1ba6e143402e2997e;hpb=87ccbd0890cfe4a905c86b73fb03942c385a814d;p=bin.git diff --git a/sshsendmail b/sshsendmail index 8151302..8668470 100755 --- a/sshsendmail +++ b/sshsendmail @@ -21,14 +21,18 @@ sshsendmail - Uses ssh to send a mail message to a different machine's copy of s =head1 SYNOPSIS -ss [options] +Stick this command in /usr/lib/nullmailer/sshsendmail. + +Then add + +foohost.com sshsendmail --identity=/var/mail/.ssh/id_rsa --username remotemail --sendmail-options='-baruser@foohost.com' + +to /etc/nullmailer/remotes. Options: - --host, -H host to upload image to - --dir, -D dir to place image (on host of -H set) - --import-options, -I options to import (default -window root) - --convert-options, -C options to convert (for scaling) - --scale, -s make scaled image (default) + --identity, -i ssh identity to use to connect to the server + --username, -l remote username + --sendmail-options, -o options to pass to sendmail --debug, -d debugging level (Default 0) --help, -h display this help --man, -m display manual @@ -55,15 +59,6 @@ Display this manual. =back -=head1 EXAMPLES - - ss - -Will pretty much do what you want - - ss -I - -Will take a picture of a window you select. =cut @@ -84,12 +79,11 @@ my %options = (debug => 0, host => undef, identity => undef, username => undef, - log => '/var/mail/log', - 'sendmail-options' => '', + 'sendmail_options' => [''], ); GetOptions(\%options,'identity|i=s','username|l=s','daemon|d', 'syslog|s', - 'sendmail-options|o=s','log|l=s', + 'sendmail_options|sendmail-options|o=s@', 'help|h|?','man|m'); pod2usage() if $options{help}; @@ -130,26 +124,23 @@ my @ssh_arguments = ($hostname); push @ssh_arguments, '-i', $options{identity} if defined $options{identity}; push @ssh_arguments, '-l', $options{username} if defined $options{username}; -push @ssh_arguments, q(cat - | /usr/lib/sendmail ).$options{'sendmail-options'}.' '.join(' ',@recipients); +push @ssh_arguments, q(cat - | /usr/lib/sendmail ). + join(' ',ref($options{sendmail_options})?@{$options{sendmail_options}}:($options{sendmail_options}//'')). + ' '.join(' ',@recipients); qx(ping -q -c 3 $hostname 2>/dev/null); if ($?) { print STDERR "${0}: Failed: unable to ping $hostname\n"; exit (9); } my $ssh = new IO::Handle; -my $log = new IO::File $options{log},'w+' or exit(2); -print {$log} @message or exit(2); -print {$log} join(' ',('ssh',@ssh_arguments)) or exit(2); open($ssh,'|-','ssh',@ssh_arguments) or exit(17); print {$ssh} @message or exit(17); close $ssh or exit(17); if ($?) { print STDERR "${0}: Failed: sendmail died for some reason\n"; - print {$log} "${0}: Failed: sendmail died for some reason\n"; exit (17); } else { print STDERR "${0}: Succeeded: Yeay\n"; - print {$log} "${0}: Succeeded: Yeay\n"; exit 0; }