Created
October 19, 2010 18:28
-
-
Save richardpeng/634753 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Setup passwordless login and install nagios plugin on remote client | |
ID=/etc/nagios3/keys/id_rsa | |
SCRIPT=nagios-install-plugins.sh | |
SCRIPTPATH=/home/richard/scripts | |
EXTRA=nagios-plugins-extra | |
if [ -e "$SCRIPTPATH/$SCRIPT" ]; then | |
sudo su -l -s /bin/bash nagios -c "ssh-copy-id -i $ID $1; \ | |
ssh -i $ID $1 exit; \ | |
scp -i $ID $SCRIPTPATH/$SCRIPT $1:; \ | |
ssh -i $ID $1 \"chmod +x ~/$SCRIPT;~/$SCRIPT;rm ~/$SCRIPT;exit\"" | |
if [ -d "$SCRIPTPATH/$EXTRA" ]; then | |
sudo su -l -s /bin/bash nagios -c "scp -i $ID $SCRIPTPATH/$EXTRA/* $1:nagios-plugins/" | |
else | |
echo "No extra plugins detected" | |
fi | |
else | |
echo "Install script missing: $SCRIPTPATH/$SCRIPT" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment