From d41ad92ad44a37432fba7cba4f1c03cb1b636490 Mon Sep 17 00:00:00 2001 From: Madhurranjan Mohaan Date: Sep 15 2012 18:09:56 +0000 Subject: Added tests for the lsof and testing of lsof against sshd --- diff --git a/tests/p_lsof/0-install_lsof.sh b/tests/p_lsof/0-install_lsof.sh new file mode 100755 index 0000000..b49d3ab --- /dev/null +++ b/tests/p_lsof/0-install_lsof.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Author: Madhurranjan Mohaan + +t_Log "Running $0 - installing lsof" + +# Install lsof +t_InstallPackage lsof diff --git a/tests/p_lsof/10-test_lsof.sh b/tests/p_lsof/10-test_lsof.sh new file mode 100755 index 0000000..b4ad4a2 --- /dev/null +++ b/tests/p_lsof/10-test_lsof.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Author: Madhurranjan Mohaan + +t_Log "Running $0 - testing lsof against ssh port" + +../p_openssh/0-install_sshd.sh + +sshd_status=`service sshd status | grep running` +if ! [ "$sshd_status" ] +then + service sshd start +fi +sshd_port_listening=`lsof -i:22 | grep LISTEN` +if [ "$sshd_port_listening" ] +then + t_Log "Ssh port 22 is in the listening mode" + ret_val=0 +else + ret_val=1 +fi +t_CheckExitStatus $ret_val