Skip to content

Instantly share code, notes, and snippets.

@nalingarg2
Created June 15, 2015 19:59
Show Gist options
  • Save nalingarg2/3ebae4cd80eee8a200a9 to your computer and use it in GitHub Desktop.
Save nalingarg2/3ebae4cd80eee8a200a9 to your computer and use it in GitHub Desktop.
sample shell script
#!/bin/bash
set -x
#IFS=":"
LIST="118 117 116 112 103 44"
for i in $LIST; do
ssh root@10.2.1.$i '
passwd
mkdir -p ~/.ssh/authorized_keys
ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
chkconfig iptables off
chkconfig iptables --list
sudo wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cooki$
"http://download.oracle.com/otn-pub/java/jdk/7u71-b14/jdk-7u71-linux-x64.tar.gz"
inputHost() {
cat >> /etc/hosts <<EOF
10.2.0.118 ambari
10.2.0.117 namenode
10.2.0.116 jobtracker
10.2.0.112 snn
10.2.0.103 datanodeone
10.2.0.44 datanodetwo
EOF
}
stop_selinux () {
cat >> /etc/hosts <<EOF
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
EOF
}
inputHost
stop_selinux
ssh-copy-id -i ~/.ssh/id_rsa.pub root@datanodetwo
'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment