lib/ssh.sh in forj-0.0.40 vs lib/ssh.sh in forj-0.0.41
- old
+ new
@@ -18,12 +18,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
NOW=$(date +%Y-%m-%d.%H%M%S)
-logpath=~/.ssh/
-DB=~/hosts
+logpath=~/.forj/
+DB=~/.forj/hosts
#key_path=~/.ssh/
#key_path=~/.hpcloud/keypairs/
init_config=~/ssh_init
key="nova.pem"
@@ -94,11 +94,11 @@
sed -i -n '/\#\#\#\# Below list are updated/q;p' $DB
sed -i '/^$/d' $DB
echo -e "\n#### Below list are updated" >> $DB
- hpcloud servers | awk -F"\|" '{print $3","$6","$9","$7}' | awk -F, '{print $1$3$4$5}' >> $DB
+ hpcloud servers -a $2 | awk -F"\|" '{print $3","$6","$9","$7}' | awk -F, '{print $1$3$4$5}' >> $DB
echo -e "\033[1;32m$DB Updated\033[00m"
linenum=$(cat $DB | grep -E -n "#### Below list are updated" | awk -F: '{print $1}')
new_serversnum=$(tail -n +$linenum $DB | grep -E " .*\..* " | wc -l)
diff=$(echo "$new_serversnum - $old_serversnum" | bc)
echo "Old Servers: $old_serversnum, New Servers: $new_serversnum, Diff: $diff"
@@ -120,10 +120,11 @@
message="$ip"
#parameter is ID NODE
else
id=$1
node=$2
+ key=$3
if [ "$node" == "" ]; then
echo -e "${RED}Error, no server name sent.$RST"
exit 1
fi
@@ -138,11 +139,11 @@
ip=$(cat $DB | grep -iE "[a-ZA-Z]+\.$id" | grep -i $node | awk '{print $2}' | tr -d ' ')
if [ "$ip" == "" ]; then
echo -e "${RED}Error, the kit ${GRE}$node${RED} with id ${GRE}$id${RED} was not found.${RST}"
exit 1
fi
- key=$(cat $DB | grep -iEw "$ip" | awk '{print $4}' | tr -d ' ')
+ #key=$(cat $DB | grep -iEw "$ip" | awk '{print $4}' | tr -d ' ')
message="$node.$id"
extended="($ip)"
if [ "$ip" == "" ] || [ "$key" == "" ]; then
echo -e "${RED}Error, combination was not found, maybe you should update the db.$RST"
@@ -153,11 +154,11 @@
if [ "$node" != "" ]; then
logname="$node.$id"
else
logname="$ip"
fi
-key="$key_path$key.pem"
+#key="$key_path$key.pem"
echo -e "Connecting to $GRE$message$RST using $BLU$key$RST $extended"
if [[ ! -f $key ]]; then
echo -e "${RED}Key doesn't exists$RST"
@@ -179,6 +180,6 @@
ssh -o StrictHostKeyChecking=no -o ServerAliveInterval=180 -i $key ubuntu@$ip < $init_config
echo -e "Reconnecting..."
fi
ssh -o StrictHostKeyChecking=no -o ServerAliveInterval=180 -i $key ubuntu@$ip | tee -a $logfile
echo -e "$RED══════════════════════════════════════════════════════════════════════════$RST"
-echo -e "${GRE}Log file: ${RST}$logfile"
\ No newline at end of file
+echo -e "${GRE}Log file: ${RST}$logfile"