#!/bin/bash

#used for cli command "set system services ssh disable"
#input:
#      $1: "ture"  disable sshd
#          "false" enable sshd
#no output var
# "true" kills sshd
if [[ x"$1" == x"true" ]] ; then
    #pid=`ps | grep -v grep | grep '/usr/sbin/sshd' | awk '{print $1}'`
    #[ $pid ] && kill -9 $pid
    #sshd_run=`/etc/init.d/ssh status | grep "is running" | wc -l`
    #[ $sshd_run -ge 1 ] && /etc/init.d/ssh stop
    if [ -f /var/run/sshd.pid ];then
       /etc/init.d/ssh stop > /dev/null
    fi
elif [[ x"$1" == x"false" ]]; then
    #pid=`ps | grep -v grep | grep '/usr/sbin/sshd' | awk '{print $1}'`
    #[ x"$pid"==x"" ] && /usr/sbin/sshd
    #sshd_run=`/etc/init.d/ssh status | grep "is running" | wc -l`
    #[ $sshd_run -ge 0 ] && /etc/init.d/ssh start
    if [ ! -f /var/run/sshd.pid ];then
       /etc/init.d/ssh start > /dev/null
    fi
fi                                                   

exit 0
