Blame tests/p_lsof/10-test_lsof.sh

Madhurranjan Mohaan d41ad9
#!/bin/bash
Madhurranjan Mohaan d41ad9
Madhurranjan Mohaan d41ad9
# Author: Madhurranjan Mohaan <madhurranjan.mohaan@gmail.com>
Madhurranjan Mohaan d41ad9
Madhurranjan Mohaan d41ad9
t_Log "Running $0 - testing lsof against ssh port"
Madhurranjan Mohaan d41ad9
Madhurranjan Mohaan d41ad9
sshd_status=`service sshd status | grep running`
Madhurranjan Mohaan d41ad9
if ! [ "$sshd_status" ]
Madhurranjan Mohaan d41ad9
then
Madhurranjan Mohaan d41ad9
  service sshd start
Madhurranjan Mohaan d41ad9
fi
Madhurranjan Mohaan 3764b5
t_InstallPackage openssh-server openssh-clients 
Madhurranjan Mohaan 3764b5
t_ServiceControl sshd start
Madhurranjan Mohaan d41ad9
Madhurranjan Mohaan d41ad9
sshd_port_listening=`lsof -i:22 | grep LISTEN`
Madhurranjan Mohaan d41ad9
if [ "$sshd_port_listening" ]
Madhurranjan Mohaan d41ad9
then
Madhurranjan Mohaan d41ad9
  t_Log "Ssh port 22 is in the listening mode"
Madhurranjan Mohaan d41ad9
  ret_val=0
Madhurranjan Mohaan d41ad9
else 
Madhurranjan Mohaan d41ad9
  ret_val=1
Madhurranjan Mohaan d41ad9
fi
Madhurranjan Mohaan d41ad9
t_CheckExitStatus $ret_val