#!/bin/bash

sign_conf=/etc/firewalld/absolute_safe.conf
role_service=role
sshd_service=sshd
telnetd_service=telnetd
online_service_sh=/etc/init.d/online
sshd_service_sh=/etc/init.d/sshd
telnetd_service_sh=/etc/init.d/telnetd

sign=`awk -F= '/absolute_safe_mode/ {print $2}' $sign_conf`
role_pid=`pidof "$role_service"`
sshd_pid=`pidof "$sshd_service"`
telnetd_pid=`pidof "$telnetd_service"`


if [ $sign = "1" ];then
	#判断 远程访问
	if [ ! -z "$role_pid" ]; then
		${online_service_sh} stop
		echo online stop
	fi
	sleep 2
	
	#判断 telnetd
	if [ ! -z "$telnetd_pid" ];then
		${telnetd_service_sh} stop
		echo telnetd stop
	fi
	sleep 2
	
	#判断 ssh
	if [ ! -z "$sshd_pid" ];then
		${sshd_service_sh} stop
		echo ssh stop
	fi
else
	if [ -z "$role_pid" ];then
		${online_service_sh} start
		echo online starting
	fi
	sleep 2
	
	if [ -z "$telnetd_pid" ];then
		${telnetd_service_sh} start
		echo telnetd starting
	fi
	sleep 2
	
	if [ -z "$sshd_pid" ];then
		${sshd_service_sh} start
		echo ssh starting
	fi
fi

