Skip to content

Instantly share code, notes, and snippets.

@richardpeng
Created October 19, 2010 18:28
Show Gist options
  • Save richardpeng/634753 to your computer and use it in GitHub Desktop.
Save richardpeng/634753 to your computer and use it in GitHub Desktop.
#!/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